Before marshal callaback

@param \Cake\Event\Event $event The Model.beforeMarshal event.
@param \ArrayObject $data Data.
@param \ArrayObject $options Options.
@return void
499977
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
    {
        $field = $this->getConfig('tagsAssoc.propertyName');
        if (!empty($data[$field]) && (!is_array($data[$field]) || !array_key_exists('_ids', $data[$field]))) {
            $data[$field] = $this->normalizeTags($data[$field]);
        }
        if (isset($data[$field]) && empty($data[$field])) {
            unset($data[$field]);
        }
    }
106213
protected function _prepareDataAndOptions($data, $options)
    {
        $options += ['validate' => true];

        if (!isset($options['fields']) && isset($options['fieldList'])) {
            deprecationWarning(
                'The `fieldList` option for marshalling is deprecated. Use the `fields` option instead.'
            );
            $options['fields'] = $options['fieldList'];
            unset($options['fieldList']);
        }

        $tableName = $this->_table->getAlias();
        if (isset($data[$tableName])) {
            $data += $data[$tableName];
            unset($data[$tableName]);
        }

        $data = new ArrayObject($data);
        $options = new ArrayObject($options);
        $this->_table->dispatchEvent('Model.beforeMarshal', compact('data', 'options'));

        return [(array)$data, (array)$options];
    }
481869
public function handleEvent(Event $event, $ormObject, $options)
    {
        $key = $this->getConfig('optionKey');
        if (empty($options[$key]) && !empty($this->_currentUser)) {
            $options[$key] = $this->_currentUser;
        }
    }
358250
public static function fire($event, $data = null)
    {
        if (!is_array($data)) {
            $data = array($data);
        }
        array_unshift($data, $event);

        $retval = true;

        foreach (array('*', $event) as $e) {
            if (!array_key_exists($e, self::$events)) {
                continue;
            }

            foreach (self::$events[$e] as $callback) {
                if (!is_callable($callback)) {
                    continue;
                }

                if (($retval = call_user_func_array($callback, $data)) === false) {
                    break 2;
                }
            }
        }

        return $retval !== false;
    }
222094
public function beforeSave($event, $entity, $options)
    {
        $auth = Configure::read('GlobalAuth');
        $id = $auth['id'];

        if ($entity->isNew()) {
            if ($this->config('created_by')) {
                $entity->set($this->config('created_by'), $id);
            }
        }

        if ($this->config('modified_by')) {
            $entity->set($this->config('modified_by'), $id);
        }
    }
1251393
public function __selectAfter(&$data,$linkOption)
	{
		$this->parseTotal($data,$linkOption);
		foreach($data as $index => $value)
		{
			$this->__selectOneAfter($data[$index],$linkOption);
		}
	}
776725
public function beforePrepare(Event $event)
	{
		$operation = $event['command']->getOperation();
		$client = $event['command']->getClient();

		if ($operation->hasParam('collection') === false) return;
		if (is_null($client->getCollectionName())) return;

		$operation->getParam('collection')->setDefault($client->getCollectionName());
		$operation->getParam('collection')->setStatic(true);

	}
1104629
private static function onReceivedMessage(string $event, $data)
    {
        foreach (self::$onMessage[$event] ?? [] as $callback) {
            asyncCall($callback, $data);
        }
    }
1304225
protected function _prepareDataAndOptions($data, $options)
    {
        $options += ['validate' => true];

        $endpointName = $this->_endpoint->getAlias();
        if (isset($data[$endpointName])) {
            $data = $data[$endpointName];
        }

        $data = new ArrayObject($data);
        $options = new ArrayObject($options);
        $this->_endpoint->dispatchEvent('Model.beforeMarshal', compact('data', 'options'));

        return [(array)$data, (array)$options];
    }
854908
public function beforeFilter(\Cake\Event\Event $event)
    {
        parent::beforeFilter($event);

        // get the type-string
        $type = $this->PostTypes->postTypeFinder($this->request);
        $this->_type = $type;

        // check if the string exists. Will throw an exception
        $this->PostTypes->check($type, ['exception' => true]);

        // intialize the settings
        $this->Settings = $this->PostTypes->get($type);

        // lets initialize the model too
        $this->Model = $this->loadModel($this->Settings['model']);
    }
1106064
public function beforeFilter(Event $event)
    {
        $this->TimebasedCurrencyPayment = TableRegistry::getTableLocator()->get('TimebasedCurrencyPayments');
        $this->TimebasedCurrencyOrderDetail = TableRegistry::getTableLocator()->get('TimebasedCurrencyOrderDetails');
        parent::beforeFilter($event);
    }
653675
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
    {
        if (! is_callable($this->getConfig('callback'))) {
            return;
        }

        $user = call_user_func($this->getConfig('callback'));
        if (empty($user['id'])) {
            return;
        }

        // Set created_by only if that field is not set during entity creation
        if ($entity->isNew() && empty($entity->get($this->getConfig('created_by')))) {
            $entity->set($this->getConfig('created_by'), $user['id']);
        }

        // Set modified_by if that field is not set during update
        $userId = $entity->isDirty($this->getConfig('modified_by')) && !empty($this->getConfig('modified_by')) ? $entity->get($this->getConfig('modified_by')) : $user['id'];
        $entity->set($this->getConfig('modified_by'), $userId);
    }
1015274
protected function create(Event $event)
    {
        $this->dispatch(static::EVENT_CREATE_BEFORE, $event);
        if (!$event->isPropagationStopped()) {
            $this->createProcess($event);
            if (!$event->isPropagationStopped()) {
                $this->dispatch(static::EVENT_CREATE_AFTER, $event);
            }
        }
    }
1183514
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
    {
        if (!empty($data['tags_as_string'])) {
            //Gets existing tags
            $existingTags = $this->Tags->getList()->toArray();

            $tags = array_unique(preg_split('/\s*,+\s*/', $data['tags_as_string']));

            //For each tag, it searches if the tag already exists.
            //If a tag exists in the database, it sets also the tag ID
            foreach ($tags as $k => $tag) {
                $id = array_search($tag, $existingTags);

                if ($id) {
                    $data['tags'][$k]['id'] = $id;
                }

                $data['tags'][$k]['tag'] = $tag;
            }
        }
    }
42724
public function onBefore(BeforeEvent $event)
    {
        $request = $event->getRequest();
        $context = Tracer::spanContext();
        if ($context->enabled()) {
            $request->setHeader($this->propagator->key(), $this->propagator->formatter()->serialize($context));
        }
        $span = Tracer::startSpan([
            'name' => 'GuzzleHttp::request',
            'attributes' => [
                'method' => $request->getMethod(),
                'uri' => $request->getUrl()
            ],
            'kind' => Span::KIND_CLIENT
        ]);
        $this->scope = Tracer::withSpan($span);
    }
931120
public function notify($event, array $data = [])
    {
        $event = (string) $event;

        if (($pos = strpos($event, '.')) == false) {
            throw new \InvalidArgumentException('The event name is invalid (expecting "action.event")');
        }

        $action = substr($event, 0, $pos);

        if (!isset($this->responders[$action])) {
            return;
        }

        if (isset($this->data[$action])) {
            $data = array_merge($this->data[$action], $data);
        }

        foreach ($this->responders[$action] as $responder) {
            if ($responder instanceof ResponderInterface) {
                $responder->respond($event, $data);
            } elseif (is_callable($responder)) {
                $responder($event, $data);
            }
        }
    }
765249
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
    {
        parent::beforeSave($event, $entity, $options);

        list($width, $height) = getimagesize($entity->path);
        $entity->size = compact('width', 'height');
    }