protected function lookupEntity(
        string $entity_class,
        int $entity_id,
        string $production_slug
    ): array {
        // Lookup the production by production_slug.
        $production_repo = $this->em->getRepository(Production::class);
        if (null === $production = $production_repo->findOneBy(['slug' => $production_slug])) {
            throw new NotFoundHttpException();
        }

        // Lookup the entity by id.
        $entity_repo = $this->em->getRepository($entity_class);
        if (null === $entity = $entity_repo->findOneBy(['id' => $entity_id])) {
            throw new NotFoundHttpException();
        }

        // Ensure entity is within production.
        if (!$entity->hasGroup($production)) {
            throw new NotFoundHttpException();
        }

        // Return the entity and the production.
        return [$entity, $production];
    }
protected function lookupEntity(
        string $entity_class,
        int $entity_id,
        string $production_slug
    ): array {
        // Lookup the production by production_slug.
        $production_repo = $this->em->getRepository(Production::class);
        if (null === $production = $production_repo->findOneBy(['slug' => $production_slug])) {
            throw new NotFoundHttpException();
        }

        // Lookup the entity by id.
        $entity_repo = $this->em->getRepository($entity_class);
        if (null === $entity = $entity_repo->findOneBy(['id' => $entity_id])) {
            throw new NotFoundHttpException();
        }

        // Ensure entity is within production.
        if (!$entity->hasGroup($production)) {
            throw new NotFoundHttpException();
        }

        // Return the entity and the production.
        return [$entity, $production];
    }
protected function lookupEntity ( string $ entity_class , int $ entity_id , string $ production_slug ) : array { // Lookup the production by production_slug. $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'slug' => $ production_slug ] ) ) { throw new NotFoundHttpException ( ) ; } // Lookup the entity by id. $ entity_repo = $ this -> em -> getRepository ( $ entity_class ) ; if ( null === $ entity = $ entity_repo -> findOneBy ( [ 'id' => $ entity_id ] ) ) { throw new NotFoundHttpException ( ) ; } // Ensure entity is within production. if ( ! $ entity -> hasGroup ( $ production ) ) { throw new NotFoundHttpException ( ) ; } // Return the entity and the production. return [ $ entity , $ production ] ; }
Helper function that looks up entities for controllers.

Checks that entities are proper members of productions and throws not
found exceptions when they are not.

@param string $entity_class    The class to lookup the entity for.
@param int    $entity_id       The entity id.
@param string $production_slug The production slug.

@throws NotFoundHttpException If anything is not found.

@return array The production and the entity.
Helper function that looks up entities for controllers .