Performs basic checks in entity name.

@param string $entity

@return string

@throws \InvalidArgumentException
193611
public static function validate($entity)
    {
        if (Kernel::VERSION_ID >= 40000) {
            $classFound = class_exists($entity, true);

            if (!$classFound) {
                throw new \InvalidArgumentException(sprintf('Entity "%s" was not found', $entity));
            }

            return $entity;
        }

        if (!preg_match('{^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*:[a-zA-Z0-9_\x7f-\xff\\\/]+$}', $entity)) {
            throw new \InvalidArgumentException(sprintf('The entity name isn\'t valid ("%s" given, expecting something like AcmeBlogBundle:Blog/Post)', $entity));
        }

        return $entity;
    }
598098
public function getTable($entity)
    {
        if (array_key_exists($entity, $this->customTables)) {
            return $this->prefix.$this->customTables[$entity];
        }

        return null;
    }
1120449
private function getTranslatableEntityConfiguration($entity)
    {
        $entityNamespace = get_class($entity);
        $classStack = $this->getNamespacesFromClass($entityNamespace);

        foreach ($classStack as $classNamespace) {
            if (array_key_exists($classNamespace, $this->translationConfiguration)) {
                return $this->translationConfiguration[$classNamespace];
            }
        }

        return null;
    }
401428
public function getEntityClassShort($entity)
    {
        $cacheKey = 'short';
        $entity   = $this->getEntityClassFull($entity);
        $short    = $this->getFromCache($entity, $cacheKey);

        if (false !== $short) {
            return $short;
        }

        foreach ($this->entityManager->getConfiguration()->getEntityNamespaces() as $short => $full) {
            if (false === strpos($entity, $full)) {
                continue;
            }

            $short .= ':'.ltrim(str_replace($full, '', $entity), '\\');
            $this->cache[$full][$cacheKey] = $short;

            return $short;
        }

        return $entity;
    }
61377
protected function _getTableEntity($entity = '') {
        /** @var $class \Gcs\Framework\Core\Orm\Entity\Entity */

        $entity = ucfirst(preg_replace_callback("/(?:^|_)([a-z])/", function ($matches) {
            return strtoupper($matches[1]);
        }, $entity));

        $className = '\Orm\Entity\\' . ucfirst($entity);

        if (class_exists($className)) {
            return self::Entity()->$entity();
        }
        else {
            throw new MissingEntityException('The Entity ' . $entity . ' does not exist');
        }
    }
879340
public function stashEntity($entity)
    {
        $className = $this->getClassName($entity);
        $entityId  = $this->getEntityId($entity);

        if (!isset($this->stashedEntities[$className])) {
            $this->stashedEntities[$className] = [];
        }

        $this->stashedEntities[$className][$entityId] = $entity;
    }
188923
public function getAdminType($entity)
    {
        if (null !== $this->type) {
            return $this->type;
        }

        if (method_exists($entity, 'getAdminType')) {
            return $entity->getAdminType();
        }

        throw new InvalidArgumentException(
            'You need to implement the getAdminType method in '.
            get_class($this).' or '.get_class($entity)
        );
    }
649483
protected function storeEntity($entity)
    {
        $this->checkEntityType($entity);

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

        return $store->execute();
    }
983650
private function hashEntity($entity)
    {
        $class = ClassUtils::getClass($entity);

        $ids = $this->em->getClassMetadata($class)->getIdentifierValues($entity);

        return $class.spl_object_hash($entity).reset($ids);
    }
166593
protected function HLGetIdByCode($entity)
    {
        $filter = [
            'filter' => ['=NAME' => $entity],
        ];
        $hlblock = HighloadBlockTable::getRow($filter);

        return !empty($hlblock['ID']) ? $hlblock['ID'] : null;
    }
925063
public function update($entity)
    {
        if (!$entity instanceof $this->entityClass) {
            throw new \InvalidArgumentException(
                "The entity to be updated must be an instance of {$this->entityClass}."
            );
        }

        $entityId = $entity->id;
        $data = $entity->toArray();
        unset($data['id']);

        return $this->adapter->update($this->entityTable, $data, "id = $entityId");
    }
1323694
protected function _getEntityClassName($entity)
    {
        if (is_object($entity)) {
            $className = get_class($entity);
        } else {
            $className = $entity;
        }
        return $className;
    }
924539
public function getRepository($entity)
    {
        $annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);

        if ($annotation instanceof Document) {
            return $annotation->repository;
        }

        return '';
    }
1356531
public function createUseCaseDiagrammFor($entity)
    {
        if (is_int($entity)) {
            $entity = $this->getById($entity);
        } elseif (!$entity instanceof UseCaseEntity) {
            throw new \InvalidArgumentException('Unkown entity data type "' . gettype($entity) . '"');
        }

        $diagrammService = $this->getDiagrammService();

        return $diagrammService->createDiagrammFromNodes(array($entity), UseCaseDiagramm::TYPE_USE_CASE);
    }
941459
private function getAdapterAlias($entity)
    {
        $descriptor = EntityDescriptorRegistry::getInstance()
            ->getDescriptorFor($entity);
        return $descriptor->getAdapterAlias()
            ? $descriptor->getAdapterAlias()
            : 'default';
    }
467947
public function serialize($entity)
    {
        return array($this->getName().'.'.$this->_parent_key => $entity->get($this->_parent_key));
    }
1349610
public function generateBody(Entity $entity)
    {
        $lines      = [];
        $descriptor = $entity->getDescriptor();
        $class      = $entity->getNamespacedName();
        $fields     = $descriptor->getFieldList() ?: [];
        $message    = var_export("Argument 1 passed to %s must be a %s, %s given", true);
        $exception  = 'sprintf(' . $message . ', __METHOD__, __CLASS__, get_class($message))';

        $lines[] = 'if ( ! $message instanceof ' . $class . ') {';
        $lines[] = '    throw new \InvalidArgumentException(' . $exception . ');';
        $lines[] = '}';
        $lines[] = null;

        foreach ($fields as $field) {
            $item  = $this->generateFieldMerge($entity, $field);
            $lines = array_merge($lines, $item);
        }

        return $lines;
    }