Set a widget detail when needed.

@param WidgetDetailEvent $event
435401
public function onWidgetDetailGenerate(WidgetDetailEvent $event)
    {
        // This always pulls from cached data from the cron task.
        $cache  = $this->healthModel->getCache();
        $widget = $event->getWidget();
        if ($widget->getHeight() < 330) {
            $widget->setHeight(330);
        }
        $params             = $widget->getParams();
        $data               = [];
        $data['params']     = $params;
        $data['height']     = $widget->getHeight();
        $data['delays']     = isset($cache['delays']) ? $cache['delays'] : [];
        $data['lastCached'] = isset($cache['lastCached']) ? $cache['lastCached'] : null;
        $event->setTemplateData(['data' => $data]);

        if ('campaign.health' == $event->getType()) {
            $event->setTemplate('MauticHealthBundle:Widgets:health.html.php');
            $event->stopPropagation();
        }
    }
826789
public function onPreContentView(PreContentViewEvent $event): void
    {
        $currentRequest = $this->requestStack->getCurrentRequest();
        if (!$currentRequest instanceof Request) {
            return;
        }

        $view = $currentRequest->attributes->get('view');
        if (!$view instanceof ContentValueView) {
            return;
        }

        if ($currentRequest->attributes->get('viewType') !== 'full') {
            return;
        }

        $content = $view->getSiteContent();
        if (!$content->hasField('css_class') || $content->getField('css_class')->isEmpty()) {
            return;
        }

        $fieldValue = $content->getField('css_class')->value;
        if (!$fieldValue instanceof TextLineValue) {
            return;
        }

        $event->getContentView()->addParameters(
            [
                'page_css_class' => trim($fieldValue->text),
            ]
        );
    }
845048
public function beforeRender(Event $event)
    {
        if (!Configure::read('debug')) {
            return;
        }

        $this->_action()->setConfig('serialize.queryLog', 'queryLog');
        $this->_controller()->set('queryLog', $this->_getQueryLogs());
    }
570929
public function beforeDispatch(Event $event)
    {
        $request = $event->getData('request');
        $response = $event->getData('response');
        $event->setData('controller', $this->_getController($request, $response));
    }
578816
public void fire(EventDefinition eventDefinition, Event eventDetails) {
        if (eventDefinition.getType() == EventDefinition.TYPE_POST) {
            fire(listenersPost, eventDefinition, eventDetails);
        } else {
            fire(listeners, eventDefinition, eventDetails);
        }
    }
1152066
public static function onBeforeSave(Event $event)
    {
        $layout = $event->getTarget();
        if (!is_a($layout, 'BackBee\Site\Layout')) {
            return;
        }

        $dispatcher = $event->getDispatcher();
        if (null !== $dispatcher->getApplication()) {
            if (is_a($event->getEventArgs(), 'Doctrine\ORM\Event\PreUpdateEventArgs')) {
                if (!$event->getEventArgs()->hasChangedField('_data')) {
                    return;
                }
            }

            // Update the layout thumbnail - Beware of generate thumbnail before any other operation
            $thumb = $dispatcher->getApplication()->getEntityManager()
                    ->getRepository('BackBee\Site\Layout')
                    ->generateThumbnail($layout, $dispatcher->getApplication());

            // Update the layout file
            try {
                $dispatcher->getApplication()->getRenderer()->updateLayout($layout);
            } catch (\BackBee\Renderer\Exception\RendererException $e) {
                $dispatcher->getApplication()->warning($e->getMessage());
            }

            if (is_a($event->getEventArgs(), 'Doctrine\ORM\Event\PreUpdateEventArgs')) {
                if ($event->getEventArgs()->hasChangedField('_picpath')) {
                    $event->getEventArgs()->setNewValue('_picpath', $thumb);
                }
            }
        }
    }
1343440
public void setDetail(String name, Object value) {
        if (value == null) {
            details.remove(name);
        } else {
            details.put(name, value);
        }
        
        if (log.isDebugEnabled()) {
            if (value == null) {
                log.debug("Detail removed: " + name);
            } else {
                log.debug("Detail added: " + name + " = " + value);
            }
        }
    }
612673
def setCheckedDetails(self, checked):
        
        layout = self.layout()
        for i in range(layout.count()):
            w = layout.itemAt(i).widget()
            if w.stimType in checked:
                w.setChecked(checked[w.stimType])
582472
public function handle(DecodePropertyValueForWidgetEvent $event)
    {
        $isAllowed = $this->isAllowedContext(
            $event->getEnvironment()->getDataDefinition(),
            $event->getProperty(),
            $event->getModel()
        );

        if (!$isAllowed) {
            return;
        }

        $model     = $event->getModel();
        $metaModel = $this->getMetaModel($model);
        $value     = $event->getValue();

        if (!($metaModel && $value)) {
            return;
        }

        $attribute = $metaModel->getAttributeById($value);
        if ($attribute) {
            $event->setValue($metaModel->getTableName().'_'.$attribute->getColName());
        }
    }
464686
public function onWidgetDetailGenerate(WidgetDetailEvent $event)
    {
        // Share cache directories between users if appropriate.
        if ($this->settingsHelper->getShareCaches()) {
            $cacheDir = $this->coreParametersHelper->getParameter(
                'cached_data_dir',
                $this->pathsHelper->getSystemPath('cache', true)
            );
            $event->setCacheDir($cacheDir, 'shared_dashboard');
        }

        // Override the default cache timeout for the widget if appropriate.
        if ($this->settingsHelper->getCacheTTL()) {
            /** @var Widget $widget */
            $widget = $event->getWidget();
            if ($widget) {
                $defaultCacheTTL = $widget->getCacheTimeout();
                if ($defaultCacheTTL < $this->settingsHelper->getCacheTTL()) {
                    $event->setCacheTimeout($this->settingsHelper->getCacheTTL());
                }
                // add date Params as clone params to keep date as unique key for cache
                // since Core removes date params before generating keys
                $params                  = $widget->getParams();
                $cloneFrom               = isset($params['dateFrom']) ? clone $params['dateFrom'] : new \DateTime('today midnight');
                $cloneTo                 = isset($params['dateTo']) ? clone $params['dateTo'] : new \DateTime('tomorrow midnight - 1 second');
                $params['uniqueDateKey'] = [
                    'fromKey' => $cloneFrom,
                    'toKey'   => $cloneTo,
                ];
                $widget->setParams($params);
            }
        }
    }
369797
public function addContextual($event)
    {
        $page = $event->getPage();
        $currentArticle = $event->getPage()->getBusinessEntity();

        $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar();

        $bottomRightNavbar->addChild('menu.page.settings',
            [
                'route'           => 'victoire_blog_article_settings',
                'routeParameters' => [
                    'id'      => $currentArticle->getId(),
                    'page_id' => $page->getId(),
                ],
                'linkAttributes' => [
                    'class' => 'v-btn v-btn--sm v-btn--transparent',
                    'id'    => 'v-settings-link',
                ],
            ]
        )->setLinkAttribute('data-toggle', 'vic-modal');
    }
1240772
public function onDisplay(DisplayWidgetEvent $event)
    {
        $instance = $event->getInstance();
        $params = ($instance->isDesktop()) ?
            $this->logManager->getDesktopWidgetList($instance):
            $this->logManager->getWorkspaceWidgetList($instance);
        $view = $this->twig->render('ClarolineCoreBundle:Log:no_action_found.html.twig', array());

        if ($params && count($params['logs']) > 0) {
            $view = $this->twig->render(
                'ClarolineCoreBundle:Log:view_short_list.html.twig',
                $params
            );
        }

        $event->setContent($view);
        $event->stopPropagation();
    }
698955
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:resources.html.twig', [
                'context' => [
                    'type' => Widget::CONTEXT_DESKTOP,
                ],
                'root' => null,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
937261
public static function onApplicationReady(Event $event)
    {
        $app = $event->getTarget();

        $twigAdapter = $app->getRenderer()->getAdapter('twig');
        if (null === $twigAdapter) {
            return;
        }

        foreach ($app->getContainer()->findTaggedServiceIds('twig.extension') as $id => $data) {
            $twigAdapter->addExtension($app->getContainer()->get($id));
        }
    }
517334
private function addDebugInfo(): void
    {
        $tpl = $this->getTplPath($this->widget->template);

        $this->html = "<span title='WidgetObj : ".get_class($this->widget).".php&#013;Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>";
    }
1080037
public function beforeRender(Event $event)
    {
        if ($this->_controller()->getName() === 'Error') {
            return;
        }

        if (!empty($event->getSubject()->entity)) {
            $this->_entity = $event->getSubject()->entity;
        }

        if ($this->associations === null) {
            $this->associations = $this->_associations(array_keys($this->_getRelatedModels()));
        }

        $this->ensureConfig();

        $this->beforeRenderFormType();
        $this->beforeRenderIndexType();
        $this->beforeRenderSiteTitle();
        $this->beforeRenderUtilityNavigation();
        $this->beforeRenderSidebarNavigation();

        $controller = $this->_controller();
        $controller->set('actionConfig', $this->_action()->getConfig());
        $controller->set('title', $this->_getPageTitle());
        $controller->set('breadcrumbs', $this->_getBreadcrumbs());

        $associations = $this->associations;
        $controller->set(compact('associations'));

        $fields = $this->_scaffoldFields($associations);
        $controller->set('fields', $fields);
        $controller->set('formTabGroups', $this->_getFormTabGroups($fields));

        $controller->set('blacklist', $this->_blacklist());
        $controller->set('actions', $this->_getControllerActions());
        $controller->set('bulkActions', $this->_getBulkActions());
        $controller->set('viewblocks', $this->_getViewBlocks());
        $controller->set('actionGroups', $this->_getActionGroups());
        $controller->set($this->_getPageVariables());
    }
1011674
public function onBeforeControllerGet(AnEvent $event)
    {
        parent::onBeforeControllerGet($event);

        if ($this->getController()->getItem()) {
            $this->addToolbarCommands();
        }
    }