Handles event

@param array $customfields
432333
public function handle(array $customfields = [])
    {
        if (empty($customfields)) {
            return;
        }
        /**
         * Taking all customfields from db
         */
        $fields = FieldView::query()->with('fieldsets')->where('brand_id', brand_id())->get()->groupBy('category_name');

        /**
         * Traverse customfields to fill database configuration
         */
        foreach ($customfields as $classname => $customfield) {
            $slug  = strtolower(last(explode('\\', $classname)));
            $group = $fields->get($slug, []);
            foreach ($customfield as $field) {
                if (empty($group)) {
                    continue;
                }
                $first = $group->first(function ($value, $key) use($field) {
                    return $value->name === $field->getName();
                });

                $field->attach($first);
            }
        }
    }
613723
public function event($field, $userId, $scopeId = 0, array $context = [], float $count = 1, $eventTime = null)
    {
        $this->sendEventData($this->makeEventData($field, $userId, $scopeId, $context, $count, $eventTime));

        return $this;
    }
879329
public function checkCustomFields($customFields, $type = self::TYPE_CONTACTS)
	{
		$type 		= $this->amoType($type);
		$response = $this->listCurrentAccounts();
		$account 	= $response['response']['account'];
		$need 		= array_flip($customFields);
		if(isset($account['custom_fields'],$account['custom_fields'][$type]))
			do
		{
			foreach($account['custom_fields'][$type] as $field)
				if(is_array($field) && isset($field['id']))
				{
					if(isset($field['code']) && isset($need[$field['code']]))
						$fields[$field['code']]=(int)$field['id'];
					$diff=array_diff_key($need,$fields);
					if(empty($diff))
						break 2;
				}
				if(isset($diff)){
					die('В amoCRM отсутствуют следующие поля'.': '.join(', ',$diff));
				}
				else{
					die('Невозможно получить дополнительные поля');
				}
			}
			while(false);
			else
				die('Невозможно получить дополнительные поля');
			$custom_fields = isset($fields) ? $fields : false;
			return $custom_fields;
	}
278443
public function doUpdateFormField($field)
    {
        $this->extend('beforeUpdateFormField', $field);
        $this->updateFormField($field);
        $this->extend('afterUpdateFormField', $field);
    }
111246
protected function addToForm(CustomField $customfield)
    {
        if (!$customfield->formAutoDisplay()) {
            return false;
        }
        $field = $customfield->setModel($this->grid->row);


        $this->grid->fieldset(function (Fieldset $fieldset) use($field) {
            $fieldset->add($field);
        });

        $this->grid->rules(array_merge($this->grid->rules, $field->getRules()));

        $this->grid->row->saved(function($row) use($field) {

            $field->onSave($row);
        });



        return $this;
    }
958882
public function update(CustomField $customField): CustomField
    {
        $id = $customField->getId();

        $customField->setId(null);

        $response = $this->client->put($this->prepareUrlForKey('update-custom-field', ['id' => $id]), [], $customField->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new CustomField($responseData);
    }
1305567
public function handle($event)
    {
        $needCrop = $event->dataType->rows()
            ->whereType('image')
            ->where('details', 'like', '%cropper%')
            ->exists();

        if ($needCrop) {
            $event->model->cropPhotos($event);
        }
    }
218219
protected function addCustomfield($grid, $field)
    {
        if (!$field instanceof \Antares\Customfield\CustomField) {
            $customfield = with(new \Antares\Customfield\CustomField())->attributes($field);
        } else {
            $customfield = $field;
        }
        $customfield->setModel($grid->row);
        $this->add($customfield);
        if (is_null($grid->rules)) {
            $grid->rules([]);
        }
        $grid->rules(array_merge($grid->rules, $customfield->getRules()));

        $grid->row->saved(function ($row) use ($customfield) {
            $customfield->onSave($row);
        });
    }
1244899
public function setCustomFields(ArrayCollection $customFields)
    {
        @trigger_error(__METHOD__.' is deprecated', E_USER_DEPRECATED);

        $this->customFields = $customFields;

        return $this;
    }
162071
public function deleteEventType($fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('LID', 'EVENT_NAME'));

        $exists = $this->getEventType(array(
            'EVENT_NAME' => $fields['EVENT_NAME'],
            'LID' => $fields['LID']
        ));

        if (empty($exists)) {
            return false;
        }

        if (\CEventType::Delete(array("ID" => $exists['ID']))) {
            return true;
        }

        $this->throwException(__METHOD__, 'Could not delete event type %s:%s', $fields['EVENT_NAME'], $fields['LID']);
    }
127384
protected function getOnUpdateAction(array $fields)
    {
        $final = [];

        foreach ($fields as $field) {
            $action = $this->extractClassFromString($field->onUpdate);
            if (!empty($action)) {
                $final[] = $this->getArrayReadyString($field->name, $action);
            }
        }

        return implode(PHP_EOL, $final);
    }
823083
public function addFields(array $fields)
    {
        array_walk(
            $fields,
            function ($field, $key) {
                $this->addField($key, $field);
            }
        );
    }
839533
protected function handleError($customMessage = null)
    {
        $message = new stdClass();
        $message->is_error = true;
        if (null !== $customMessage) {
            $message->message = $customMessage;
        }

        return $message;
    }
1269895
protected function saveOriginalFieldNames(array $fields, string $field): void
	{
		foreach($fields as $expanded)
		{
			$this->originalFieldNames[$expanded] = $field;
		}
	}
444469
public function definition() {
        global $PAGE;
        $mform = $this->_form;

        $field = $this->_customdata['field'];
        if (!($field && $field instanceof field_controller)) {
            throw new \coding_exception('Field must be passed in customdata');
        }
        $handler = $field->get_handler();

        $mform->addElement('header', '_commonsettings', get_string('commonsettings', 'core_customfield'));

        $mform->addElement('text', 'name', get_string('fieldname', 'core_customfield'), 'size="50"');
        $mform->addRule('name', null, 'required', null, 'client');
        $mform->setType('name', PARAM_TEXT);

        // Accepted values for 'shortname' would follow [a-z0-9_] pattern,
        // but we are accepting any PARAM_TEXT value here,
        // and checking [a-zA-Z0-9_] pattern in validation() function to throw an error when needed.
        $mform->addElement('text', 'shortname', get_string('fieldshortname', 'core_customfield'), 'size=20');
        $mform->addHelpButton('shortname', 'shortname', 'core_customfield');
        $mform->addRule('shortname', null, 'required', null, 'client');
        $mform->setType('shortname', PARAM_TEXT);

        $desceditoroptions = $handler->get_description_text_options();
        $mform->addElement('editor', 'description_editor', get_string('description', 'core_customfield'), null, $desceditoroptions);
        $mform->addHelpButton('description_editor', 'description', 'core_customfield');

        // If field is required.
        $mform->addElement('selectyesno', 'configdata[required]', get_string('isfieldrequired', 'core_customfield'));
        $mform->addHelpButton('configdata[required]', 'isfieldrequired', 'core_customfield');
        $mform->setType('configdata[required]', PARAM_BOOL);

        // If field data is unique.
        $mform->addElement('selectyesno', 'configdata[uniquevalues]', get_string('isdataunique', 'core_customfield'));
        $mform->addHelpButton('configdata[uniquevalues]', 'isdataunique', 'core_customfield');
        $mform->setType('configdata[uniquevalues]', PARAM_BOOL);

        // Field specific settings from field type.
        $field->config_form_definition($mform);

        // Handler/component settings.
        $handler->config_form_definition($mform);

        // We add hidden fields.
        $mform->addElement('hidden', 'categoryid');
        $mform->setType('categoryid', PARAM_INT);

        $mform->addElement('hidden', 'type');
        $mform->setType('type', PARAM_COMPONENT);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $this->add_action_buttons(true);
    }
466519
public void setCustomFields(Map<String, String> fields) {
        clearCustomFields();
        for (String key : fields.keySet()) {
            CustomField f = new CustomField();
            f.setName(key);
            f.setValue(fields.get(key));
            customFields.add(f);
        }
    }
573484
private static function handleSelectandi($fields) {
        $i = 0;
        $res = '';
        foreach($fields as $what) {
            $res .= ($i > 0 ? ', ' : '') . self::$_ops->selectandi($what);
            $i++;
        }
        return $res;
    }