@param $entity

@return array
969254
public function validate($entity)
    {
        $errors = $this->validator->validate($entity);

        $dataErrors = [];

        /** @var ConstraintViolation $error */
        foreach ($errors as $error) {
            if (!isset($dataErrors[$error->getPropertyPath()])) {
                $dataErrors[$error->getPropertyPath()] = [];
            }

            $dataErrors[$error->getPropertyPath()][] = $error->getMessage();
        }

        return $dataErrors;
    }
1126274
public function segments($entity) {
		$result = [];

		if (strpos($entity->name, '::') !== false) {
			list($class, $child) = explode('::', $entity->name, 2);
			$result[$entity->name] = $child;
			$result[] = '::';
		} else {
			$class = $entity->name;
		}
		$parts = explode('/', $class);
		while ($parts) {
			$result[implode('/', $parts)] = end($parts);

			array_pop($parts);
			if ($parts) {
				$result[] = '\\';
			}
		}
		return array_reverse($result);
	}
388931
public function getThumbnails(FileStorage $entity) : array
    {
        $versions = (array)Configure::read('FileStorage.imageHashes.file_storage');
        if (empty($versions)) {
            return [];
        }

        $result = [];
        foreach (array_keys($versions) as $version) {
            $result[$version] = $this->getThumbnail($entity, (string)$version);
        }

        return $result;
    }
940206
private function readClassProperties($entity)
    {
        $className = get_class($entity);
        if (isset($this->entityProperties[$className])) {
            return $this->entityProperties[$className];
        }

        $reflectionClass = new \ReflectionClass($entity);
        $inheritedProperties = array_merge($this->getParentProperties($reflectionClass), $reflectionClass->getProperties());

        $properties = [];
        foreach ($inheritedProperties as $property) {
            $properties[$property->getName()] = $property;
        }

        $this->entityProperties[$className] = $properties;

        return $properties;
    }
471958
public function unmapEntity(Entity $entity)
    {
        $output = [];
        foreach ($entity->getData() as $name => $value) {

            $property = $entity::getReflection()->getProperty($name);

            // Skip associations & readonly & disabled mapping
            if ($property->hasOption(Reflection\Property\Option\Assoc::KEY)
                || !$property->isWritable()
                || ($property->hasOption(Reflection\Property\Option\Map::KEY)
                    && !$property->getOption(Reflection\Property\Option\Map::KEY))
            ) {
                continue;
            }

            $output[$property->getUnmapped()] = $this->unmapValue($property, $value);
        }
        return $output;
    }
722791
public function getData(Entity $entity)
    {
        $column = $this->analyzer->listColumns();
        $data = array();

        foreach ($column as $key => $value) {
            $method = 'get' . Utils::capitalize($key);
            $data[$key] = $entity->$method();
            if (is_null($data[$key])) $data[$key] = array();
            if ($data[$key] instanceof ArrayCollection) $data[$key] = $data[$key]->toArray();
        }

        $data['objectclass'] = $entity->getObjectClass()->toArray();

        return $data;
    }
783985
public function getDescriptorFor($entity)
    {
        return $this->descriptors->containsKey($entity)
            ? $this->descriptors->get($entity)
            : $this->createDescriptor($entity);
    }
369056
protected function generateMethods(Entity $entity)
    {
        $result     = [];
        $descriptor = $entity->getDescriptor();
        $methods    = $descriptor->getMethodList() ?: [];

        foreach ($methods as $method) {
            $result[] = $this->generateMethod($entity, $method);
        }

        return $result;
    }
1003907
public function getValidatorFor($entity)
    {
        $rules = $this->getEntityRulesFor($entity);

        return $this->validator->make($this->extract($entity), $rules->rules($entity), $rules->messages());
    }
813107
public function getOriginalEntityData($entity)
    {
        $oid = spl_object_hash($entity);

        if (isset($this->originalEntityData[$oid])) {
            return $this->originalEntityData[$oid];
        }

        return array();
    }
799198
private function getOriginalEntityData($entity)
    {
        $class = $this->em->getClassMetadata(\get_class($entity));
        $data = $this->uow->getOriginalEntityData($entity);
        if ($class->isVersioned) {
            $versionField = $class->versionField;
            $data[$versionField] = $class->reflFields[$versionField]->getValue($entity);
        }

        return $data;
    }
112081
public function getUserNames($entity)
    {
        $users = $this->getDoctrine()->getRepository($entity)->findBy(
            [
                'enabled' => true,
            ],
            [
                'id' => 'asc',
            ]
        );

        return CollectionUtility::get('username', $users);
    }
137459
private function getEntityIdentifierValue($entity)
    {
        $entityMetaData = $this->entityManager->getEntityMetadataRegister()->getEntityMetadata($entity);

        return $entityMetaData ? $entityMetaData->getIdentifierValue() : null;
    }
1338198
public function getExceptionsFromEntityConfig($entity)
  {
    $exceptions = [];

    foreach ($entity->requests as $request)
    {
      foreach ($request as $action)
      {
        if (isset($action->throws))
        {
          $exceptions[] = $action->throws;
        }
      }
    }

    return $exceptions;
  }
125467
protected function _getOldValues(Entity $entity)
    {
        $config = $this->getConfig();
        $fields = array_merge($config['scope'], [$config['order']]);

        $values = [];
        foreach ($fields as $field) {
            if ($entity->isDirty($field)) {
                $values[$field] = $entity->getOriginal($field);
            } elseif ($entity->has($field)) {
                $values[$field] = $entity->get($field);
            }
        }

        if (count($fields) != count($values)) {
            $primaryKey = $entity->get($this->_table->getPrimaryKey());
            $entity = $this->_table->get($primaryKey, ['fields' => $fields]);
            $values = $entity->extract($fields);
        }

        $order = $values[$config['order']];
        unset($values[$config['order']]);

        return [$order, $values];
    }
1282616
protected function _getPartsFromEntity($entity)
    {
        $parts = [];
        foreach ((array)$this->getConfig('displayField') as $displayField) {
            $value = Hash::get($entity, $displayField);

            if ($value === null && !$entity->isNew()) {
                return [];
            }

            if (!empty($value) || is_numeric($value)) {
                $parts[] = $value;
            }
        }

        return $parts;
    }
317557
public function getEntityRulesFor($entity)
    {
        $class = is_object($entity) ? ClassUtils::getClass($entity) : $entity;

        if (null === $rules = $this->ruleMappings->get($class)) {
            throw ValidationConfigurationException::noEntityRulesMappingExists($class);
        }

        return $rules;
    }