Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

SchemaBuilderInstallerPass.php
Go to the documentation of this file.
1 <?php
2
7 declare(strict_types=1);
8
9 namespace EzSystems\PlatformInstallerBundle\DependencyInjection\Compiler;
10
11 use EzSystems\DoctrineSchema\API\Builder\SchemaBuilder;
12 use EzSystems\PlatformInstallerBundle\Installer\CoreInstaller;
13 use EzSystems\PlatformInstallerBundle\Installer\DbBasedInstaller;
14 use Symfony\Component\DependencyInjection\ChildDefinition;
15 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Definition;
18
27 class SchemaBuilderInstallerPass implements CompilerPassInterface
28 {
29 const CLEAN_INSTALLER_DEF_ID = 'ezplatform.installer.clean_installer';
30 const DB_BASED_INSTALLER_DEF_ID = 'ezplatform.installer.db_based_installer';
31
39 public function process(ContainerBuilder $container)
40 {
41 if (!$container->hasAlias(SchemaBuilder::class)) {
42 $container->removeDefinition(CoreInstaller::class);
43 @trigger_error(
44 sprintf(
45 'Using eZ Platform Installer Bundle without enabling Doctrine Schema Bundle (%s) ' .
46 'is deprecated since v2.5 LTS and will cause a fatal error in eZ Platform v3.0',
47 'https://github.com/ezsystems/doctrine-dbal-schema'
48 ),
49 E_USER_DEPRECATED
50 );
51 } elseif ($container->hasDefinition(self::CLEAN_INSTALLER_DEF_ID)) {
52 // remove the actual definition first for alias to work properly
53 $container->removeDefinition(self::CLEAN_INSTALLER_DEF_ID);
54 $container->setAlias(self::CLEAN_INSTALLER_DEF_ID, CoreInstaller::class);
55 }
56
57 $this->warnAboutRelyingOnDeprecatedService(
58 $container,
59 [
60 self::DB_BASED_INSTALLER_DEF_ID => DbBasedInstaller::class,
61 self::CLEAN_INSTALLER_DEF_ID => CoreInstaller::class,
62 ]
63 );
64 }
65
76 private function warnAboutRelyingOnDeprecatedService(
77 ContainerBuilder $container,
78 array $oldNewNameMap
79 ): void {
80 // find usages of deprecated definitions as parents
82 $deprecatedParentDefinitions = array_filter(
83 $container->getDefinitions(),
84 function (Definition $definition) use ($oldNewNameMap) {
85 return $definition instanceof ChildDefinition
86 && array_key_exists($definition->getParent(), $oldNewNameMap);
87 }
88 );
89 // trigger deprecation warnings to be logged
90 foreach ($deprecatedParentDefinitions as $id => $definition) {
91 $parent = $definition->getParent();
92 @trigger_error(
93 sprintf(
94 'The service definition "%s" relies on the deprecated "%s" service. Use "%s" instead',
95 $id,
96 $parent,
97 $oldNewNameMap[$parent]
98 ),
99 E_USER_DEPRECATED
100 );
101 }
102 }
103 }
EzSystems\PlatformInstallerBundle\DependencyInjection\Compiler\SchemaBuilderInstallerPass
Enable installer which uses SchemaBuilder.
Definition: SchemaBuilderInstallerPass.php:28
EzSystems\PlatformInstallerBundle\DependencyInjection\Compiler\SchemaBuilderInstallerPass\DB_BASED_INSTALLER_DEF_ID
const DB_BASED_INSTALLER_DEF_ID
Definition: SchemaBuilderInstallerPass.php:30
EzSystems\PlatformInstallerBundle\DependencyInjection\Compiler\SchemaBuilderInstallerPass\CLEAN_INSTALLER_DEF_ID
const CLEAN_INSTALLER_DEF_ID
Definition: SchemaBuilderInstallerPass.php:29
EzSystems\PlatformInstallerBundle\DependencyInjection\Compiler\SchemaBuilderInstallerPass\process
process(ContainerBuilder $container)
Replace Clean installer with CoreInstaller if required SchemaBuilder from DoctrineSchemaBundle is ava...
Definition: SchemaBuilderInstallerPass.php:39
EzSystems\PlatformInstallerBundle\Installer\CoreInstaller
New variant of CleanInstaller, which uses SchemaBuilder.
Definition: CoreInstaller.php:22
EzSystems\PlatformInstallerBundle\Installer\DbBasedInstaller
Definition: DbBasedInstaller.php:14
EzSystems\PlatformInstallerBundle\DependencyInjection\Compiler
Definition: InstallerTagPass.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.