/** * @inheritdoc */ public function start() { parent::start(); // Register "location-search" form. $filename = $this->config('location-search-form.filename'); $this->getEngine()->forms()->registry()->registerFormDefinitionFilePath($this->config('location-search-form.key'), $this, $filename); }
/** * @inheritdoc */ public function start() { parent::start(); // Register the checkout form generator. $this->getEngine()->forms()->registry()->registerFormGeneratorCallback($this->config('checkout.form-key'), array($this, 'buildCheckoutForm')); // Create the trolley object. $this->trolley = new Trolley($this, $this->config('page-messages')); }
/** * @inheritdoc */ public function start() { parent::start(); // Create RealCaptcha object for use during this request. $this->captcha = new RealCaptcha($this->config('real-captcha-options')); // Register the namespace for the RealCaptcha field. $this->getEngine()->forms()->registry()->registerFieldNamespace('\\Sitegear\\Module\\RealCaptcha\\Form'); }
/** * @inheritdoc */ public function start() { parent::start(); // The transport name cannot be converted due to old-school class names in SwiftMailer with underscores $transportName = $this->config('transport'); $transportClass = new \ReflectionClass($transportName); /** @noinspection PhpParamsInspection The null gives a warning phpStorm 5.0.4 but is valid */ $transport = $transportClass->getMethod('newInstance')->invokeArgs(null, $this->config('transportArguments', array())); $this->mailer = \Swift_Mailer::newInstance($transport); }
/** * @inheritdoc */ public function start() { parent::start(); // Register constraint namespace. $this->getEngine()->forms()->registry()->registerConstraintNamespace('\\Sitegear\\Module\\UserIntegration\\Constraint'); // Register login form. $filename = $this->config('login.form.filename'); $this->getEngine()->forms()->registry()->registerFormDefinitionFilePath($this->config('login.form.key'), $this, $filename); // Register sign-up form. $filename = $this->config('sign-up.form.filename'); $this->getEngine()->forms()->registry()->registerFormDefinitionFilePath($this->config('sign-up.form.key'), $this, $filename); // Register guest-login form. $filename = $this->config('guest-login.form.filename'); $this->getEngine()->forms()->registry()->registerFormDefinitionFilePath($this->config('guest-login.form.key'), $this, $filename); // Register credentials recovery form. $filename = $this->config('recover-login.form.filename'); $this->getEngine()->forms()->registry()->registerFormDefinitionFilePath($this->config('recover-login.form.key'), $this, $filename); }
/** * @inheritdoc */ public function start() { parent::start(); $connectionConfig = $this->config('connection'); if (!empty($connectionConfig) && is_array($connectionConfig)) { // Setup Doctrine. Largely borrowed from // https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/annotations.md#em-setup // Register Doctrine default annotations. AnnotationRegistry::registerFile($this->getEngine()->getSiteInfo()->getSiteRoot() . '/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); // Setup annotation metadata cache if ($this->getEngine()->getEnvironmentInfo()->isDevMode() || !$this->getEngine()->config('memcache.enabled')) { $cache = new ArrayCache(); } else { $cache = new MemcacheCache(); $cache->setMemcache($this->getEngine()->getMemcache()); } // Setup annotation metadata reader and driver /** @var AnnotationReader $cachedAnnotationReader (for all intents and purposes...) */ $cachedAnnotationReader = new CachedReader(new AnnotationReader(), $cache); $this->driverChain = new MappingDriverChain(); $this->annotationDriver = new AnnotationDriver($cachedAnnotationReader, array($this->getEngine()->getApplicationInfo()->getSitegearRoot())); // Setup Gedmo extension annotations \Gedmo\DoctrineExtensions::registerAnnotations(); $this->driverChain->addDriver($this->annotationDriver, 'Gedmo'); // Setup Sitegear extension annotations // TODO Make model-providing modules declare their own namespaces $this->driverChain->addDriver($this->annotationDriver, 'Sitegear\\Module\\Customer\\Model'); $this->driverChain->addDriver($this->annotationDriver, 'Sitegear\\Module\\News\\Model'); $this->driverChain->addDriver($this->annotationDriver, 'Sitegear\\Module\\Locations\\Model'); $this->driverChain->addDriver($this->annotationDriver, 'Sitegear\\Module\\Products\\Model'); // Create the entity manager configuration, with proxy generation, cached metadata and lowercase-underscore // database naming convention. $entityManagerConfig = new Configuration(); // TODO Make this a temp directory set in the engine config $entityManagerConfig->setProxyDir(sys_get_temp_dir()); // TODO Configurable namespace and naming strategy $entityManagerConfig->setProxyNamespace('Proxy'); $entityManagerConfig->setAutoGenerateProxyClasses($this->getEngine()->getEnvironmentInfo()->isDevMode()); $entityManagerConfig->setMetadataDriverImpl($this->driverChain); $entityManagerConfig->setMetadataCacheImpl($cache); $entityManagerConfig->setQueryCacheImpl($cache); $entityManagerConfig->setNamingStrategy(new UnderscoreNamingStrategy(CASE_LOWER)); // Setup event subscribers. $eventManager = new EventManager(); foreach ($this->config('orm.subscribers') as $subscriberConfig) { /** @var \Doctrine\Common\EventSubscriber $subscriber */ $subscriber = TypeUtilities::buildTypeCheckedObject($subscriberConfig['class'], 'event subscriber', null, array('\\Doctrine\\Common\\EventSubscriber'), isset($subscriberConfig['arguments']) ? $subscriberConfig['arguments'] : array()); if ($subscriber instanceof MappedEventSubscriber) { /** @var MappedEventSubscriber $subscriber */ $subscriber->setAnnotationReader($cachedAnnotationReader); } $eventManager->addEventSubscriber($subscriber); } // Create the entity manager using the configured connection parameters. $this->entityManager = EntityManager::create($this->config('connection'), $entityManagerConfig, $eventManager); // Register the JSON custom data type. This has to be done last, when the entity manager has a connection. foreach ($this->config('dbal.types') as $key => $className) { Type::addType($key, $className); $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping(preg_replace('/^.*\\\\(.*?)$/', '$1', $className), $key); } } else { throw new \DomainException('<h1>Incorrect or Missing Configuration</h1><p>You have attempted to use the Doctrine module in your site, but you have not provided all the required connection parameters in your configuration file.</p><p>Please rectify this by providing connection parameters ("driver", "dbname", plus normally "username" and "password") or disabling the Doctrine module.</p>'); } }
/** * @inheritdoc */ public function start() { parent::start(); $this->registry = new FormRegistry($this, $this->config('form-builder'), $this->config('field-namespaces', array()), $this->config('constraint-namespaces', array()), $this->config('condition-namespaces', array())); }
/** * @inheritdoc */ public function start() { parent::start(); $this->messages = $this->getEngine()->getSession()->get($this->config('session-key')); }