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)
                    )
                );
            }
        }
    }