Returns the encryption mode for the given entity

@param $entity

@return ClassMetadata
195469
private function getEncryptionMode($entity)
    {
        $className = ClassUtils::getClass($entity);
        $classMetadata = $this->metadataFactory->getMetadataFor($className);

        return $classMetadata->encryptionMode;
    }
475090
public function getDocumentIndex($entity)
    {
        $annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);
        if (!$annotation instanceof Document) {
            return null;
        }

        $indexHandler = $annotation->indexHandler;
        if ($indexHandler != '' && method_exists($entity, $indexHandler)) {
            return $entity->$indexHandler();
        }

        return $annotation->getIndex();
    }
1000854
public static function dicionario(string $entity = null)
    {
        if(file_exists(PATH_HOME . "entity/cache") && (empty($entity) || file_exists(PATH_HOME . "entity/cache/{$entity}.json"))) {
            if(empty($entity)){

                //read all dicionarios
                $list = [];
                foreach (\Helpers\Helper::listFolder(PATH_HOME . "entity/cache") as $json) {
                    if(preg_match('/^\w+\.json$/i', $json)){
                        $entity = str_replace('.json', '', $json);
                        if($dic = self::dicionario($entity))
                            $list[$entity] = $dic;
                    }
                }

                return $list;

            } else {

                //read dicionario específico
                $setor = empty($_SESSION['userlogin']['setor']) ? 0 : $_SESSION['userlogin']['setor'];
                $entidadesNaoPermitidas = \Config\Config::getEntityNotAllow();
                $entidadesNaoPermitidas = isset($entidadesNaoPermitidas[$setor]) ? $entidadesNaoPermitidas[$setor] : [];

                if(!in_array($entity, $entidadesNaoPermitidas)) {
                    return \Entity\Metadados::getDicionario($entity, true, true);
                }
            }
        }

        return null;
    }
367724
private function encryptSymmetricKeyWithSystemKey($clearKey, $entity)
    {
        $publicMasterKey = $this->keyStore->getPublicMasterKey();
        $symmetricKey = new SymmetricKey();
        $encryptedKey = base64_encode($this->cryptographyProvider->encryptWithPublicKey($clearKey, $publicMasterKey));
        $symmetricKey->addSystemKey($encryptedKey);

        return $symmetricKey;
    }
642349
protected function getEntityTable($entity)
    {
        if (!$entity instanceof EntityInterface) {
            $entity = $this->getEntityClass($entity);
        }
        return $this->tablePrefix . $entity::getTable() . $this->tableSuffix;
    }
1076569
public function mapEntity(Entity $entity) {
		$entity['_loc'] = $this->_table->getUrl($entity);
		$entity['_lastmod'] = $entity->{$this->_config['lastmod']};
		$entity['_changefreq'] = $this->_config['changefreq'];
		$entity['_priority'] = $this->_config['priority'];

		return $entity;
	}
1241525
protected function getEntityKey($entity)
    {
        $keyName = Manager::getMapper($entity)->getEntityMap()->getKeyName();

        $wrapper = $this->factory->make($entity);

        return $wrapper->getEntityAttribute($keyName);
    }
147312
public function getEntityId($entity)
    {
        $entityId = $this->idAccessorRegistry->getEntityId($entity);

        if (is_array($entityId)) {
            ksort($entityId);
            $entityId = json_encode($entityId);
        }

        return $entityId;
    }
1153357
public function getEntityClassFull($entity)
    {
        $entity = $this->toString($entity);

        if (isset($this->cache[$entity])) {
            return $entity;
        }

        if ($this->managed || $this->isManagedByDoctrine($entity)) {
            /** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetaData */
            $classMetaData        = $this->entityManager->getClassMetadata($entity);
            $entity               = $classMetaData->getName();
            $this->cache[$entity] = ['metadata' => $classMetaData];
            $this->managed        = false;
        } else {
            $this->cache[$entity] = [];
        }

        return $entity;
    }
234225
public function getPositionFieldByEntity($entity)
    {
        if (is_object($entity)) {
            $entity = ClassUtils::getClass($entity);
        }

        if (isset($this->positionField['entities'][$entity])) {
            return $this->positionField['entities'][$entity];

        } else {
            return $this->positionField['default'];
        }
    }
649483
protected function storeEntity($entity)
    {
        $this->checkEntityType($entity);

        $store = new Store($this->aggregate($entity), $this->newQueryBuilder());

        return $store->execute();
    }
1332072
public function getStableVersion(DocumentationEntity $entity)
    {
        foreach ($this->getEntities() as $check) {
            if ($check->getKey() == $entity->getKey()) {
                if ($check->getLanguage() == $entity->getLanguage()) {
                    if ($check->getIsStable()) {
                        return $check;
                    }
                }
            }
        }

        return $entity;
    }
710471
public function getConfigFromEntity($entity) {
        $parameters = array();
        $parameters['_onlyConf'] = true;
        return $this->generate($entity,null,$parameters);
    }
462378
protected function getEntityManager($entity)
    {
        if (!is_null($this->connection)) {
            return $this->registry->getManager($this->connection);
        }

        if (substr($entity, 0, 1) === '\\') {
            $entity = substr($entity, 1);
        }

        $em = $this->registry->getManagerForClass($entity);

        if ($em === null) {
            throw new InvalidArgumentException(sprintf("No Entity Manager could be found for [%s].", $entity));
        }

        return $em;
    }
536796
public function getLevel($entity)
    {
        $primaryKey = $this->_getPrimaryKey();
        $id = $entity;
        if ($entity instanceof EntityInterface) {
            $id = $entity->get($primaryKey);
        }
        $config = $this->getConfig();
        $entity = $this->_table->find('all')
            ->select([$config['left'], $config['right']])
            ->where([$primaryKey => $id])
            ->first();

        if ($entity === null) {
            return false;
        }

        $query = $this->_table->find('all')->where([
            $config['left'] . ' <' => $entity[$config['left']],
            $config['right'] . ' >' => $entity[$config['right']],
        ]);

        return $this->_scope($query)->count();
    }
1207977
private function createMapper($entity)
    {
        $mapper = new EntityMapper();
        $mapper->setAdapter(
            $this->adapters->get(
                $this->getAdapterAlias($entity)
            )
        )
            ->setEntityClassName($entity);
        $this->mappers->set($entity, $mapper);
        return $mapper;
    }
797192
private function decryptSymmetricKey($entity)
    {
        $decryptedKey = null;

        $encryptionMode = $this->getEncryptionMode($entity);
        switch ($encryptionMode) {
            case EncryptionService::MODE_PER_USER_SHAREABLE:
                $decryptedKey = $this->decryptSymmetricKeyWithUserKey($entity);
                break;
            case EncryptionService::MODE_SYSTEM_ENCRYPTION:
                $decryptedKey = $this->decryptSymmetricKeyWithSystemKey($entity);
                break;
            default:
                throw new EncryptionException(sprintf('Encryption mode %s not supported.', $encryptionMode));
        }

        return $decryptedKey;
    }