On site context initialization.

@param SiteEvent $event
519333
public function onMenuTree(MenuEvent $event)
    {
        if (!$event->hasSite()) {
            return;
        }

        $deleted = [];
        $changed = [];

        foreach ($event->getDeletedItems() as $item) {
            $deleted[] = $item->getNodeId();
        }
        if ($deleted) {
            // @todo
            //  if node is not present on site, we should clean up the references
            //  except for some types such as news (list by type)
        }

        foreach ($event->getTree()->getAll() as $item) {
            $changed[] = $item->getNodeId();
        }
        if ($changed) {
            $this->nodeManager->createReferenceBulkInSite($event->getSite()->getId(), $changed);
        }
    }
691711
public function switchSiteContext($site_name) {
    $this->logger->debug("Switching site context to <comment>$site_name</comment>.");
    $config_initializer = new ConfigInitializer($this->getConfigValue('repo.root'), $this->input());
    $config_initializer->setSite($site_name);
    $new_config = $config_initializer->initialize();

    // Replaces config.
    $this->getConfig()->import($new_config->export());
  }
911700
protected function apply(DomainEvent $event): void {
        $eventName = explode('\\', get_class($event));

        $method = 'apply' . $eventName[count($eventName) - 1];

        if (method_exists($this, $method)) {
            $this->$method($event);
        }

        $this->version = $this->version->next();
    }
372215
public function preCreate(CreateEvent $event)
    {
        /** @var Group $role */
        $group = $event->getObject();
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof User) {
            $group->addOrganization($user->getMainOrganization());
        }
    }
772457
public static function listenToContextLoadFactoriesEvent(sfEvent $event)
    {
        /** @param sfContext $context */
        $context = $event->getSubject();

        if (sfContext::getInstance()->getConfiguration()->getEnvironment() == 'dev') {
            $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/bootstrap.css', 'first');
            $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/bootstrap-responsive.css');
            $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/smoothness/jquery-ui-1.10.1.custom.css');
        } else {
            $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/bootstrap.min.css', 'first');
            $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/bootstrap-responsive.min.css');
            $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/smoothness/jquery-ui-1.10.1.custom.min.css');
        }
        $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/jquery-ui-timepicker-addon.css');

        $context->getResponse()->addStylesheet(twAdmin::getProperty('web_dir') . '/css/twadmin.css', 'last');

        if (sfContext::getInstance()->getConfiguration()->getEnvironment() == 'dev') {
            $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/jquery-1.9.1.js');
            $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/bootstrap.js');
            $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/jquery-ui-1.10.1.custom.js');
        } else {
            $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/jquery-1.9.1.min.js');
            $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/bootstrap.min.js');
            $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/jquery-ui-1.10.1.custom.min.js');
        }
        $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/jquery-ui-timepicker-addon.js');
        $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/jquery-ui-datepicker-pl.js');

        $context->getResponse()->addJavascript(twAdmin::getProperty('web_dir') . '/js/twadmin.js', 'last');
    }
1191229
public function handle(DomainEvent $event) : void {
        $this->projections->each(function (Projection $projection) use ($event) {
            $projection->handle($event);
        });
    }
1338879
public function onInitDescription($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if (!is_string($sender->descriptionAttribute) || empty($sender->descriptionAttribute)) {
            return;
        }
        $descriptionAttribute = $sender->descriptionAttribute;
        if (empty($sender->$descriptionAttribute)) {
            $sender->$descriptionAttribute = $sender->initDescription;
        }
    }
1080875
public function onAfterRespond(Event $event)
    {
        /** @var ResponseInterface $response */
        $response = $event['response'];

        if (strpos($response->getHeaderLine('Content-Type'), 'html') === false) {
            DebuggerHelper::disableConsole();
        }
    }
713573
final protected function raise(DomainEvent $event) : void
    {
        $this->setStateHash($this->calculateNextStateHash($event));
        if ($event instanceof AbstractDomainEvent) {
            AbstractDomainEvent::initEvent($event, $this->getId(), $this->stateHash());
        }
        EventPublisher::instance()->post($event);
    }
440551
@Override
  public void contextInitialized(ServletContextEvent servletContextEvent) {
    otherListeners.addAll(getDefaultOtherListeners());

    contextInitialized(servletContextEvent.getServletContext());

    for(ServletContextListener listener : otherListeners) {
      try {
        listener.contextInitialized(servletContextEvent);
      }
      catch(Exception e){
        classLoaderLeakPreventor.error(e);
      }
    }
  }
903812
public function onSiteWebmasterCreate(SiteEvent $event)
    {
        /* @var UserInterface $user */
        $user = $this->entityManager->getStorage('user')->load($event->getArgument('webmaster_id'));

        if ($user->status == 0) {
            $this->tokenManager->sendTokenMail($user, 'ucms_user', 'new-account-disabled');
        } else {
            $this->tokenManager->sendTokenMail($user, 'ucms_user', 'new-account-enabled');
        }
    }
249596
public function initializeContext(Context $context)
    {
        if (!$context instanceof FixtureServiceAwareContextInterface && !$this->usesReferenceDictionary($context)) {
            return;
        }

        $context->setFixtureService($this->fixtureService);
    }
435861
public function activateSiteAction(Site $site)
    {
        $site->setState($site::STATE_ONLINE);
        $this->siteRepository->update($site);
        $this->addFlashMessage('The site "%s" has been activated.', 'Site activated', Message::SEVERITY_OK, [htmlspecialchars($site->getName())], 1412372881);
        $this->unsetLastVisitedNodeAndRedirect('index');
    }
1224675
public function onNodePrepare(NodeEvent $event)
    {
        $node = $event->getNode();

        if (!empty($node->group_id)) {
            return; // Someone took care of this for us
        }

        $node->group_id = $this->findMostRelevantGroupId();
        $node->is_ghost = (int)$this->findMostRelevantGhostValue($node);
    }
1022930
public function init()
    {
        $event = new ContextPaneEvent($this);

        $this->dispatcher->dispatch(ContextPaneEvent::EVENT_INIT, $event);
    }
357127
public function beforeFilter($event)
    {
        $this->setController($event->subject());

        if (method_exists($this->Controller, 'initMenuItems')) {
            $this->Controller->initMenuItems($event);
        }
    }
1360413
public function deleteDoctrineCache(SiteEvent $event)
    {
        if ($cacheImpl = $this->em->getConfiguration()->getResultCacheImpl()) {
            $cacheImpl->delete(SiteInterface::SITE);
        }
    }