* @copyright 2007-2019 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ use PrestaShop\PrestaShop\Adapter\Configuration; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; class LegacyCompilerPass implements CompilerPassInterface { /** * Add legacy services that need to be built using Context::getContext(). * * @param ContainerBuilder $container */ public function process(ContainerBuilder $container) { $context = Context::getContext(); $this->buildSyntheticDefinitions([ 'configuration', 'context', 'db', 'shop', 'employee', ], $container); $container->set('context', $context); $container->set('configuration', new Configuration()); $container->set('db', Db::getInstance()); $container->set('shop', $context->shop); $container->set('employee', $context->employee); } private function buildSyntheticDefinitions(array $keys, ContainerBuilder $container) { foreach ($keys as $key) { $definition = new Definition(); $definition->setSynthetic(true); $container->setDefinition($key, $definition); } } }