diff --git a/src/bundle/Core/DependencyInjection/Configuration/ContainerConfigurator/Generic.php b/src/bundle/Core/DependencyInjection/Configuration/ContainerConfigurator/Generic.php new file mode 100644 index 0000000000..7b7086e4c6 --- /dev/null +++ b/src/bundle/Core/DependencyInjection/Configuration/ContainerConfigurator/Generic.php @@ -0,0 +1,115 @@ +setParameter('search_engine', '%env(SEARCH_ENGINE)%'); + + // Session save path as used by symfony session handlers (e.g. used for dsn with redis) + $container->setParameter('ibexa.session.save_path', '%kernel.project_dir%/var/sessions/%kernel.environment%'); + + // Predefined pools are located in config/packages/cache_pool/ + // You can add your own cache pool to the folder mentioned above. + // In order to change the default cache_pool use environmental variable export. + // The line below must not be altered as required cache service files are resolved based on environmental config. + $container->setParameter('cache_pool', '%env(CACHE_POOL)%'); + + // By default, cache ttl is set to 24h, when using Varnish you can set a much higher value. High values depends on + // using IbexaHttpCacheBundle (default as of v1.12) which by design expires affected cache on changes + $container->setParameter('httpcache_default_ttl', '%env(HTTPCACHE_DEFAULT_TTL)%'); + + // Settings for HttpCache + $container->setParameter('purge_server', '%env(HTTPCACHE_PURGE_SERVER)%'); + + // Identifier used to generate the CSRF token. Commenting this line will result in authentication + // issues both in AdminUI and REST calls + $container->setParameter('ibexa.rest.csrf_token_intention', 'authenticate'); + + // Varnish invalidation/purge token (for use on platform.sh, Ibexa Cloud and other places you can't use IP for ACL) + $container->setParameter('varnish_invalidate_token', '%env(resolve:default::HTTPCACHE_VARNISH_INVALIDATE_TOKEN)%'); + + // Compile time handlers + // These are defined at compile time, and hence can't be set at runtime using env() + // config/env/generic.php takes care about letting you set them by env variables + + // Session handler, by default set to file based (instead of ~) in order to be able to use %ibexa.session.save_path% + $container->setParameter('ibexa.session.handler_id', 'session.handler.native_file'); + + // Purge type used by HttpCache system ("local", "varnish"/"http", and on ee also "fastly") + $container->setParameter('purge_type', '%env(HTTPCACHE_PURGE_TYPE)%'); + + $container->setParameter('solr_dsn', '%env(SOLR_DSN)%'); + $container->setParameter('solr_core', '%env(SOLR_CORE)%'); + + $projectDir = $container->getParameter('kernel.project_dir'); + + if (null !== ($dfsNfsPath = $_SERVER['DFS_NFS_PATH'] ?? null)) { + $container->setParameter('dfs_nfs_path', $dfsNfsPath); + + $parameterMap = [ + 'dfs_database_charset' => 'database_charset', + 'dfs_database_driver' => 'database_driver', + 'dfs_database_collation' => 'database_collation', + ]; + + foreach ($parameterMap as $dfsParameter => $platformParameter) { + $container->setParameter( + $dfsParameter, + $_SERVER[strtoupper($dfsParameter)] ?? $container->getParameter($platformParameter) + ); + } + + $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/dfs')); + $loader->load('dfs.yaml'); + } + + // Cache settings + // If CACHE_POOL env variable is set, check if there is a yml file that needs to be loaded for it + if ( + null !== ($pool = $_SERVER['CACHE_POOL'] ?? null) && + file_exists($projectDir . "/config/packages/cache_pool/${pool}.yaml") + ) { + $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); + $loader->load($pool . '.yaml'); + } + + if (null !== ($purgeType = $_SERVER['HTTPCACHE_PURGE_TYPE'] ?? null)) { + $container->setParameter('purge_type', $purgeType); + $container->setParameter('ibexa.http_cache.purge_type', $purgeType); + } + + if (null !== ($value = $_SERVER['MAILER_TRANSPORT'] ?? null)) { + $container->setParameter('mailer_transport', $value); + } + + if (null !== ($value = $_SERVER['LOG_TYPE'] ?? null)) { + $container->setParameter('log_type', $value); + } + + if (null !== ($value = $_SERVER['SESSION_HANDLER_ID'] ?? null)) { + $container->setParameter('ibexa.session.handler_id', $value); + } + + if (null !== ($value = $_SERVER['SESSION_SAVE_PATH'] ?? null)) { + $container->setParameter('ibexa.session.save_path', $value); + } + } +} diff --git a/src/bundle/Core/DependencyInjection/Configuration/ContainerConfigurator/PlatformSh.php b/src/bundle/Core/DependencyInjection/Configuration/ContainerConfigurator/PlatformSh.php new file mode 100644 index 0000000000..00d65097c8 --- /dev/null +++ b/src/bundle/Core/DependencyInjection/Configuration/ContainerConfigurator/PlatformSh.php @@ -0,0 +1,207 @@ +getParameter('kernel.project_dir'); + + // Will not be executed on build step + $relationships = $_SERVER['PLATFORM_RELATIONSHIPS'] ?? null; + if (null === $relationships) { + return; + } + $routes = $_SERVER['PLATFORM_ROUTES']; + + $relationships = json_decode(base64_decode($relationships), true); + $routes = json_decode(base64_decode($routes), true); + + // PLATFORMSH_DFS_NFS_PATH is different compared to DFS_NFS_PATH in the sense that it is relative to ezplatform dir + // DFS_NFS_PATH is an absolute path + if (null !== ($dfsNfsPath = $_SERVER['PLATFORMSH_DFS_NFS_PATH'] ?? null)) { + $container->setParameter('dfs_nfs_path', sprintf('%s/%s', $projectDir, $dfsNfsPath)); + + // Map common parameters + $container->setParameter('dfs_database_charset', $container->getParameter('database_charset')); + $container->setParameter( + 'dfs_database_collation', + $container->getParameter('database_collation') + ); + if (\array_key_exists('dfs_database', $relationships)) { + // process dedicated P.sh dedicated config + foreach ($relationships['dfs_database'] as $endpoint) { + if (empty($endpoint['query']['is_master'])) { + continue; + } + $container->setParameter('dfs_database_driver', 'pdo_' . $endpoint['scheme']); + $container->setParameter( + 'dfs_database_url', + sprintf( + '%s://%s:%s:%d@%s/%s', + $endpoint['scheme'], + $endpoint['username'], + $endpoint['password'], + $endpoint['port'], + $endpoint['host'], + $endpoint['path'] + ) + ); + } + } else { + // or set fallback from the Repository database, if not configured + $container->setParameter('dfs_database_driver', $container->getParameter('database_driver')); + } + + $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/dfs')); + $loader->load('dfs.yaml'); + } + + // Use Redis-based caching if possible. + if (isset($relationships['rediscache'])) { + foreach ($relationships['rediscache'] as $endpoint) { + if ($endpoint['scheme'] !== 'redis') { + continue; + } + + $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); + $loader->load('cache.redis.yaml'); + + $container->setParameter('cache_pool', 'cache.redis'); + $container->setParameter('cache_dsn', sprintf('%s:%d', $endpoint['host'], $endpoint['port']) . '?retry_interval=3'); + } + } elseif (isset($relationships['cache'])) { + // Fallback to memcached if here (deprecated, we will only handle redis here in the future) + foreach ($relationships['cache'] as $endpoint) { + if ($endpoint['scheme'] !== 'memcached') { + continue; + } + + @trigger_error('Usage of Memcached is deprecated, redis is recommended', E_USER_DEPRECATED); + + $container->setParameter('cache_pool', 'cache.memcached'); + $container->setParameter('cache_dsn', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); + + $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); + $loader->load('cache.memcached.yaml'); + } + } + + // Use Redis-based sessions if possible. If a separate Redis instance + // is available, use that. If not, share a Redis instance with the + // Cache. (That should be safe to do except on especially high-traffic sites.) + if (isset($relationships['redissession'])) { + foreach ($relationships['redissession'] as $endpoint) { + if ($endpoint['scheme'] !== 'redis') { + continue; + } + + $container->setParameter('ibexa.session.handler_id', NativeSessionHandler::class); + $container->setParameter('ibexa.session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); + } + } elseif (isset($relationships['rediscache'])) { + foreach ($relationships['rediscache'] as $endpoint) { + if ($endpoint['scheme'] !== 'redis') { + continue; + } + + $container->setParameter('ibexa.session.handler_id', NativeSessionHandler::class); + $container->setParameter('ibexa.session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); + } + } + + if (isset($relationships['solr'])) { + foreach ($relationships['solr'] as $endpoint) { + if ($endpoint['scheme'] !== 'solr') { + continue; + } + + $container->setParameter('search_engine', 'solr'); + + $container->setParameter('solr_dsn', sprintf('http://%s:%d/%s', $endpoint['host'], $endpoint['port'], 'solr')); + // To set solr_core parameter we assume path is in form like: "solr/collection1" + $container->setParameter('solr_core', substr($endpoint['path'], 5)); + } + } + + if (isset($relationships['elasticsearch'])) { + foreach ($relationships['elasticsearch'] as $endpoint) { + $dsn = sprintf('%s:%d', $endpoint['host'], $endpoint['port']); + + if ($endpoint['username'] !== null && $endpoint['password'] !== null) { + $dsn = $endpoint['username'] . ':' . $endpoint['password'] . '@' . $dsn; + } + + if ($endpoint['path'] !== null) { + $dsn .= '/' . $endpoint['path']; + } + + $dsn = $endpoint['scheme'] . '://' . $dsn; + + $container->setParameter('search_engine', 'elasticsearch'); + $container->setParameter('elasticsearch_dsn', $dsn); + } + } + + // We will pick a varnish route by the following prioritization: + // - The first route found that has upstream: varnish + // - if primary route has upstream: varnish, that route will be prioritised + // If no route is found with upstream: varnish, then purge_server will not be set + $route = null; + foreach ($routes as $host => $info) { + if ($route === null && $info['type'] === 'upstream' && $info['upstream'] === 'varnish') { + $route = $host; + } + if ($info['type'] === 'upstream' && $info['upstream'] === 'varnish' && $info['primary'] === true) { + $route = $host; + break; + } + } + + if ($route !== null && null !== ($_SERVER['SKIP_HTTPCACHE_PURGE'] ?? null)) { + $purgeServer = rtrim($route, '/'); + if ( + null !== ($_SERVER['HTTPCACHE_USERNAME'] ?? null) && + null !== ($_SERVER['HTTPCACHE_PASSWORD'] ?? null) + ) { + $domain = parse_url($purgeServer, PHP_URL_HOST); + $credentials = sprintf( + '%s:%s', + urlencode($_SERVER['HTTPCACHE_USERNAME']), + urlencode($_SERVER['HTTPCACHE_PASSWORD']) + ); + $purgeServer = str_replace($domain, $credentials . '@' . $domain, $purgeServer); + } + + $container->setParameter('ibexa.http_cache.purge_type', 'varnish'); + $container->setParameter('purge_type', 'varnish'); + $container->setParameter('purge_server', $purgeServer); + } + // Setting default value for HTTPCACHE_VARNISH_INVALIDATE_TOKEN if it is not explicitly set + if (null === ($_SERVER['HTTPCACHE_VARNISH_INVALIDATE_TOKEN'] ?? null)) { + $container->setParameter('varnish_invalidate_token', $_SERVER['PLATFORM_PROJECT_ENTROPY']); + } + + // Adapt config based on enabled PHP extensions + // Get imagine to use imagick if enabled, to avoid using php memory for image conversions + if (\extension_loaded('imagick')) { + $container->setParameter('liip_imagine_driver', 'imagick'); + } + } +} diff --git a/src/bundle/Core/DependencyInjection/Configuration/ContainerConfiguratorInterface.php b/src/bundle/Core/DependencyInjection/Configuration/ContainerConfiguratorInterface.php new file mode 100644 index 0000000000..bf404802a7 --- /dev/null +++ b/src/bundle/Core/DependencyInjection/Configuration/ContainerConfiguratorInterface.php @@ -0,0 +1,21 @@ +load('routing/js_routing.yml'); } - // Default settings - $this->handleDefaultSettingsLoading($container, $loader); - $this->registerRepositoriesConfiguration($config, $container); $this->registerSiteAccessConfiguration($config, $container); $this->registerImageMagickConfiguration($config, $container); @@ -191,8 +188,11 @@ public function prepend(ContainerBuilder $container) $this->prependTranslatorConfiguration($container); $this->prependDoctrineConfiguration($container); - $this->configureGenericSetup($container); - $this->configurePlatformShSetup($container); + // Default settings + $this->handleDefaultSettingsLoading($container); + + (new ContainerConfigurator\Generic())->configure($container); + (new ContainerConfigurator\PlatformSh())->configure($container); } /** @@ -229,15 +229,14 @@ private function getMainRepositoryConfigParser(): RepositoryConfigParserInterfac } /** - * Handle default settings. - * - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader - * * @throws \Exception */ - private function handleDefaultSettingsLoading(ContainerBuilder $container, FileLoader $loader) + private function handleDefaultSettingsLoading(ContainerBuilder $container): void { + $loader = new Loader\YamlFileLoader( + $container, + new FileLocator(__DIR__ . '/../Resources/config') + ); $loader->load('default_settings.yml'); foreach ($this->defaultSettingsCollection as $fileLocation => $files) { @@ -714,289 +713,6 @@ private function registerForAutoConfiguration(ContainerBuilder $container): void ->addTag(ServiceTags::FILTERING_SORT_CLAUSE_QUERY_BUILDER); } - /** - * @throws \Exception - */ - private function configureGenericSetup(ContainerBuilder $container): void - { - // One of `legacy` (default) or `solr` - $container->setParameter('search_engine', '%env(SEARCH_ENGINE)%'); - - // Session save path as used by symfony session handlers (eg. used for dsn with redis) - $container->setParameter('ibexa.session.save_path', '%kernel.project_dir%/var/sessions/%kernel.environment%'); - - // Predefined pools are located in config/packages/cache_pool/ - // You can add your own cache pool to the folder mentioned above. - // In order to change the default cache_pool use environmental variable export. - // The line below must not be altered as required cache service files are resolved based on environmental config. - $container->setParameter('cache_pool', '%env(CACHE_POOL)%'); - - // By default cache ttl is set to 24h, when using Varnish you can set a much higher value. High values depends on - // using IbexaHttpCacheBundle (default as of v1.12) which by design expires affected cache on changes - $container->setParameter('httpcache_default_ttl', '%env(HTTPCACHE_DEFAULT_TTL)%'); - - // Settings for HttpCache - $container->setParameter('purge_server', '%env(HTTPCACHE_PURGE_SERVER)%'); - - // Identifier used to generate the CSRF token. Commenting this line will result in authentication - // issues both in AdminUI and REST calls - $container->setParameter('ibexa.rest.csrf_token_intention', 'authenticate'); - - // Varnish invalidation/purge token (for use on platform.sh, Ibexa Cloud and other places you can't use IP for ACL) - $container->setParameter('varnish_invalidate_token', '%env(resolve:default::HTTPCACHE_VARNISH_INVALIDATE_TOKEN)%'); - - // Compile time handlers - // These are defined at compile time, and hence can't be set at runtime using env() - // config/env/generic.php takes care about letting you set them by env variables - - // Session handler, by default set to file based (instead of ~) in order to be able to use %ibexa.session.save_path% - $container->setParameter('ibexa.session.handler_id', 'session.handler.native_file'); - - // Purge type used by HttpCache system ("local", "varnish"/"http", and on ee also "fastly") - $container->setParameter('purge_type', '%env(HTTPCACHE_PURGE_TYPE)%'); - - $container->setParameter('solr_dsn', '%env(SOLR_DSN)%'); - $container->setParameter('solr_core', '%env(SOLR_CORE)%'); - - $projectDir = $container->getParameter('kernel.project_dir'); - - if ($dfsNfsPath = $_SERVER['DFS_NFS_PATH'] ?? false) { - $container->setParameter('dfs_nfs_path', $dfsNfsPath); - - $parameterMap = [ - 'dfs_database_charset' => 'database_charset', - 'dfs_database_driver' => 'database_driver', - 'dfs_database_collation' => 'database_collation', - ]; - - foreach ($parameterMap as $dfsParameter => $platformParameter) { - $container->setParameter( - $dfsParameter, - $_SERVER[strtoupper($dfsParameter)] ?? $container->getParameter($platformParameter) - ); - } - - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/dfs')); - $loader->load('dfs.yaml'); - } - - // Cache settings - // If CACHE_POOL env variable is set, check if there is a yml file that needs to be loaded for it - if (($pool = $_SERVER['CACHE_POOL'] ?? false) && file_exists($projectDir . "/config/packages/cache_pool/${pool}.yaml")) { - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); - $loader->load($pool . '.yaml'); - } - - if ($purgeType = $_SERVER['HTTPCACHE_PURGE_TYPE'] ?? false) { - $container->setParameter('purge_type', $purgeType); - $container->setParameter('ibexa.http_cache.purge_type', $purgeType); - } - - if ($value = $_SERVER['MAILER_TRANSPORT'] ?? false) { - $container->setParameter('mailer_transport', $value); - } - - if ($value = $_SERVER['LOG_TYPE'] ?? false) { - $container->setParameter('log_type', $value); - } - - if ($value = $_SERVER['SESSION_HANDLER_ID'] ?? false) { - $container->setParameter('ibexa.session.handler_id', $value); - } - - if ($value = $_SERVER['SESSION_SAVE_PATH'] ?? false) { - $container->setParameter('ibexa.session.save_path', $value); - } - } - - /** - * @throws \Exception - */ - private function configurePlatformShSetup(ContainerBuilder $container): void - { - $projectDir = $container->getParameter('kernel.project_dir'); - - // Run for all hooks, incl build step - if ($_SERVER['PLATFORM_PROJECT_ENTROPY'] ?? false) { - // Disable PHPStormPass as we don't have write access & it's not localhost - $container->setParameter('ezdesign.phpstorm.enabled', false); - } - - // Will not be executed on build step - $relationships = $_SERVER['PLATFORM_RELATIONSHIPS'] ?? false; - if (!$relationships) { - return; - } - $routes = $_SERVER['PLATFORM_ROUTES']; - - $relationships = json_decode(base64_decode($relationships), true); - $routes = json_decode(base64_decode($routes), true); - - // PLATFORMSH_DFS_NFS_PATH is different compared to DFS_NFS_PATH in the sense that it is relative to ezplatform dir - // DFS_NFS_PATH is an absolute path - if ($dfsNfsPath = $_SERVER['PLATFORMSH_DFS_NFS_PATH'] ?? false) { - $container->setParameter('dfs_nfs_path', sprintf('%s/%s', $projectDir, $dfsNfsPath)); - - // Map common parameters - $container->setParameter('dfs_database_charset', $container->getParameter('database_charset')); - $container->setParameter( - 'dfs_database_collation', - $container->getParameter('database_collation') - ); - if (\array_key_exists('dfs_database', $relationships)) { - // process dedicated P.sh dedicated config - foreach ($relationships['dfs_database'] as $endpoint) { - if (empty($endpoint['query']['is_master'])) { - continue; - } - $container->setParameter('dfs_database_driver', 'pdo_' . $endpoint['scheme']); - $container->setParameter( - 'dfs_database_url', - sprintf( - '%s://%s:%s:%d@%s/%s', - $endpoint['scheme'], - $endpoint['username'], - $endpoint['password'], - $endpoint['port'], - $endpoint['host'], - $endpoint['path'] - ) - ); - } - } else { - // or set fallback from the Repository database, if not configured - $container->setParameter('dfs_database_driver', $container->getParameter('database_driver')); - } - - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/dfs')); - $loader->load('dfs.yaml'); - } - - // Use Redis-based caching if possible. - if (isset($relationships['rediscache'])) { - foreach ($relationships['rediscache'] as $endpoint) { - if ($endpoint['scheme'] !== 'redis') { - continue; - } - - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); - $loader->load('cache.redis.yaml'); - - $container->setParameter('cache_pool', 'cache.redis'); - $container->setParameter('cache_dsn', sprintf('%s:%d', $endpoint['host'], $endpoint['port']) . '?retry_interval=3'); - } - } elseif (isset($relationships['cache'])) { - // Fallback to memcached if here (deprecated, we will only handle redis here in the future) - foreach ($relationships['cache'] as $endpoint) { - if ($endpoint['scheme'] !== 'memcached') { - continue; - } - - @trigger_error('Usage of Memcached is deprecated, redis is recommended', E_USER_DEPRECATED); - - $container->setParameter('cache_pool', 'cache.memcached'); - $container->setParameter('cache_dsn', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); - - $loader = new Loader\YamlFileLoader($container, new FileLocator($projectDir . '/config/packages/cache_pool')); - $loader->load('cache.memcached.yaml'); - } - } - - // Use Redis-based sessions if possible. If a separate Redis instance - // is available, use that. If not, share a Redis instance with the - // Cache. (That should be safe to do except on especially high-traffic sites.) - if (isset($relationships['redissession'])) { - foreach ($relationships['redissession'] as $endpoint) { - if ($endpoint['scheme'] !== 'redis') { - continue; - } - - $container->setParameter('ibexa.session.handler_id', NativeSessionHandler::class); - $container->setParameter('ibexa.session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); - } - } elseif (isset($relationships['rediscache'])) { - foreach ($relationships['rediscache'] as $endpoint) { - if ($endpoint['scheme'] !== 'redis') { - continue; - } - - $container->setParameter('ibexa.session.handler_id', NativeSessionHandler::class); - $container->setParameter('ibexa.session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port'])); - } - } - - if (isset($relationships['solr'])) { - foreach ($relationships['solr'] as $endpoint) { - if ($endpoint['scheme'] !== 'solr') { - continue; - } - - $container->setParameter('search_engine', 'solr'); - - $container->setParameter('solr_dsn', sprintf('http://%s:%d/%s', $endpoint['host'], $endpoint['port'], 'solr')); - // To set solr_core parameter we assume path is in form like: "solr/collection1" - $container->setParameter('solr_core', substr($endpoint['path'], 5)); - } - } - - if (isset($relationships['elasticsearch'])) { - foreach ($relationships['elasticsearch'] as $endpoint) { - $dsn = sprintf('%s:%d', $endpoint['host'], $endpoint['port']); - - if ($endpoint['username'] !== null && $endpoint['password'] !== null) { - $dsn = $endpoint['username'] . ':' . $endpoint['password'] . '@' . $dsn; - } - - if ($endpoint['path'] !== null) { - $dsn .= '/' . $endpoint['path']; - } - - $dsn = $endpoint['scheme'] . '://' . $dsn; - - $container->setParameter('search_engine', 'elasticsearch'); - $container->setParameter('elasticsearch_dsn', $dsn); - } - } - - // We will pick a varnish route by the following prioritization: - // - The first route found that has upstream: varnish - // - if primary route has upstream: varnish, that route will be prioritised - // If no route is found with upstream: varnish, then purge_server will not be set - $route = null; - foreach ($routes as $host => $info) { - if ($route === null && $info['type'] === 'upstream' && $info['upstream'] === 'varnish') { - $route = $host; - } - if ($info['type'] === 'upstream' && $info['upstream'] === 'varnish' && $info['primary'] === true) { - $route = $host; - break; - } - } - - if ($route !== null && !($_SERVER['SKIP_HTTPCACHE_PURGE'] ?? false)) { - $purgeServer = rtrim($route, '/'); - if (($_SERVER['HTTPCACHE_USERNAME'] ?? false) && ($_SERVER['HTTPCACHE_PASSWORD'] ?? false)) { - $domain = parse_url($purgeServer, PHP_URL_HOST); - $credentials = urlencode($_SERVER['HTTPCACHE_USERNAME']) . ':' . urlencode($_SERVER['HTTPCACHE_PASSWORD']); - $purgeServer = str_replace($domain, $credentials . '@' . $domain, $purgeServer); - } - - $container->setParameter('ibexa.http_cache.purge_type', 'varnish'); - $container->setParameter('purge_type', 'varnish'); - $container->setParameter('purge_server', $purgeServer); - } - // Setting default value for HTTPCACHE_VARNISH_INVALIDATE_TOKEN if it is not explicitly set - if (!($_SERVER['HTTPCACHE_VARNISH_INVALIDATE_TOKEN'] ?? false)) { - $container->setParameter('varnish_invalidate_token', $_SERVER['PLATFORM_PROJECT_ENTROPY']); - } - - // Adapt config based on enabled PHP extensions - // Get imagine to use imagick if enabled, to avoid using php memory for image conversions - if (\extension_loaded('imagick')) { - $container->setParameter('liip_imagine_driver', 'imagick'); - } - } - private function shouldLoadTestBehatServices(ContainerBuilder $container): bool { return $container->hasParameter('ibexa.behat.browser.enabled') diff --git a/src/bundle/Core/Resources/config/default_settings.yml b/src/bundle/Core/Resources/config/default_settings.yml index cf1718dbe7..6cafe7051e 100644 --- a/src/bundle/Core/Resources/config/default_settings.yml +++ b/src/bundle/Core/Resources/config/default_settings.yml @@ -256,8 +256,11 @@ parameters: ## ibexa.orm.entity_mappings: [] + # fallback for existing project configuration, should be overridden + dfs_nfs_path: '%ibexa.io.dir.storage%' + ibexa.io.nfs.adapter.config: - root: './' + root: '%dfs_nfs_path%' path: '$var_dir$/$storage_dir$/' writeFlags: ~ linkHandling: ~ diff --git a/src/lib/Resources/settings/repository/siteaccessaware.yml b/src/lib/Resources/settings/repository/siteaccessaware.yml index 9cb226ffbf..6af570d83d 100644 --- a/src/lib/Resources/settings/repository/siteaccessaware.yml +++ b/src/lib/Resources/settings/repository/siteaccessaware.yml @@ -1,6 +1,7 @@ parameters: languages: [] - ibexa.io.dir.storage: var/ibexa_demo_site/storage + ibexa.io.dir.storage: var/site/storage + ibexa.io.dir.root: '%ibexa.io.dir.storage%' ibexa.legacy.url_prefix: var/ibexa_demo_site/storage ibexa.url_prefix: var/ibexa_demo_site/storage diff --git a/src/lib/Resources/settings/settings.yml b/src/lib/Resources/settings/settings.yml index 42cb0e00e5..d35de28cbb 100644 --- a/src/lib/Resources/settings/settings.yml +++ b/src/lib/Resources/settings/settings.yml @@ -1,13 +1,11 @@ parameters: - ibexa.persistence.legacy.dsn: sqlite://:memory: + ibexa.persistence.legacy.dsn: 'sqlite://:memory:' anonymous_user_id: 10 kernel.debug: false languages: [] ibexa.io.images.storage.prefix: images ibexa.io.images.storage.prefix.draft: images-versioned ibexa.io.binary_file.storage.prefix: original - ibexa.io.dir.storage: var/ibexa_demo_site/storage - ibexa.io.dir.root: '%ibexa.io.dir.storage%' ibexa.site_access.list: [test] ibexa.site_access.config.default.anonymous_user_id: 10