예제 #1
0
 /**
  * Adds settings to the parameters that will be injected into the legacy kernel
  *
  * @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
  *
  * @todo Cache computed settings somehow
  */
 public function onBuildKernel(PreBuildKernelEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     if (!isset($this->options['extensions'])) {
         return;
     }
     $settings = array("site.ini/ExtensionSettings/ActiveExtensions" => $this->options['extensions']);
     $event->getParameters()->set("injected-merge-settings", $settings + (array) $event->getParameters()->get("injected-merge-settings"));
 }
    /**
     * Adds settings to the parameters that will be injected into the legacy kernel
     *
     * @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
     */
    public function onBuildKernel( PreBuildKernelEvent $event )
    {
        if( !$this->enabled )
        {
            return;
        }

        $settings = array();
        $settings["owpagenda.ini/AgendaSettings/FolderNodeId"] = $this->configResolver->getParameter( "open_wide_publish_agenda.agenda_folder.location_id" );
        $event->getParameters()->set(
                "injected-settings", $settings + (array) $event->getParameters()->get( "injected-settings" )
        );
    }
 /**
  * Adds settings to the parameters that will be injected into the legacy kernel
  *
  * @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
  */
 public function onBuildKernel(PreBuildKernelEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     $databaseSettings = $this->legacyDbHandler->getConnection()->getParams();
     $settings = array();
     foreach (array("host" => "Server", "port" => "Port", "user" => "User", "password" => "Password", "dbname" => "Database", "unix_socket" => "Socket", "driver" => "DatabaseImplementation") as $key => $iniKey) {
         if (isset($databaseSettings[$key])) {
             $iniValue = $databaseSettings[$key];
             switch ($key) {
                 case "driver":
                     $driverMap = array('pdo_mysql' => 'ezmysqli', 'pdo_pgsql' => 'ezpostgresql', 'oci8' => 'ezoracle');
                     if (!isset($driverMap[$iniValue])) {
                         throw new RuntimeException("Could not map database driver to Legacy Stack database implementation.\n" . "Expected one of '" . implode("', '", array_keys($driverMap)) . "', got '" . $iniValue . "'.");
                     }
                     $iniValue = $driverMap[$iniValue];
                     break;
             }
             $settings["site.ini/DatabaseSettings/{$iniKey}"] = $iniValue;
         } else {
             switch ($key) {
                 case "unix_socket":
                     $settings["site.ini/DatabaseSettings/{$iniKey}"] = "disabled";
                     break;
             }
         }
     }
     // Image settings
     $settings += $this->getImageSettings();
     // File settings
     $settings += array('site.ini/FileSettings/VarDir' => $this->configResolver->getParameter('var_dir'), 'site.ini/FileSettings/StorageDir' => $this->configResolver->getParameter('storage_dir'));
     // Multisite settings (PathPrefix and co)
     $settings += $this->getMultiSiteSettings();
     // User settings
     $settings["site.ini/UserSettings/AnonymousUserID"] = $this->configResolver->getParameter("anonymous_user_id");
     $event->getParameters()->set("injected-settings", $settings + (array) $event->getParameters()->get("injected-settings"));
     if (class_exists('ezxFormToken')) {
         // Inject csrf protection settings to make sure legacy & symfony stack work together
         if ($this->container->hasParameter('form.type_extension.csrf.enabled') && $this->container->getParameter('form.type_extension.csrf.enabled')) {
             ezxFormToken::setSecret($this->container->getParameter('kernel.secret'));
             ezxFormToken::setFormField($this->container->getParameter('form.type_extension.csrf.field_name'));
         } else {
             ezxFormToken::setIsEnabled(false);
         }
     }
     // Register http cache content/cache event listener
     ezpEvent::getInstance()->attach('content/cache', array($this->gatewayCachePurger, 'purge'));
     ezpEvent::getInstance()->attach('content/cache/all', array($this->gatewayCachePurger, 'purgeAll'));
     // Register persistence cache event listeners
     ezpEvent::getInstance()->attach('content/cache', array($this->persistenceCachePurger, 'content'));
     ezpEvent::getInstance()->attach('content/cache/all', array($this->persistenceCachePurger, 'all'));
     ezpEvent::getInstance()->attach('content/class/cache/all', array($this->persistenceCachePurger, 'contentType'));
     ezpEvent::getInstance()->attach('content/class/cache', array($this->persistenceCachePurger, 'contentType'));
     ezpEvent::getInstance()->attach('content/class/group/cache', array($this->persistenceCachePurger, 'contentTypeGroup'));
     ezpEvent::getInstance()->attach('content/section/cache', array($this->persistenceCachePurger, 'section'));
     ezpEvent::getInstance()->attach('user/cache/all', array($this->persistenceCachePurger, 'user'));
     ezpEvent::getInstance()->attach('content/translations/cache', array($this->persistenceCachePurger, 'languages'));
 }
예제 #4
0
 /**
  * Adds the session settings to the parameters that will be injected
  * into the legacy kernel
  *
  * @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
  */
 public function onBuildKernelHandler(PreBuildKernelEvent $event)
 {
     $sessionInfos = array('configured' => false, 'started' => false, 'name' => false, 'namespace' => false, 'has_previous' => false, 'storage' => false);
     if (isset($this->session)) {
         $sessionInfos['configured'] = true;
         $sessionInfos['name'] = $this->session->getName();
         $sessionInfos['started'] = $this->session->isStarted();
         $sessionInfos['namespace'] = $this->sessionStorageKey;
         $sessionInfos['has_previous'] = isset($this->request) ? $this->request->hasPreviousSession() : false;
         $sessionInfos['storage'] = $this->sessionStorage;
     }
     $legacyKernelParameters = $event->getParameters();
     $legacyKernelParameters->set('session', $sessionInfos);
     // Deactivate session cookie settings in legacy kernel.
     // This will force using settings defined in Symfony.
     $sessionSettings = array('site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false);
     $legacyKernelParameters->set("injected-settings", $sessionSettings + (array) $legacyKernelParameters->get("injected-settings"));
 }
 public function testConstruct()
 {
     $parameterBag = new ParameterBag();
     $event = new PreBuildKernelEvent($parameterBag);
     $this->assertSame($parameterBag, $event->getParameters());
 }
 public function onBuildKernel(PreBuildKernelEvent $e)
 {
     $settings = ['site.ini/InformationCollectionSettings/EmailReceiver' => $this->contactEmail, 'site.ini/TemplateSettings/DevelopmentMode' => $this->debug ? 'enabled' : 'disabled', 'site.ini/TemplateSettings/ShowUsedTemplates' => $this->debug ? 'enabled' : 'disabled', 'site.ini/SiteSettings/GMapsKey' => $this->configResolver->getParameter('gmaps_key', 'metalfrance'), 'solr.ini/SolrBase/SearchServerURI' => $this->solrUrl];
     $e->getParameters()->set("injected-settings", $settings + (array) $e->getParameters()->get("injected-settings"));
 }
예제 #7
0
 /**
  * Adds settings to the parameters that will be injected into the legacy kernel.
  *
  * @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
  */
 public function onBuildKernel(PreBuildKernelEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     $databaseSettings = $this->legacyDbHandler->getConnection()->getParams();
     $settings = array();
     foreach (array('host' => 'Server', 'port' => 'Port', 'user' => 'User', 'password' => 'Password', 'dbname' => 'Database', 'unix_socket' => 'Socket', 'driver' => 'DatabaseImplementation') as $key => $iniKey) {
         if (isset($databaseSettings[$key])) {
             $iniValue = $databaseSettings[$key];
             switch ($key) {
                 case 'driver':
                     $driverMap = array('pdo_mysql' => 'ezmysqli', 'pdo_pgsql' => 'ezpostgresql', 'oci8' => 'ezoracle');
                     if (!isset($driverMap[$iniValue])) {
                         throw new RuntimeException("Could not map database driver to Legacy Stack database implementation.\n" . "Expected one of '" . implode("', '", array_keys($driverMap)) . "', got '" . $iniValue . "'.");
                     }
                     $iniValue = $driverMap[$iniValue];
                     break;
             }
             $settings["site.ini/DatabaseSettings/{$iniKey}"] = $iniValue;
         } else {
             switch ($key) {
                 case 'unix_socket':
                     $settings["site.ini/DatabaseSettings/{$iniKey}"] = 'disabled';
                     break;
             }
         }
     }
     // Image settings
     $settings += $this->getImageSettings();
     // File settings
     $settings += array('site.ini/FileSettings/VarDir' => $this->configResolver->getParameter('var_dir'), 'site.ini/FileSettings/StorageDir' => $this->configResolver->getParameter('storage_dir'));
     // Multisite settings (PathPrefix and co)
     $settings += $this->getMultiSiteSettings();
     // User settings
     $settings['site.ini/UserSettings/AnonymousUserID'] = $this->configResolver->getParameter('anonymous_user_id');
     // Cache settings
     // Enforce ViewCaching to be enabled in order to persistence/http cache to be purged correctly.
     $settings['site.ini/ContentSettings/ViewCaching'] = 'enabled';
     $event->getParameters()->set('injected-settings', $settings + (array) $event->getParameters()->get('injected-settings'));
     if (class_exists('ezxFormToken')) {
         // Inject csrf protection settings to make sure legacy & symfony stack work together
         if ($this->container->hasParameter('form.type_extension.csrf.enabled') && $this->container->getParameter('form.type_extension.csrf.enabled')) {
             ezxFormToken::setSecret($this->container->getParameter('kernel.secret'));
             ezxFormToken::setFormField($this->container->getParameter('form.type_extension.csrf.field_name'));
         } else {
             ezxFormToken::setIsEnabled(false);
         }
     }
     // Register http cache content/cache event listener
     $ezpEvent = ezpEvent::getInstance();
     $ezpEvent->attach('content/cache', array($this->gatewayCachePurger, 'purge'));
     $ezpEvent->attach('content/cache/all', array($this->gatewayCachePurger, 'purgeAll'));
     // Register persistence cache event listeners
     $ezpEvent->attach('content/cache', array($this->persistenceCachePurger, 'content'));
     $ezpEvent->attach('content/cache/all', array($this->persistenceCachePurger, 'all'));
     $ezpEvent->attach('content/cache/version', array($this->persistenceCachePurger, 'contentVersion'));
     $ezpEvent->attach('content/class/cache/all', array($this->persistenceCachePurger, 'contentType'));
     $ezpEvent->attach('content/class/cache', array($this->persistenceCachePurger, 'contentType'));
     $ezpEvent->attach('content/class/group/cache', array($this->persistenceCachePurger, 'contentTypeGroup'));
     $ezpEvent->attach('content/section/cache', array($this->persistenceCachePurger, 'section'));
     $ezpEvent->attach('user/cache/all', array($this->persistenceCachePurger, 'user'));
     $ezpEvent->attach('content/translations/cache', array($this->persistenceCachePurger, 'languages'));
     // Register image alias removal listeners
     $ezpEvent->attach('image/removeAliases', array($this->aliasCleaner, 'removeAliases'));
     $ezpEvent->attach('image/trashAliases', array($this->aliasCleaner, 'removeAliases'));
     $ezpEvent->attach('image/purgeAliases', array($this->aliasCleaner, 'removeAliases'));
 }
 /**
  * Adds settings to the parameters that will be injected into the legacy kernel
  *
  * @param PreBuildKernelEvent $event
  */
 public function onBuildKernel(PreBuildKernelEvent $event)
 {
     $settings['novaseo.ini/Settings/Metas'] = $this->configResolver->getParameter('fieldtype_metas', 'novae_zseo');
     $event->getParameters()->set("injected-settings", $settings + (array) $event->getParameters()->get("injected-settings"));
 }