/** * Share any non-Silex objects around the application (the string is shared) */ public function shareObjects() { $injector = $this->aurex->getInjector(); $config = $this->aurex->getConfiguration(self::CONFIG_KEY); if (isset($config['share'])) { foreach ($config['share'] as $shareable) { $injector->share($shareable); } } }
/** * {@inheritDoc} */ public function integrate(Aurex $aurex) { $config = $aurex->getConfiguration(self::CONFIG_KEY); $aurex->register(new DoctrineServiceProvider(), ['db.options' => $config]); $configType = 'annotation'; $entityDirectory = __DIR__ . '/../../../Application/Model/Entity'; $entityNamespace = 'Aurex\\Application\\Model\\Entity'; $cacheObject = !$aurex['debug'] && extension_loaded('apc') ? new ApcCache() : new ArrayCache(); $cacheDirectory = __DIR__ . '/../../../Application/Cache/Doctrine'; $cacheNamespace = 'Aurex\\Application\\Cache\\Doctrine'; $mappings = ['mappings' => [['type' => $configType, 'path' => $entityDirectory, 'namespace' => $entityNamespace]]]; $aurex->register(new DoctrineOrmServiceProvider(), ['orm.proxies_dir' => $cacheDirectory, 'orm.proxies_namespace' => $cacheNamespace, 'orm.cache' => $cacheObject, 'orm.auto_generate_proxies' => true, 'orm.em.options' => $mappings]); /** @var Connection $orm */ $orm = $aurex['orm.em']; /** @var Configuration $ormConfig */ $ormConfig = $orm->getConfiguration(); $ormConfig->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [$entityDirectory])); $aurex->getInjector()->share($aurex['orm.em']); $aurex->getInjector()->share($aurex['db']); }
/** * {@inheritDoc} */ public function integrate(Aurex $aurex) { $aurex->register(new FormServiceProvider()); $aurex->register(new SessionServiceProvider()); $aurex->register(new TranslationServiceProvider(), ['locale' => 'en']); $aurex['form.extensions'] = $aurex->extend('form.extensions', function ($extensions, $app) { $managerRegistry = new FormManagerRegistry(null, [], ['default'], null, null, '\\Doctrine\\ORM\\Proxy\\Proxy'); $managerRegistry->setContainer($app); unset($extensions); return [new DoctrineOrmExtension($managerRegistry)]; }); $aurex->getInjector()->share($aurex['form.factory']); }
/** * Load the module * * @param Aurex $aurex * @param string $moduleName Either the module name if from the default namespace or fully qualified module * * @throws ModuleNotFoundException * @throws ModuleConfigurationNotFoundException * * @return void */ public function load(Aurex $aurex, $moduleName) { $defaultModulePath = sprintf('%s\\%s\\%s', self::DEFAULT_NAMESPACE, $moduleName, $moduleName); /** Check for default modules or user provided ones **/ if (!class_exists($defaultModulePath) && !class_exists($moduleName)) { throw new ModuleNotFoundException(sprintf('Unable to load module: %s - it does not exist', $moduleName)); } /** @var ModuleInterface $module */ $module = class_exists($moduleName) ? $aurex->getInjector()->make($moduleName) : new $defaultModulePath(); if (!$module instanceof ModuleInterface) { throw new ModuleNotFoundException(sprintf('Module: %s does not implement ModuleInterface', $moduleName)); } $configuration = $aurex->getConfiguration(); $configurationKey = $module->usesConfigurationKey(); if ($configurationKey !== null && (strlen($configurationKey) > 0 && !array_key_exists($configurationKey, $configuration))) { throw new ModuleConfigurationNotFoundException(sprintf('Module: %s requires configuration key: %s', $moduleName, $configurationKey)); } /** Perform the module's individual logic **/ $module->integrate($aurex); /** Store a list of which modules have been loaded **/ $aurex->addLoadedModule($module); }