Gets an entity by its id

@param mixed $entityId

@return EntityInterface|null
485110
public function get($entityId)
    {
        $key = $this->getEntityDescriptor()->className();
        $key .= '::'.$entityId;
        $entity = $this->getIdentityMap()->get($key, false);
        if ($entity === false) {
            $entity = $this->load($entityId);
        }
        return $entity;
    }
341799
public function findByEntityId($entityId, $entityType)
    {
        $item = $this->model->where('entity_type', $entityType)->where('entity_id', $entityId)->first();

        if ($item && ($item->data->is_published == 1 || $item->data->is_published == 'on') && $item->data->published_at <= Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s')) {
            return $item->data;
        }

        return null;
    }
73652
public function getMedia($mediaId)
    {
        $em = $this->getEntityManager();

        $media = $em->getRepository('VictoireMediaBundle:Media')->find($mediaId);
        if (!$media) {
            throw new EntityNotFoundException('The id given for the media is not valid.');
        }

        return $media;
    }
849550
public function fetchProduct($productId)
    {
        /** @var ProductInterface $product */
        $product = $this->getProductRepository()->find($productId);
        if (!$product) {
            throw new EntityNotFoundException($this->getProductRepository()->getClassName(), $productId);
        }

        return $product;
    }
1343134
public function findOrderEntityById($id)
    {
        try {
            return $this->em
                ->getRepository(static::$orderEntityName)
                ->find($id);
        } catch (NoResultException $nre) {
            throw new EntityNotFoundException(static::$orderEntityName, $id);
        }
    }
962535
public static function getEntityClassFromObjectID($objectID)
    {
        $type = explode('::', $objectID)[0];

        if (in_array($type, static::getEntities(), true)) {
            return $type;
        }

        throw new EntityNotFoundInObjectID("Entity class from ObjectID {$objectID} not found.");
    }
263808
private function getContact($id)
    {
        $contact = $this->contactManager->findById($id);

        if (!$contact) {
            throw new EntityNotFoundException($this->contactManager->getContactEntityName(), $id);
        }

        return $contact;
    }
573648
public function getEntity($id = null)
    {
        if (null === $id) {
            $entity           = new ContactSource();
            $defaultUtmSource = $this->getRepository()->getDefaultUTMSource();
            $entity->setUtmSource($defaultUtmSource);

            return $entity;
        }

        if ('clone' == $this->dispatcher->getContainer()->get('request')->attributes->get('objectAction')) {
            $entity           = parent::getEntity($id);
            $defaultUtmSource = $this->getRepository()->getDefaultUTMSource();
            $entity->setUtmSource($defaultUtmSource);

            return $entity;
        }

        return parent::getEntity($id);
    }
789240
public function findOrderStatusById($statusId)
    {
        try {
            return $this->em
                ->getRepository(self::$orderStatusEntityName)
                ->find($statusId);
        } catch (NoResultException $nre) {
            throw new EntityNotFoundException(self::$orderStatusEntityName, $statusId);
        }
    }
834038
public function find($entityId)
    {
        $this->preFind($entityId);
        $entity = $this->doFind($entityId);
        $this->postFind($entity);

        return $entity;
    }
1122199
private function createEntityID(string $id): EntityID
    {
        return new EntityID($this->entityManager, $this->className, $id);
    }
1022574
public static function gets($data = [], Entity $entity = null)
    {
        if (!$entity) {
            $entity = (new static)->getEntity();
        }

        if (is_scalar($data)) {
            return $entity->where('id', $data)->one();
        } else {
            return $entity->whereArr($data)->one();
        }
    }
807411
public function getUserTypeEntity($entityId, $fieldName) {
        /** @noinspection PhpDynamicAsStaticMethodCallInspection */
        $item = \CUserTypeEntity::GetList(array(), array(
            'ENTITY_ID' => $entityId,
            'FIELD_NAME' => $fieldName
        ))->Fetch();

        return (!empty($item)) ? $this->getUserTypeEntityById($item['ID']) : false;
    }
831910
public function find(
        string $entityNamespace,
        $id
    ) {
        return $this
            ->getObjectRepository($this->locateEntity($entityNamespace))
            ->find($id);
    }
131142
protected function _getUserEntity($userId) {
		if (is_a($userId, EntityInterface::class)) {
			return $userId;
		}

		if (is_string($userId) || is_integer($userId)) {
			$entity = $this->UserTable->newEntity();

			return $this->UserTable->patchEntity(
				$entity,
				[$this->UserTable->primaryKey() => $userId],
				['guard' => false]
			);
		}

		if (is_array($userId)) {
			$entity = $this->UserTable->newEntity();

			return $this->UserTable->patchEntity(
				$entity,
				$userId,
				['guard' => false]
			);
		}
	}
993144
protected function getCache($documentId)
    {
        if (isset($this->cache[$documentId])) {
            return $this->cache[$documentId];
        }

        return null;
    }
688231
protected function lookUpEntity($entityId) {
        $entity = $this->generateEntity();
        $entityInstance = $entity->findFirst($entityId);
        if($entityInstance === false) {
            throw new Exception("Invalid Entity Id: Entity not found.", 404);
        }
        return $entityInstance;
    }