|
19 | 19 | use Ibexa\Bundle\Core\DependencyInjection\Configuration\Suggestion\Formatter\YamlSuggestionFormatter; |
20 | 20 | use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\PoliciesConfigBuilder; |
21 | 21 | use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface; |
22 | | -use Ibexa\Bundle\Core\Session\Handler\NativeSessionHandler; |
23 | 22 | use Ibexa\Bundle\Core\SiteAccess\SiteAccessConfigurationFilter; |
24 | 23 | use Ibexa\Contracts\Core\MVC\EventSubscriber\ConfigScopeChangeSubscriber; |
25 | 24 | use Ibexa\Contracts\Core\Repository\Values\Filter\CriterionQueryBuilder as FilteringCriterionQueryBuilder; |
@@ -194,7 +193,6 @@ public function prepend(ContainerBuilder $container): void |
194 | 193 | $this->handleDefaultSettingsLoading($container); |
195 | 194 |
|
196 | 195 | $this->configureGenericSetup($container); |
197 | | - $this->configurePlatformShSetup($container); |
198 | 196 | } |
199 | 197 |
|
200 | 198 | /** |
@@ -803,188 +801,6 @@ private function configureGenericSetup(ContainerBuilder $container): void |
803 | 801 | } |
804 | 802 | } |
805 | 803 |
|
806 | | - /** |
807 | | - * @throws \Exception |
808 | | - */ |
809 | | - private function configurePlatformShSetup(ContainerBuilder $container): void |
810 | | - { |
811 | | - $projectDir = $container->getParameter('kernel.project_dir'); |
812 | | - |
813 | | - // Will not be executed on build step |
814 | | - $relationships = $_SERVER['PLATFORM_RELATIONSHIPS'] ?? false; |
815 | | - if (!$relationships) { |
816 | | - return; |
817 | | - } |
818 | | - $routes = $_SERVER['PLATFORM_ROUTES']; |
819 | | - |
820 | | - $relationships = json_decode(base64_decode($relationships), true); |
821 | | - $routes = json_decode(base64_decode($routes), true); |
822 | | - |
823 | | - // PLATFORMSH_DFS_NFS_PATH is different compared to DFS_NFS_PATH in the sense that it is relative to ezplatform dir |
824 | | - // DFS_NFS_PATH is an absolute path |
825 | | - if ($dfsNfsPath = $_SERVER['PLATFORMSH_DFS_NFS_PATH'] ?? false) { |
826 | | - $container->setParameter('dfs_nfs_path', sprintf('%s/%s', $projectDir, $dfsNfsPath)); |
827 | | - |
828 | | - // Map common parameters |
829 | | - $container->setParameter('dfs_database_charset', $container->getParameter('database_charset')); |
830 | | - $container->setParameter( |
831 | | - 'dfs_database_collation', |
832 | | - $container->getParameter('database_collation') |
833 | | - ); |
834 | | - if (\array_key_exists('dfs_database', $relationships)) { |
835 | | - // process dedicated P.sh dedicated config |
836 | | - foreach ($relationships['dfs_database'] as $endpoint) { |
837 | | - if (empty($endpoint['query']['is_master'])) { |
838 | | - continue; |
839 | | - } |
840 | | - $container->setParameter('dfs_database_driver', 'pdo_' . $endpoint['scheme']); |
841 | | - $container->setParameter( |
842 | | - 'dfs_database_url', |
843 | | - sprintf( |
844 | | - '%s://%s:%s@%s:%d/%s', |
845 | | - $endpoint['scheme'], |
846 | | - $endpoint['username'], |
847 | | - $endpoint['password'], |
848 | | - $endpoint['host'], |
849 | | - $endpoint['port'], |
850 | | - $endpoint['path'] |
851 | | - ) |
852 | | - ); |
853 | | - } |
854 | | - } else { |
855 | | - // or set fallback from the Repository database, if not configured |
856 | | - $container->setParameter('dfs_database_driver', $container->getParameter('database_driver')); |
857 | | - } |
858 | | - |
859 | | - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/dfs')); |
860 | | - $loader->load('dfs.yaml'); |
861 | | - } |
862 | | - |
863 | | - // Use Redis-based caching if possible. |
864 | | - if (isset($relationships['rediscache'])) { |
865 | | - foreach ($relationships['rediscache'] as $endpoint) { |
866 | | - if ($endpoint['scheme'] !== 'redis') { |
867 | | - continue; |
868 | | - } |
869 | | - |
870 | | - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); |
871 | | - $loader->load('cache.redis.yaml'); |
872 | | - |
873 | | - $container->setParameter('cache_pool', 'cache.redis'); |
874 | | - $container->setParameter('cache_dsn', sprintf('%s:%d', $endpoint['host'], $endpoint['port']) . '?retry_interval=3'); |
875 | | - } |
876 | | - } elseif (isset($relationships['cache'])) { |
877 | | - // Fallback to memcached if here (deprecated, we will only handle redis here in the future) |
878 | | - foreach ($relationships['cache'] as $endpoint) { |
879 | | - if ($endpoint['scheme'] !== 'memcached') { |
880 | | - continue; |
881 | | - } |
882 | | - |
883 | | - @trigger_error('Usage of Memcached is deprecated, redis is recommended', E_USER_DEPRECATED); |
884 | | - |
885 | | - $container->setParameter('cache_pool', 'cache.memcached'); |
886 | | - $container->setParameter('cache_dsn', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); |
887 | | - |
888 | | - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); |
889 | | - $loader->load('cache.memcached.yaml'); |
890 | | - } |
891 | | - } |
892 | | - |
893 | | - // Use Redis-based sessions if possible. If a separate Redis instance |
894 | | - // is available, use that. If not, share a Redis instance with the |
895 | | - // Cache. (That should be safe to do except on especially high-traffic sites.) |
896 | | - if (isset($relationships['redissession'])) { |
897 | | - foreach ($relationships['redissession'] as $endpoint) { |
898 | | - if ($endpoint['scheme'] !== 'redis') { |
899 | | - continue; |
900 | | - } |
901 | | - |
902 | | - $container->setParameter('ibexa.session.handler_id', NativeSessionHandler::class); |
903 | | - $container->setParameter('ibexa.session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); |
904 | | - } |
905 | | - } elseif (isset($relationships['rediscache'])) { |
906 | | - foreach ($relationships['rediscache'] as $endpoint) { |
907 | | - if ($endpoint['scheme'] !== 'redis') { |
908 | | - continue; |
909 | | - } |
910 | | - |
911 | | - $container->setParameter('ibexa.session.handler_id', NativeSessionHandler::class); |
912 | | - $container->setParameter('ibexa.session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); |
913 | | - } |
914 | | - } |
915 | | - |
916 | | - if (isset($relationships['solr'])) { |
917 | | - foreach ($relationships['solr'] as $endpoint) { |
918 | | - if ($endpoint['scheme'] !== 'solr') { |
919 | | - continue; |
920 | | - } |
921 | | - |
922 | | - $container->setParameter('search_engine', 'solr'); |
923 | | - |
924 | | - $container->setParameter('solr_dsn', sprintf('http://%s:%d/%s', $endpoint['host'], $endpoint['port'], 'solr')); |
925 | | - // To set solr_core parameter we assume path is in form like: "solr/collection1" |
926 | | - $container->setParameter('solr_core', substr($endpoint['path'], 5)); |
927 | | - } |
928 | | - } |
929 | | - |
930 | | - if (isset($relationships['elasticsearch'])) { |
931 | | - foreach ($relationships['elasticsearch'] as $endpoint) { |
932 | | - $dsn = sprintf('%s:%d', $endpoint['host'], $endpoint['port']); |
933 | | - |
934 | | - if ($endpoint['username'] !== null && $endpoint['password'] !== null) { |
935 | | - $dsn = $endpoint['username'] . ':' . $endpoint['password'] . '@' . $dsn; |
936 | | - } |
937 | | - |
938 | | - if ($endpoint['path'] !== null) { |
939 | | - $dsn .= '/' . $endpoint['path']; |
940 | | - } |
941 | | - |
942 | | - $dsn = $endpoint['scheme'] . '://' . $dsn; |
943 | | - |
944 | | - $container->setParameter('search_engine', 'elasticsearch'); |
945 | | - $container->setParameter('elasticsearch_dsn', $dsn); |
946 | | - } |
947 | | - } |
948 | | - |
949 | | - // We will pick a varnish route by the following prioritization: |
950 | | - // - The first route found that has upstream: varnish |
951 | | - // - if primary route has upstream: varnish, that route will be prioritised |
952 | | - // If no route is found with upstream: varnish, then purge_server will not be set |
953 | | - $route = null; |
954 | | - foreach ($routes as $host => $info) { |
955 | | - if ($route === null && $info['type'] === 'upstream' && $info['upstream'] === 'varnish') { |
956 | | - $route = $host; |
957 | | - } |
958 | | - if ($info['type'] === 'upstream' && $info['upstream'] === 'varnish' && $info['primary'] === true) { |
959 | | - $route = $host; |
960 | | - break; |
961 | | - } |
962 | | - } |
963 | | - |
964 | | - if ($route !== null && !($_SERVER['SKIP_HTTPCACHE_PURGE'] ?? false)) { |
965 | | - $purgeServer = rtrim($route, '/'); |
966 | | - if (($_SERVER['HTTPCACHE_USERNAME'] ?? false) && ($_SERVER['HTTPCACHE_PASSWORD'] ?? false)) { |
967 | | - $domain = parse_url($purgeServer, PHP_URL_HOST); |
968 | | - $credentials = urlencode($_SERVER['HTTPCACHE_USERNAME']) . ':' . urlencode($_SERVER['HTTPCACHE_PASSWORD']); |
969 | | - $purgeServer = str_replace($domain, $credentials . '@' . $domain, $purgeServer); |
970 | | - } |
971 | | - |
972 | | - $container->setParameter('ibexa.http_cache.purge_type', 'varnish'); |
973 | | - $container->setParameter('purge_type', 'varnish'); |
974 | | - $container->setParameter('purge_server', $purgeServer); |
975 | | - } |
976 | | - // Setting default value for HTTPCACHE_VARNISH_INVALIDATE_TOKEN if it is not explicitly set |
977 | | - if (!($_SERVER['HTTPCACHE_VARNISH_INVALIDATE_TOKEN'] ?? false)) { |
978 | | - $container->setParameter('varnish_invalidate_token', $_SERVER['PLATFORM_PROJECT_ENTROPY']); |
979 | | - } |
980 | | - |
981 | | - // Adapt config based on enabled PHP extensions |
982 | | - // Get imagine to use imagick if enabled, to avoid using php memory for image conversions |
983 | | - if (\extension_loaded('imagick')) { |
984 | | - $container->setParameter('liip_imagine_driver', 'imagick'); |
985 | | - } |
986 | | - } |
987 | | - |
988 | 804 | private function shouldLoadTestBehatServices(ContainerBuilder $container): bool |
989 | 805 | { |
990 | 806 | return $container->hasParameter('ibexa.behat.browser.enabled') |
|
0 commit comments