Populate the extra data of the widget.

@param BuildWidgetEvent $event The event.

@return void

@SuppressWarnings(PHPMD.CyclomaticComplexity)
@SuppressWarnings(PHPMD.NPathComplexity)
518964
public function fillExtraData(BuildWidgetEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getProperty()->getName() !== 'translatedtabletext_cols')) {
            return;
        }

        $model         = $event->getModel();
        $metaModelName = $this->factory->translateIdToMetaModelName($event->getModel()->getProperty('pid'));
        $objMetaModel  = $this->factory->getMetaModel($metaModelName);
        $translator    = $event->getEnvironment()->getTranslator();

        // Check model and input for the cols and get the max value.
        $intModelCols = $model->getProperty('tabletext_quantity_cols');
        $intInputCols = $event->getEnvironment()->getInputProvider()->getValue('tabletext_quantity_cols');
        $intCols      = \max((int) $intModelCols, (int) $intInputCols);

        // For new models, we might not have a value.
        if (!$intCols) {
            return;
        }

        if (!($objMetaModel && $objMetaModel->isTranslated())) {
            return;
        }

        $attribute = $objMetaModel->getAttributeById($model->getProperty('id'));
        $arrValues = $attribute ? $attribute->get('name') : [];

        $languageEvent = new LoadLanguageFileEvent('languages');
        $this->eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $languageEvent);

        $arrLanguages = [];
        foreach ((array) $objMetaModel->getAvailableLanguages() as $strLangCode) {
            $arrLanguages[$strLangCode] = $translator->translate($strLangCode, 'LNG');
        }
        \asort($arrLanguages);

        // Ensure we have the values present.
        if (empty($arrValues)) {
            foreach ((array) $objMetaModel->getAvailableLanguages() as $strLangCode) {
                $arrValues[$strLangCode] = '';
            }
        }

        $arrRowClasses = [];
        foreach (\array_keys(\deserialize($arrValues)) as $strLangcode) {
            $arrRowClasses[] = ($strLangcode == $objMetaModel->getFallbackLanguage())
                ? 'fallback_language'
                : 'normal_language';
        }

        $data                                      = $event->getProperty()->getExtra();
        $data['minCount']                          = \count($arrLanguages);
        $data['maxCount']                          = \count($arrLanguages);
        $data['columnFields']['langcode']['label'] = $translator->translate(
            'name_langcode',
            'tl_metamodel_attribute'
        );

        $data['columnFields']['langcode']['options']            = $arrLanguages;
        $data['columnFields']['langcode']['eval']['rowClasses'] = $arrRowClasses;
        $data['columnFields']['rowLabels']['label']             = $translator->translate(
            'tabletext_rowLabels',
            'tl_metamodel_attribute'
        );

        $data['columnFields']['rowLabels']['eval']['minCount']                          = $intCols;
        $data['columnFields']['rowLabels']['eval']['maxCount']                          = $intCols;
        $data['columnFields']['rowLabels']['eval']['columnFields']['rowLabel']['label'] = $translator->translate(
            'tabletext_rowLabel',
            'tl_metamodel_attribute'
        );

        $data['columnFields']['rowLabels']['eval']['columnFields']['rowLabel']['eval']  = $arrRowClasses;
        $data['columnFields']['rowLabels']['eval']['columnFields']['rowStyle']['label'] = $translator->translate(
            'tabletext_rowStyle',
            'tl_metamodel_attribute'
        );

        $event->getProperty()->setExtra($data);
    }
15505
public function onNick(Event $event)
    {
        $msg = $event->getMessage();

        $oldNick = $msg['nick'];
        $newNick = $msg['params']['nickname'];

        $this->storage->updateNickname($oldNick, $newNick);
    }
892764
public function handleGetAttributesFromDca(GetAttributesFromDcaEvent $event)
    {
        /** @var Widget $widgetAdapter */
        $widgetAdapter = $this->framework->getAdapter(Widget::class);

        $event->setResult(
            $widgetAdapter->getAttributesFromDca(
                $event->getFieldConfiguration(),
                $event->getWidgetName(),
                $event->getValue(),
                $event->getWidgetId(),
                $event->getTable(),
                $event->getDataContainer()
            )
        );
    }
1374829
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $event = $options['data'];
        $builder
            ->add('start', null, [
                'label' => 'event.form.start',
                'date_widget' => 'single_text',
                'time_widget' => 'single_text',
            ])
            ->add('end', null, [
                'label' => 'event.form.end',
                'date_widget' => 'single_text',
                'time_widget' => 'single_text',
            ])
            ->add('name', null, [
                'label' => 'event.form.name',
            ])
            ->add('location', null, [
                'label' => 'event.form.location',
            ])
            ->add('description', CKEditorType::class, [
                'label' => 'event.form.description',
                'required' => false,
                'config' => ['toolbar' => 'basic'],
            ])
            ->add('full_company', CheckboxType::class, [
                'label' => 'event.form.full_company',
                'required' => false,
            ])
            ->add('invitations', CollectionType::class, [
                'label' => 'event.form.invitations',
                'entry_type' => InvitationType::class,
                'entry_options' => ['label' => false],
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false,
            ])
            ->add('colour', ChoiceType::class, [
                'label' => 'event.form.colour',
                'required' => false,
                'choices' => [
                    'event.form.colour_choices.red' => 'important',
                    'event.form.colour_choices.green' => 'success',
                    'event.form.colour_choices.yellow' => 'warning',
                    'event.form.colour_choices.blue' => 'info',
                    'event.form.colour_choices.dark' => 'inverse',
                    'event.form.colour_choices.purple' => 'special',
                ],
            ])
            ->add('active', ChoiceType::class, [
                // Show "unpublished" instead of active.
                'choice_loader' => new CallbackChoiceLoader(function () use ($event) {
                    yield 'event.form.status_choices.active' => true;
                    if (!$event->isPublished()) {
                        yield 'event.form.status_choices.unpublished' => false;
                    } else {
                        yield 'event.form.status_choices.archived' => false;
                    }
                }),
                'label' => 'event.form.status',
            ])
        ;
    }
806351
public function buildFromEvent(Event $event)
    {
        $this->setEvent($event);

        $configs = $this->getConfigFilesByComposer();
        $this->addFindersByConfigs($configs);

        // We have to initialize composer autoload
        require_once 'vendor/autoload.php';

        $this->build();
    }
1238445
public function convertUuidToFileSource(DecodePropertyValueForWidgetEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $propertiesDefinition = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition();
        $property             = $propertiesDefinition->getProperty($event->getProperty());


        if (!\array_key_exists('rte', $property->getExtra())
            || \strpos($property->getExtra()['rte'], 'tiny') !== 0
        ) {
            return;
        }

        $event->setValue(
            StringUtil::insertTagToSrc($event->getValue())
        );
    }
701460
public function addEventToList(Event $event)
    {
        if ($this->_eventList) {
            $this->_eventList->add($event);
        }

        return $this;
    }
954410
public function taskFinished(BuildEvent $event)
    {
        // ignore tasks in root
        if ($event->getTarget()->getName() == "") {
            return;
        }

        $this->remTasks--;
        $this->bar->advance();
    }
1280472
public synchronized void insert_event(EventData event) {
        events.add(event);
        while (events.size() > max_size)
            events.remove(0);
    }
1271323
public function onInit(BaseEvent $event)
    {
        $this->state->loadSettings();
        // It is not possible to know if the user specified --dev or --no-dev so assume it is false.
        // The dev section will be merged later when the other events fire.
        $this->state->setDevMode(false);
        $this->mergeFiles($this->state->getIncludes(), false);
        $this->mergeFiles($this->state->getRequires(), true);
    }
602046
public function attach($event)
    {
        $this->attachRows($event);
        $this->attachSeo($event);
        $this->attachAnonsModule($event);
    }
265150
public function construct(ConstructEvent $event)
    {
        if ($event->getTwig()->hasExtension(Extension\Profiler::class)) {
            return;
        }

        $profile = new Profile();
        $event->getTwig()->addExtension(new Extension\Profiler($profile));

        EventManager::instance()->dispatch(ProfileEvent::create($profile));
    }
1310367
public function onBuildView(CollectViewParametersEvent $event): void
    {
        $view = $event->getView();
        if (!$view instanceof LayoutViewInterface) {
            return;
        }

        if ($view->getContext() !== ViewInterface::CONTEXT_ADMIN) {
            return;
        }

        $layout = $view->getLayout();

        $relatedLayoutsCount = 0;
        if ($layout->isShared() && $layout->isPublished()) {
            $relatedLayoutsCount = $this->layoutService->getRelatedLayoutsCount($layout);
        }

        $event->addParameter('related_layouts_count', $relatedLayoutsCount);
    }
1329048
public function buildFinished(BuildEvent $event)
    {
        parent::buildFinished($event);

        $project = $event->getProject();
        $properties = $project->getProperties();

        $filename = $properties['phing.log.mail.properties.file'];

        // overlay specified properties file (if any), which overrides project
        // settings
        $fileProperties = new Properties();
        $file = new PhingFile($filename);

        try {
            $fileProperties->load($file);
        } catch (IOException $ioe) {
            // ignore because properties file is not required
        }

        foreach ($fileProperties as $key => $value) {
            $properties['key'] = $project->replaceProperties($value);
        }

        $success = $event->getException() === null;
        $prefix = $success ? 'success' : 'failure';

        try {
            $notify = StringHelper::booleanValue($this->getValue($properties, $prefix . '.notify', 'on'));
            if (!$notify) {
                return;
            }

            if (is_string(Phing::getDefinedProperty('phing.log.mail.subject'))) {
                $defaultSubject = Phing::getDefinedProperty('phing.log.mail.subject');
            } else {
                $defaultSubject = ($success) ? 'Build Success' : 'Build Failure';
            }
            $hdrs = [];
            $hdrs['From'] = $this->getValue($properties, 'from', $this->from);
            $hdrs['Reply-To'] = $this->getValue($properties, 'replyto', '');
            $hdrs['Cc'] = $this->getValue($properties, $prefix . '.cc', '');
            $hdrs['Bcc'] = $this->getValue($properties, $prefix . '.bcc', '');
            $hdrs['Body'] = $this->getValue($properties, $prefix . '.body', '');
            $hdrs['Subject'] = $this->getValue($properties, $prefix . '.subject', $defaultSubject);
            $tolist = $this->getValue($properties, $prefix . '.to', $this->tolist);
        } catch (BadMethodCallException $e) {
            $project->log($e->getMessage(), Project::MSG_WARN);
        }

        if (empty($tolist)) {
            return;
        }

        $mail = Mail::factory('mail');
        $mail->send($tolist, $hdrs, $this->mailMessage);
    }
879440
public function resolveWidgetErrorMessage(ResolveWidgetErrorMessageEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $error = $event->getError();

        if ($error instanceof \Exception) {
            $event->setError($error->getMessage());
        } elseif (\is_object($error)) {
            if (\method_exists($error, '__toString')) {
                $event->setError((string) $error);
            } else {
                $event->setError(\sprintf('[%s]', \get_class($error)));
            }
        } elseif (!\is_string($error)) {
            $event->setError(\sprintf('[%s]', \gettype($error)));
        }
    }
330311
public function onAddNewItem(AddNewItem $event)
    {
        $item = $event->getItem();
        if (!$event->getFillers()->contains($this->filler) && ($url = $this->refiller->getSourceForFill($item))) {
            $new_item = $this->filler->fill(['url' => $url]);

            // fill item
            if (!$item->getCountry()) {
                $item->setCountry($new_item->getCountry());
            }
            if (!$item->getDateEnd()) {
                $item->setDateEnd($new_item->getDateEnd());
            }
            if (!$item->getDatePremiere()) {
                $item->setDatePremiere($new_item->getDatePremiere());
            }
            if (!$item->getDuration()) {
                $item->setDuration($new_item->getDuration());
            }
            if (!$item->getEpisodes()) {
                $item->setEpisodes($new_item->getEpisodes());
            }
            if (!$item->getEpisodesNumber()) {
                $item->setEpisodesNumber($new_item->getEpisodesNumber());
            }
            if (!$item->getFileInfo()) {
                $item->setFileInfo($new_item->getFileInfo());
            }
            if (!$item->getSummary()) {
                $item->setSummary($new_item->getSummary());
            }
            if (!$item->getStudio()) {
                $item->setStudio($new_item->getStudio());
            }
            if (!$item->getType()) {
                $item->setType($new_item->getType());
            }
            // remove links
            $item->getCountry()->removeItem($new_item);
            $item->getType()->removeItem($new_item);
            $item->getStudio()->removeItem($new_item);

            if (!$item->getCover()) {
                $item->setCover($new_item->getCover());
            }
            foreach ($new_item->getGenres() as $genre) {
                $item->addGenre($genre->removeItem($new_item));
            }
            // set main name in top of names list
            $new_names = $new_item->getNames()->toArray();
            array_unshift($new_names, (new Name())->setName($new_item->getName()));
            foreach ($new_names as $new_name) {
                $item->addName($new_name->setItem(null));
            }
            foreach ($new_item->getSources() as $source) {
                $item->addSource($source->setItem(null));
            }

            $event->addFiller($this->filler);
            // resend event
            $this->dispatcher->dispatch(StoreEvents::ADD_NEW_ITEM, clone $event);
            $event->stopPropagation();
        }
    }
1238164
void add(int event) {
        int b = bits.addAndGet(event);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(this, tc, "add " + event + ", polling state: " + b);
    }