Handles value-changed events that are received from the entity's value holders.

@param ValueChangedEvent $event
551003
public function onValueChanged(ValueChangedEvent $event)
    {
        // @todo Possible optimization: only track events for EmbedRoot entities,
        // what will save some memory when dealing with deeply nested embed structures.
        $this->changes->push($event);
        $this->propagateEntityChangedEvent($event);
    }
277623
protected function handleError($event)
    {
        if (error_reporting() & $event->code) {
            $this->getSentryClient()->captureException(
                $this->createErrorException($event->message, $event->code, $event->file, $event->line)
            );
        }
        parent::handleError($event);
    }
49109
protected function handle($event): void
    {
        $method = $this->getApplyMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
238733
@UiHandler("m_searchInput")
    protected void onSearchInputChange(ValueChangeEvent<String> event) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(event.getValue()) && (event.getValue().length() >= 3)) {
            m_tabHandler.setSearchQuery(event.getValue());
        } else {
            m_tabHandler.setSearchQuery(null);
        }
    }
880493
public function handlePersist(PersistEvent $event)
    {
        if (!$this->supports($event->getDocument())) {
            return;
        }

        $this->persistEvents[] = $event;
    }
154428
function clearEventHandlers($event = null)
	{
		if (!empty($event)) {
			$this->_events[$event] = array();
		}
		else {
			$this->_events = array();
		}
	}
192919
public function onEntityChanged(EntityChangedEvent $embedded_entity_event)
    {
        $value_changed_event = $embedded_entity_event->getValueChangedEvent();

        $this->propagateValueChangedEvent(
            new ValueChangedEvent(
                array(
                    'attribute_name' => $value_changed_event->getAttributeName(),
                    'prev_value' => $value_changed_event->getOldValue(),
                    'value' => $value_changed_event->getNewValue(),
                    'embedded_event' => $embedded_entity_event
                )
            )
        );
    }
146674
@UiHandler("m_everyDay")
    void onEveryDayChange(ValueChangeEvent<String> event) {

        if (handleChange()) {
            m_controller.setInterval(m_everyDay.getFormValueAsString());
        }

    }
658502
public function handlePersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        if (!$event->getOption('auto_name') || !$document instanceof AutoNameBehavior || $event->hasNode()) {
            return;
        }

        $parentNode = $event->getParentNode();
        $name = $this->getName($document, $parentNode, $event->getOption('auto_rename'));
        $node = $parentNode->addNode($name);
        $event->setNode($node);
    }
306553
@UiHandler("m_dateCreatedEndDateBox")
    protected void onDateCreatedEndChange(ValueChangeEvent<Date> event) {

        if (event.getValue() != null) {
            m_tabHandler.setDateCreatedEnd(event.getValue().getTime());
        } else {
            // if the field is empty take the max value
            m_tabHandler.setDateCreatedEnd(-1L);
        }
    }
185925
public void fireChangeEvent() {

        String result = "";
        if (m_textarea.getFormValueAsString() != null) {
            result = m_textarea.getFormValueAsString();
        }

        ValueChangeEvent.fire(this, result);
    }
1011092
final private function replayChange(Event $event)
    {
        $this->apply($event->payload());
        $this->lastCommittedEventSequenceNumber = $event->sequenceNumber();
    }
209686
public function handleChangedBlockType(ConfigEvent $event)
    {
        if ($this->ignoreProjectConfigChanges) {
            return;
        }

        $blockTypeUid = $event->tokenMatches[0];
        $data = $event->newValue;
        $previousData = $event->oldValue;

        // Make sure the field has been synced
        $fieldId = Db::idByUid(Table::FIELDS, $data['field']);
        if ($fieldId === null) {
            Craft::$app->getProjectConfig()->defer($event, [$this, __FUNCTION__]);
            return;
        }

        $fieldsService = Craft::$app->getFields();
        $contentService = Craft::$app->getContent();

        $transaction = Craft::$app->getDb()->beginTransaction();

        try {
            // Store the current contexts.
            $originalContentTable = $contentService->contentTable;
            $originalFieldContext = $contentService->fieldContext;
            $originalFieldColumnPrefix = $contentService->fieldColumnPrefix;
            $originalOldFieldColumnPrefix = $fieldsService->oldFieldColumnPrefix;

            // Get the block type record
            $blockTypeRecord = $this->_getBlockTypeRecord($blockTypeUid);

            // Set the basic info on the new block type record
            $blockTypeRecord->fieldId = $fieldId;
            $blockTypeRecord->uid = $blockTypeUid;

            // Make sure that alterations, if any, occur in the correct context.
            $contentService->fieldContext = 'superTableBlockType:' . $blockTypeUid;
            $contentService->fieldColumnPrefix = 'field_';

            /** @var SuperTableField $superTableField */
            $superTableField = $fieldsService->getFieldById($blockTypeRecord->fieldId);
            $contentService->contentTable = $superTableField->contentTable;
            $fieldsService->oldFieldColumnPrefix = 'field_';

            $oldFields = $previousData['fields'] ?? [];
            $newFields = $data['fields'] ?? [];

            // Remove fields that this block type no longer has
            foreach ($oldFields as $fieldUid => $fieldData) {
                if (!array_key_exists($fieldUid, $newFields)) {
                    $fieldsService->applyFieldDelete($fieldUid);
                }
            }

            // (Re)save all the fields that now exist for this block.
            foreach ($newFields as $fieldUid => $fieldData) {
                $fieldsService->applyFieldSave($fieldUid, $fieldData, 'superTableBlockType:' . $blockTypeUid);
            }

            // Refresh the schema cache
            Craft::$app->getDb()->getSchema()->refresh();

            $contentService->fieldContext = $originalFieldContext;
            $contentService->fieldColumnPrefix = $originalFieldColumnPrefix;
            $contentService->contentTable = $originalContentTable;
            $fieldsService->oldFieldColumnPrefix = $originalOldFieldColumnPrefix;

            if (!empty($data['fieldLayouts'])) {
                // Save the field layout
                $layout = FieldLayout::createFromConfig(reset($data['fieldLayouts']));
                $layout->id = $blockTypeRecord->fieldLayoutId;
                $layout->type = SuperTableBlockElement::class;
                $layout->uid = key($data['fieldLayouts']);

                $fieldsService->saveLayout($layout);
                $blockTypeRecord->fieldLayoutId = $layout->id;
            } else if ($blockTypeRecord->fieldLayoutId) {
                // Delete the field layout
                $fieldsService->deleteLayoutById($blockTypeRecord->fieldLayoutId);
                $blockTypeRecord->fieldLayoutId = null;
            }

            // Save it
            $blockTypeRecord->save(false);
            $transaction->commit();
        } catch (\Throwable $e) {
            $transaction->rollBack();
            throw $e;
        }

        // Clear caches
        unset(
            $this->_blockTypesById[$blockTypeRecord->id],
            $this->_blockTypesByFieldId[$blockTypeRecord->fieldId]
        );
        $this->_fetchedAllBlockTypesForFieldId[$blockTypeRecord->fieldId] = false;
    }
519201
public function send(Event $event)
    {
        $message = $this->getEventMessage($event);
        $this->flush($message);
    }
12042
protected function doSendEvent(Event $event): void
    {
        if (!$this->shouldUseGearman()) {
            $this->locator->getEventBus()->receiveEvent($event);
            return;
        }

        $envelope = new TransportEnvelope($event, 'php');
        $channel = $this->router->forEvent($event);

        try {
            $client = $this->getClient();
            @$client->doBackground($channel, $envelope->toString(), (string)$event->get('event_id'));
            $this->validateReturnCode($client, $channel);
        } catch (\GearmanException $ge) {
            if (isset(self::$reconnectCodes[$ge->getCode()])) {
                $this->destroyClient();
                $this->locator->getEventBus()->receiveEvent($event);
                return;
            }

            throw $ge;
        } catch (\Throwable $e) {
            throw $e;
        }
    }
172118
public function evaluateAttributes($event)
    {
        if (!empty($this->attributes[$event->name])) {
            $attributes = (array) $this->attributes[$event->name];
            foreach ($attributes as $attribute) {
                // ignore attribute names which are not string (e.g. when set by TimestampBehavior::updatedAtAttribute)
                if (is_string($attribute)) {
                    $value = $this->getValue($event, $attribute);
                    $this->owner->$attribute = $value;
                }
            }
        }
    }
29038
public function transition($event): void
    {
        $this->apply($event, self::HANDLE_PREFIX);

        $this->version++;
    }