@param \Closure|string $entityClass
@param string          $rel
@param HalDocument     $halDocument

@return HalResources
962243
public static function deserializeResources($entityClass, string $rel, HalDocument $halDocument): HalResources
    {
        if ($halDocument->hasEmbedded($rel)) {
            $resources = array_map(function (HalDocument $embeddedDocument) use ($entityClass) {
                return self::deserializeResource($entityClass, $embeddedDocument);
            }, $halDocument->getEmbedded($rel));
        } else {
            $resources = [];
        }

        $data = $halDocument->getData();
        if (array_key_exists('page', $data)) {
            return new HalPagedResources($resources, $halDocument->getLinks(), new HalPageMetadata(
                $data['page']['number'],
                $data['page']['size'],
                $data['page']['totalElements'],
                $data['page']['totalPages']
            ));
        }

        return new HalResources($resources, $halDocument->getLinks());
    }
83738
public function getByEntity($entityClass, $id, $locale, $object = null)
    {
        if (!$object) {
            $object = $this->documentManager->find($id, $locale);
        }

        $pageNumber = $object->getPageNumber();
        if ($object instanceof ArticlePageDocument) {
            // the article contains the seo/excerpt data and the controller handles the page-number automatically
            $object = $object->getParent();
        }

        $metadata = $this->structureMetadataFactory->getStructureMetadata('article', $object->getStructureType());

        // this parameter should not be used
        // but the sulu-collector for the profiler needs it to determine data from request
        $structure = $this->structureManager->wrapStructure('article', $metadata);
        $structure->setDocument($object);

        return [
            'object' => $object,
            'view' => $metadata->view,
            'pageNumber' => $pageNumber,
            'structure' => $structure,
            '_cacheLifetime' => $this->getCacheLifetime($metadata),
            '_controller' => $metadata->controller,
        ];
    }
279054
protected function loadResource(string $entityClass, string $url)
    {
        $resource = $this->restClient->getResource($entityClass, $url);

        return $resource->getEntity();
    }
593145
private function processEntities($entities, $operation, callable $callback, $entityClass = null)
    {
        $filterByEntityClass = !empty($entityClass);

        foreach ($entities as $entity) {
            if (!$filterByEntityClass || $entity instanceof $entityClass) {
                $callback($entity, $operation);
            }
        }

        return $this;
    }
1275518
private function getSlugsMetadata($entityClass)
    {
        if (!isset($this->slugsMetadata[$entityClass])) {
            $meta = $this->extendedMetadataFactory->getExtendedMetadata($entityClass);

            if (!isset($meta['slugs']) || empty($meta['slugs'])) {
                $message = sprintf(
                    'At least one property of class "%s" must be annotated with "%s" annotation in order to generate slug.',
                    $entityClass,
                    Slug::class
                );

                throw new SluggableException($message);
            }

            $this->slugsMetadata[$entityClass] = $meta['slugs'];
        }

        return $this->slugsMetadata[$entityClass];
    }
532521
public function setRel(string $rel)
    {
        $rels = [
            'alternate',
            'author',
            'bookmark',
            'help',
            'license',
            'next',
            'nofollow',
            'noreferrer',
            'prefetch',
            'prev',
            'search',
            'tag'
        ];

        if (! in_array($rel, $rels)) {
            Throw new ElementException('Not valid rel attribute');
        }

        $this->attribute['rel'] = $rel;

        return $this;
    }
825108
public function fromType(string $entityClass, string $tableName = null)
    {
        $this->from($this->orm->getEntityMapper($entityClass, $tableName));
    }
1231113
public function setEntityArguments($entityClass, array $arguments)
    {
        $this->entityArguments[$this->getEntityClass($entityClass)] = $arguments;
        return $this;
    }
1284526
public function getResource($rel)
    {
        $resources = $this->getResources();

        if (isset($resources[$rel])) {
            return $resources[$rel];
        }

        return null;
    }
388674
private ClassRecord getClassRecord(EntityIdValue entityIdValue) {
		if (!this.classRecords.containsKey(entityIdValue)) {
			ClassRecord classRecord = new ClassRecord();
			this.classRecords.put(entityIdValue, classRecord);
			return classRecord;
		} else {
			return this.classRecords.get(entityIdValue);
		}
	}
36137
public static function createEntities($entityClass, $dataArray)
    {
        return array_map(function ($data) use ($entityClass) {
            return static::createEntity($entityClass, $data);
        }, $dataArray);
    }
490198
public static function createFor($entityClass, $collectionPropertyName, DCPackage $dc) {
    $entityMeta = $dc->getEntityMeta($entityClass);
    $property = $entityMeta->getPropertyMeta($collectionPropertyName);
    $collectionClass = $property->getRelationEntityClass();
    
    $synchronizer = new static(
      $entityMeta,
      $property->getName(),
      new UniqueEntityHydrator($dc->getEntityManager()->getRepository($collectionClass->getFQN())),
      new EntityFactory($dc->getEntityMeta($collectionClass->getFQN()))
    );
    
    return $synchronizer;
  }
478744
protected static function prepareManyToMany(&$ret, $instance, $member, $annot = null) {
		$class = get_class ( $instance );
		if (! isset ( $annot )) {
			$annot = OrmUtils::getAnnotationInfoMember ( $class, "#ManyToMany", $member );
		}
		if ($annot !== false) {
			$key = $annot ["targetEntity"] . "|" . $member . "|" . $annot ["inversedBy"] . "|";
			if (! isset ( $ret [$key] )) {
				$parser = new ManyToManyParser ( $instance, $member );
				$parser->init ( $annot );
				$ret [$key] = $parser;
			}
			$accessor = "get" . ucfirst ( $ret [$key]->getMyPk () );
			if (method_exists ( $instance, $accessor )) {
				$fkv = $instance->$accessor ();
				$ret [$key]->addValue ( $fkv );
			}
		}
	}
15838
protected function generateFileContent($class, $entity)
    {
        $generator  = new FileGenerator();
        $descriptor = $entity->getFileDescriptor();

        $generator->setClass($class);
        $generator->setDocblock(DocBlockGenerator::fromArray(array(
            'shortDescription' => 'Generated by Protobuf protoc plugin.',
            'longDescription'  => 'File descriptor : ' . $descriptor->getName(),
        )));

        return $generator->generate();
    }
60734
public function createCopyForm($entity, $entityClass)
    {
        return $this->createIdForm($entity, 'copy_', $this->adminRouter->generate($entity, $entityClass, AdminRouter::TYPE_COPY));
    }
683289
private function parseDescription($filename, $entityClass)
    {
        $parser = new XmlParser();

        $parser->open($filename);

        /** @var EntityStructure $definition */
        $definition = $parser->parse([
            'onBeforeEntity'   => [$this, 'prepareEntity'],
            'onAfterEntity'    => [$this, 'handleEntity'],
            'onAfterField'     => [$this, 'handleField'],
            'onBeforeOption'   => [$this, 'prepareOption'],
            'onAfterOption'    => [$this, 'handleOption'],
            'onBeforeFieldset' => [$this, 'prepareFieldset'],
            'onAfterFieldset'  => [$this, 'handleFieldset'],
        ], $this->locator);

        return $definition;
    }
928597
public static function getCodeGenerators($entityClass = null)
    {
        if ($entityClass) {
            if (!isset(self::$generators[$entityClass])) {
                throw new \Exception("There is no registered entity code generator for class $entityClass");
            }

            return self::$generators[$entityClass];
        } else {
            return self::$generators;
        }
    }