src/Model/Behavior/FootprintBehavior.php
protected function _injectEntity(EntityInterface $entity, ArrayObject $options, array $fields)
    {
        $new = $entity->isNew() !== false;

        foreach ($fields as $field => $when) {
            if (!in_array($when, ['always', 'new', 'existing'])) {
                throw new UnexpectedValueException(sprintf(
                    'When should be one of "always", "new" or "existing". The passed value "%s" is invalid',
                    $when
                ));
            }

            if ($entity->isDirty($field)) {
                continue;
            }

            if ($when === 'always' ||
                ($when === 'new' && $new) ||
                ($when === 'existing' && !$new)
            ) {
                $entity->set(
                    $field,
                    Hash::get(
                        $options,
                        $this->getConfig('propertiesMap.' . $field)
                    )
                );
            }
        }
    }
protected function _injectEntity(EntityInterface $entity, ArrayObject $options, array $fields)
    {
        $new = $entity->isNew() !== false;

        foreach ($fields as $field => $when) {
            if (!in_array($when, ['always', 'new', 'existing'])) {
                throw new UnexpectedValueException(sprintf(
                    'When should be one of "always", "new" or "existing". The passed value "%s" is invalid',
                    $when
                ));
            }

            if ($entity->isDirty($field)) {
                continue;
            }

            if ($when === 'always' ||
                ($when === 'new' && $new) ||
                ($when === 'existing' && !$new)
            ) {
                $entity->set(
                    $field,
                    Hash::get(
                        $options,
                        $this->getConfig('propertiesMap.' . $field)
                    )
                );
            }
        }
    }
protected function _injectEntity ( EntityInterface $ entity , ArrayObject $ options , array $ fields ) { $ new = $ entity -> isNew ( ) !== false ; foreach ( $ fields as $ field => $ when ) { if ( ! in_array ( $ when , [ 'always' , 'new' , 'existing' ] ) ) { throw new UnexpectedValueException ( sprintf ( 'When should be one of "always", "new" or "existing". The passed value "%s" is invalid' , $ when ) ) ; } if ( $ entity -> isDirty ( $ field ) ) { continue ; } if ( $ when === 'always' || ( $ when === 'new' && $ new ) || ( $ when === 'existing' && ! $ new ) ) { $ entity -> set ( $ field , Hash :: get ( $ options , $ this -> getConfig ( 'propertiesMap.' . $ field ) ) ) ; } } }
Injects configured field values into entity if those fields are not dirty.

@param \Cake\Datasource\EntityInterface $entity Entity.
@param \ArrayObject $options Options.
@param array $fields Field configuration.
@return void
Injects configured field values into entity if those fields are not dirty .