@param \Interpro\Core\Contracts\Ref\ARef $ref
@param \Interpro\Core\Contracts\Taxonomy\Fields\OwnField $own
@param mixed $value

@return void
339231
public function update(ARef $ref, OwnField $own, $value)
    {
        $type          = $ref->getType();
        $type_name     = $type->getName();
        $id            = $ref->getId();
        $own_type_name = $own->getFieldTypeName();
        $own_name      = $own->getName();

        if($own_type_name !== 'seo')
        {
            throw new UpdateException('Seo не обрабатывает тип '.$own_type_name);
        }

        if(!is_string($value))
        {
            $value = '';
            //throw new UpdateException('Seo поле '.$own_name.' типа '.$own_type_name.' должно быть задано строкой!');
        }

        $field = Seo::firstOrNew(['entity_name' => $type_name, 'entity_id' => $id, 'name' => $own_name]);

        $field->value = $value;
        $field->save();
    }
436498
public function setRefid(Reference $r)
    {
        if (!empty($this->includeList) || !empty($this->excludeList)) {
            throw $this->tooManyAttributes();
        }
        parent::setRefid($r);
    }
970131
protected function _setValuesToObject($instance, $values = null) {
		if (URequest::isJSON ()) {
			if(is_string($values)){
				$values = \json_decode ( $values, true );
			}
		}
		$className = \get_class ( $instance );
		$fieldsInRelationForUpdate = OrmUtils::getFieldsInRelationsForUpdate_ ( $className );
		$manyToOneRelations = $fieldsInRelationForUpdate ["manyToOne"];
		
		$members = array_keys ( $values );
		OrmUtils::setFieldToMemberNames ( $members, $fieldsInRelationForUpdate ["relations"] );
		URequest::setValuesToObject ( $instance, $values );
		if ($manyToOneRelations) {
			$this->updateManyToOne ( $manyToOneRelations, $members, $className, $instance, $values );
		}
	}
820000
public function setConfig($reference, $value)
    {
        if (!array_key_exists($reference, $this->config)) {
            user_error("Unknown option reference: $reference", E_USER_ERROR);
        }

        if ($reference == 'actions') {
            user_error('Bulk actions must be edited via addBulkAction() and removeBulkAction()', E_USER_ERROR);
        }

        if (($reference == 'editableFields') && !is_array($value)) {
            $value = array($value);
        }

        $this->config[$reference] = $value;

        return $this;
    }
1141246
public static function doSetter( $oInstance, $field, $value=null ){

		if( $oInstance == null )
			return ;
			
		//TODO tratar los args.
		/*
		$method = self::buildSetter( $field );
		
		self::invoke( $oInstance, $method, $value );
		*/
		
		/*
		 * hay que obtener el "último" objeto para realizarle
		 * el setter.
		 * si viene algo del estilo: 
		 *   doSetter( $persona, "domicilio.calle.nombre", "Belgrano" )
		 * sería lo siguiente: 
		 *   $persona->getDomicilio()->getCalle()->setNombre( "Belgrano" )
		 */
		
		
		$methods = explode(".", $field );
		
		if( count($methods) > 1  ){
			
			$field =  $methods[ count($methods)-1 ];
			$getters =  array_slice($methods,0,count($methods)-1);
			$getters = implode(".", $getters ) ;
			$oInstance = self::doGetter( $oInstance, $getters );
		}
		
	
		$method = self::buildSetter( $field );
		
		self::invoke( $oInstance, $method, $value );
			
	}
1170011
public function execute(ARef $ref)
    {
        $type      = $ref->getType();
        $type_name = $type->getName();

        if($type->getFamily() === $this->getFamily())
        {
            if($type->getRank() === TypeRank::BLOCK)
            {
                if($type_name === 'feedback')
                {
                    //Fbac - очищать?
                }
                else//Если удаляется одна из форм, очистить письма и получателей
                {
                    Fbmail::where('form_name', '=', $type_name)->delete();
                    Fbmailto::where('form_name', '=', $type_name)->delete();
                }
            }
            elseif($type->getRank() === TypeRank::GROUP)
            {
                //Пока нет групп подчиненных группам и перекрестных ссылок в пакете
            }
        }
        else
        {
            //Когда будут ссылки на сторонние А записи - наполнить логику здесь
        }
    }
1049070
public function selectByRef(ARef $ref)
    {
        $type  = $ref->getType();
        $type_name = $type->getName();
        $id = $ref->getId();

        $table = $this->getTable($type);

        $query = new QueryBuilder(DB::table($table));
        $query->where($table.'.name', '=', $type_name);

        if($id > 0)
        {
            $query->where($table.'.id', '=', $id);
        }

        return $query;
    }
548388
public function owns(Model $related = null, ?string $foreignKey = null): bool
    {
        if (\is_null($related)) {
            return false;
        }

        if (\is_null($foreignKey)) {
            $foreignKey = $this->getForeignKey();
        }

        return $related->getAttribute($foreignKey) == $this->getKey();
    }
827433
public function hasOne($model, $our_field = null, $display_field = null, $as_field = null)
    {

        // register reference, but don't create any fields there
        // parent::hasOne($model,null);
        // model, our_field
        $this->_references[null] = $model;

        if (!$our_field) {
            if (!is_object($model)) {
                $tmp = $this->app->normalizeClassName($model, 'Model');
                $tmp = new $tmp(); // avoid recursion
            } else {
                $tmp = $model;
            }
            $our_field = ($tmp->table).'_id';
        }

        /** @type Field_Reference $r */
        $r = $this->add('Field_Reference', array('name' => $our_field, 'dereferenced_field' => $as_field));
        $r->setModel($model, $display_field);
        $r->system(true)->editable(true);

        return $r;
    }
705323
public function update(Expression $key = null, Expression $value, $isReference)
    {
        if ($this->key === $key
                && $this->value === $value
                && $this->isReference === $isReference
        ) {
            return $this;
        }

        return new self($key, $value, $isReference);
    }
17954
protected function setOwnerError()
    {
        if (strlen($this->getMessage()) && !$this->owner->getError()) {
            $this->owner->setError($this->getMessage());
        }
    }
1170575
public static function setField($owningEntity, $key, CustomFieldBase $entity)
    {
        if ($entity->isEmpty()) {
            self::remove($owningEntity, $key);

            return;
        }
        /** @var Collection */
        $customFields = $owningEntity->getNonemptyCustomFields();
        if ($entity->getFieldId() !== $key) {
            $entity = clone $entity;
            $entity->setFieldId($key);
        }
        $customFields->set($key, $entity);
    }
1306892
public function setFieldValue($document, $field, $value)
    {
        $this->reflFields[$field]->setValue($document, $value);
    }
928498
public function init(ARef $ref, OwnField $own, $value = null)
    {
        $type          = $ref->getType();
        $type_name     = $type->getName();
        $id            = $ref->getId();
        $own_type_name = $own->getFieldTypeName();
        $own_name      = $own->getName();

        if($own_type_name === 'seo')
        {
            if($value === null)
            {
                $value = '';
            }

            if(!is_string($value))
            {
                throw new InitException('Seo поле '.$own_name.' типа '.$own_type_name.' должно быть задано строкой!');
            }

            $field = Seo::firstOrNew(['entity_name' => $type_name, 'entity_id' => $id, 'name' => $own_name]);
        }
        else
        {
            throw new InitException('Seo не обрабатывает тип '.$type_name);
        }

        $field->value = $value;
        $field->save();
    }
55961
public function performStoreAfter(Model $model, $source, $value)
    {
        $relation = $this->resolveModelSource($model, $source);

        if ( ! ($relation instanceof Relation)) {
            throw new UnexpectedValueException("{$source} did not resolve to relation");
        }

        // Any singular relations are unexpected
        if (    $relation instanceof BelongsTo
            ||  $relation instanceof HasOne
            ||  $relation instanceof MorphOne
        ) {
            throw new UnexpectedValueException("{$source} is a single relation, expecting plural");
        }

        if (null === $value) {
            $value = [];
        }

        // Should not be used, since this is for singular relations..
        if ($relation instanceof BelongsToMany) {
            $relation->sync($value);
            return;
        }

        // For *One and *Many relations, we need to handle detachment for currently related models.
        if (    $relation instanceof HasOne
            ||  $relation instanceof HasMany
            ||  $relation instanceof MorphOne
            ||  $relation instanceof MorphMany
        ) {
            // Detach only the models that shouldn't stay attached (ie. aren't in the new value array)

            /** @var Collection|Model[] $currentlyRelated */
            $currentlyRelated = $relation->get();
            $currentlyRelated = $currentlyRelated->filter(function (Model $model) use ($value) {
                return ! in_array($model->getKey(), $value);
            });

            $this->detachRelatedModelsForOneOrMany($currentlyRelated, $relation);
        }

        // For HasMany, the related models must be found,
        // and then they should be saved on the relation.
        $relatedModels = $this->getModelsByKey($relation->getRelated(), $value);

        if ( ! count($relatedModels)) return;

        if (    $relation instanceof HasOne
            ||  $relation instanceof HasMany
            ||  $relation instanceof MorphOne
            ||  $relation instanceof MorphMany
        ) {
            foreach ($relatedModels as $relatedModel) {
                $relation->save($relatedModel);
            }
            return;
        }

        throw new UnexpectedValueException(
            'Unexpected relation class ' . get_class($relation) . " for {$source}"
        );
    }
209744
public function setNewValue(string $field, $value) : void
    {
        $change = $this->objectChangeSet->getFieldChange($field);

        if ($change !== null) {
            $change->setNewValue($value);
        } else {
            $this->objectChangeSet->addChange(new Change($field, null, $value));
        }
    }
1015067
public function add($value)
    {
        if (!$value instanceof Contact) {
            throw new InvalidArgumentException(
                sprintf(
                    '%s only accepts instances of %s.',
                    __FUNCTION__, Contact::class
                )
            );
        }

        return parent::add($value);
    }