Returns fields that have been marked as protected.

@param \Cake\Datasource\EntityInterface $entity Entity
@return array
491575
public function fields(EntityInterface $entity)
    {
        $fields = [];
        foreach ((array)$this->getConfig('fields') as $field) {
            if (!$entity->isDirty($field)) {
                continue;
            }
            $fields[$field] = $entity->$field;
            $entity->setDirty($field, false);
        }

        return $fields;
    }
1292229
protected function _extractDirtyFields(EntityInterface $entity): array
    {
        $dirtyFields = [];
        $fields = array_keys($entity->toArray());
        $dirtyFields = $entity->extract($fields, true);
        unset($dirtyFields['modified']);

        return array_keys($dirtyFields);
    }
684593
public function getTimes(IdentifierInterface $entity)
    {
        $handle = $this->getTimerHandle($entity);
        $past = $this->localStorage->get($handle, []);

        return $past;
    }
251160
protected function _getRequestData(EntityInterface $entity)
    {
        $pk = (string)TableRegistry::get($entity->source())->primaryKey();
        $data = $this->_controller->request->data('comment');
        $return = [
            'parent_id' => null,
            'subject' => '',
            'body' => '',
            'status' => 'pending',
            'author_name' => null,
            'author_email' => null,
            'author_web' => null,
            'author_ip' => $this->_controller->request->clientIp(),
            'table_alias' => $this->_getTableAlias($entity),
            'entity_id' => $entity->get($pk),
        ];

        if (!empty($this->_controller->request->data['comment'])) {
            $data = $this->_controller->request->data['comment'];
        }

        if ($this->_controller->request->is('userLoggedIn')) {
            $return['user_id'] = user()->id;
            $return['author_name'] = null;
            $return['author_email'] = null;
            $return['author_web'] = null;
        } else {
            $return['author_name'] = !empty($data['author_name']) ? h($data['author_name']) : null;
            $return['author_email'] = !empty($data['author_email']) ? h($data['author_email']) : null;
            $return['author_web'] = !empty($data['author_web']) ? h($data['author_web']) : null;
        }

        if (!empty($data['subject'])) {
            $return['subject'] = h($data['subject']);
        }

        if (!empty($data['parent_id'])) {
            // this is validated at Model side
            $return['parent_id'] = $data['parent_id'];
        }

        if (!empty($data['body'])) {
            $return['body'] = TextToolbox::process($data['body'], $this->config('settings.text_processing'));
        }

        if ($this->config('settings.auto_approve') ||
            $this->_controller->request->is('userAdmin')
        ) {
            $return['status'] = 'approved';
        }

        return $return;
    }
441651
public function getVersionId(EntityInterface $entity)
    {
        $table = TableRegistry::get($this->_config['versionTable']);
        $preexistent = $table->find()
            ->select(['version_id'])
            ->where([
                    'model' => $this->_config['referenceName']
                ] + $this->_extractForeignKey($entity))
            ->order(['id desc'])
            ->limit(1)
            ->enableHydration(false)
            ->toArray();

        return Hash::get($preexistent, '0.version_id', 0);
    }
621790
public function & getEntityChangeSet($entity)
    {
        $oid  = spl_object_id($entity);
        $data = [];

        if (! isset($this->entityChangeSets[$oid])) {
            return $data;
        }

        return $this->entityChangeSets[$oid];
    }
717833
protected function _handleFiles(EntityInterface $entity) {
		$files = $this->getConfig('file');
		if (is_string($files)) {
			$files = [$files => $this->getConfig('defaults')];
		}

		$results = [];
		foreach ($files as $key => $file) {
			if (is_string($key)) {
				$field = $key;
				$options = $this->getConfig('defaults');
				$options += $file;
			}
			if (is_string($file)) {
				$field = $file;
				$options = $this->getConfig('defaults');
			}
			$results[$field] = $this->saveFile($entity->{$field}, $options);
		}

		return $results;
	}
682471
protected function _prepareCachedColumns(EntityInterface $entity)
    {
        if ($this->config('cacheMap')) {
            foreach ((array)$this->config('cacheMap') as $column => $fields) {
                if (in_array($column, $entity->visibleProperties())) {
                    $string = $entity->get($column);
                    if ($string == serialize(false) || unserialize($string) !== false) {
                        $entity->set($column, unserialize($string));
                    } else {
                        $entity->set($column, new CachedColumn());
                    }
                }
            }
        }

        return $entity;
    }
586346
public function decodeItems(EntityInterface $entity) {
		$fields = $this->_getMappedFields();

		foreach ($fields as $map => $field) {
			$val = $entity->get($field);
			if ($this->isEncoded($val)) {
				$entity->set($map, $this->decoded);
			}
		}
	}
630801
private function getEntityEncryptedReflectionProperties($entity)
    {
        return DoctrineHelper::getPropertiesByAnnotation($this->getClassName($entity), Encrypted::class, $this->getReader());
    }
801971
public function getObjectAclEntriesAsArray($entity)
    {
        $result = array();
        foreach ($this->getObjectAclEntries($entity) as $aclEntry) {
            $result[] = new AclEntry($aclEntry->getSecurityIdentity());
        }
        return $result;
    }
125538
public function attachEntityFields(EntityInterface $entity)
    {
        $_fields = [];
        foreach ($this->_attributesForEntity($entity) as $attr) {
            $field = $this->_prepareMockField($entity, $attr);
            if ($entity->has($field->get('name'))) {
                $this->_fetchPost($field);
            }

            $field->fieldAttached();
            $_fields[] = $field;
        }

        $entity->set('_fields', new FieldCollection($_fields));

        return $entity;
    }
1309042
protected function getCurrent(EntityInterface $entity) {
		$conditions = $this->buildConditions($entity);

		return $this->_table->find()
			->where($conditions)
			->first();
	}
975938
protected function _getTableAlias(EntityInterface $entity)
    {
        $alias = $entity->source();
        if (mb_strpos($alias, '.') !== false) {
            $parts = explode('.', $alias);
            $alias = array_pop($parts);
        }

        return strtolower($alias);
    }
965895
public function serialize($entity)
    {
        return array($this->getName().'.'.$this->_target_parent_key => $entity->get($this->_target_parent_key));
    }
112207
protected function getOptions(FieldableEntityInterface $entity) {
    if (!isset($this->options)) {
      // Limit the settable options for the current user account.
      $options = $this->fieldDefinition
        ->getFieldStorageDefinition()
        ->getSetting('allowed_values');

      $module_handler = \Drupal::moduleHandler();
      $context = [
        'fieldDefinition' => $this->fieldDefinition,
        'entity' => $entity,
      ];
      $module_handler->alter('dropdown_list', $options, $context);

      array_walk_recursive($options, [$this, 'sanitizeLabel']);

      $this->options = $options;
    }
    return $this->options;
  }
161491
public function getEntityModel(EntityInterface $entity): string
    {
        $source = $entity->source();
        if (substr($source, -5) == 'Table') {
            $source = substr($source, 0, -5);
        }

        return $source;
    }