@param $id
@param int $mode

@return mixed
@throws \Doctrine\ORM\NonUniqueResultException
776645
public function getPageThemeById($id, $mode = AbstractQuery::HYDRATE_OBJECT)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        /** @var $query \Doctrine\ORM\Query */

        $query = $qb->select('e, m')
            ->from($this->getEntity(), 'e')
            ->innerJoin('e.pageId', 'm')
            ->where('e.id = :id')
            ->setMaxResults(1)
            ->setParameter('id', $id)
            ->getQuery();

        return $query->getOneOrNullResult($mode);
    }
1147590
protected function getUrl($entity, $mode)
    {
        return $this->generateUrl($this->route_name.$mode, array('id' => $entity->getId()));
    }
1124850
public function getById($id)
    {
        $list = $this->getByCriteria($id, $this->getUniqueId());
        return reset($list);
    }
686232
public function deleteAction($id)
    {
        /** @var RouteRepositoryInterface $routeRespository */
        $routeRespository = $this->get('sulu.repository.route');

        $route = $routeRespository->find($id);
        if (!$route) {
            throw new EntityNotFoundException(RouteInterface::class, $id);
        }

        $entityManager = $this->get('doctrine.orm.entity_manager');
        $entityManager->remove($route);
        $entityManager->flush();

        return $this->handleView($this->view());
    }
53664
public function getModalDelete($id = null)
    {
        $confirm_route = $error = null;

        $title = 'Delete group';
        $message = 'Are you sure to delete this group?';

        // Get group information
        $group = Sentinel::getRoleRepository()->findOrFail($id);

        if ($group == null)
        {
            // Prepare the error message
            $error = Lang::get('base.groups.not_found');
            return View('layouts.modal_confirmation', compact('title', 'message', 'error', 'model', 'confirm_route'));
        }

        $confirm_route = route('delete/group', ['id' => $group->id]);
        return View('layouts.modal_confirmation', compact('title', 'message', 'error', 'model', 'confirm_route'));
    }
758840
public static function view_glossary($id, $mode) {
        $params = self::validate_parameters(self::view_glossary_parameters(), array(
            'id' => $id,
            'mode' => $mode
        ));
        $id = $params['id'];
        $mode = $params['mode'];
        $warnings = array();

        // Get and validate the glossary.
        list($glossary, $context, $course, $cm) = self::validate_glossary($id);

        // Trigger module viewed event.
        glossary_view($glossary, $course, $cm, $context, $mode);

        return array(
            'status' => true,
            'warnings' => $warnings
        );
    }
391088
public function loadOneById($id)
    {
        $stmt = $this->getMatchOneByIdCypher($id);
        $result = $this->_em->getDatabaseDriver()->run($stmt->text(), $stmt->parameters());
        $hydrator = $this->_em->getEntityHydrator($this->_className);
        $entities = $hydrator->hydrateAll($result);

        return count($entities) === 1 ? $entities[0] : null;
    }
281911
public function get($id)
    {
        if ($this->has($id) === false)
        {
            $message = (string) 'Class (%s) does not exists';

            throw new NotFoundException(sprintf($message, $id));
        }

        $reflection = new \ReflectionClass($id);

        if ($constructor = $reflection->getConstructor())
        {
            $arguments = $this->arguments($constructor);

            return $reflection->newInstanceArgs($arguments);
        }

        return new $id;
    }
855099
public function patchGalleryAction($id) {
        $manager = $this->get('doctrine_phpcr.odm.default_document_manager');
        $entity = $manager->getRepository('ToguMediaBundle:Gallery')->find($id);
        if ($entity === null) {
            return $this->handleView(View::create('', 404));
        }
        $content = json_decode($this->getRequest()->getContent(), true);
        $content['id'] = $id;
        $serializer = $this->get("tpg_extjs.phpcr_serializer");
        $dContext = DeserializationContext::create()->setGroups(array("Default", "patch"));
        $dContext->attributes->set('related_action', 'merge');
        $entity = $serializer->deserialize(
            json_encode($content),
            'Togu\MediaBundle\Document\Gallery',
            'json',
            $dContext
        );
        $validator = $this->get('validator');
        $validations = $validator->validate($entity, array('Default', 'patch'));
        if ($validations->count() === 0) {
            try {
                $manager->flush();
            } catch (DBALException $e) {
                return $this->handleView(
                    View::create(array('errors'=>array($e->getMessage())), 400)
                );
            }
            return $this->handleView(
                View::create(array(
                	"success" => true,
                	"records" => array($entity)
                ), 200)->setSerializationContext($this->getSerializerContext(array("get")))
            );
        } else {
            return $this->handleView(
                View::create(array('errors'=>$validations), 400)
            );
        }
    }
346296
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
    {
        // Check identity map first
        if ($entity = $this->xem->getUnitOfWork()->tryGetById($id, $this->class->rootXmlEntityName)) {
            if ($lockMode != LockMode::NONE) {
                $this->xem->lock($entity, $lockMode, $lockVersion);
            }

            return $entity; // Hit!
        }

        if ($lockMode == LockMode::NONE) {
            return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id);
        } else if ($lockMode == LockMode::OPTIMISTIC) {
            if (!$this->class->isVersioned) {
                throw OptimisticLockException::notVersioned($this->entityName);
            }
            $entity = $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id);

            $this->xem->getUnitOfWork()->lock($entity, $lockMode, $lockVersion);

            return $entity;
        } else {
            if (!$this->xem->getConnection()->isTransactionActive()) {
                throw TransactionRequiredException::transactionRequired();
            }

            return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id, null, null, array(), $lockMode);
        }
    }
232974
public function get($id)
    {
        \assert(\is_scalar($id), 'Invalid format of the entry identifier.');

        if (\array_key_exists($id, $this->values)) {
            return $this->values[$id];
        }

        if ($this->hasInProxy($id)) {
            return $this->container->get((string)$id);
        }

        throw new ContainerResolutionException(\sprintf('Entry with id %s not found', $id));
    }
1343134
public function findOrderEntityById($id)
    {
        try {
            return $this->em
                ->getRepository(static::$orderEntityName)
                ->find($id);
        } catch (NoResultException $nre) {
            throw new EntityNotFoundException(static::$orderEntityName, $id);
        }
    }
772210
public function getById($id)
    {
        $model = $this
            ->prepareQuery()
            ->where($this->model->getTable() . '.id', $id)
            ->first();

        if (empty($model))
            return null;

        $model = $this->addPermissionsForModel($model);

        return $this->formatModel($model);
    }
812442
protected function findOrFail($id)
    {
        $model = $this->model;
        if ($this->withTrashed()) {
            return $model::withTrashed()->findOrFail($id);
        } else {
            return $model::findOrFail($id);
        }
    }
819620
public function findOrderEntityById($id)
    {
        try {
            return $this->orderRepository->find($id);
        } catch (NoResultException $nre) {
            throw new EntityNotFoundException(static::$orderEntityName, $id);
        }
    }
751687
public Object get(Id id, Mode mode) {
        Object value = writeCache.get(id);
        if (value == null) {
            value = readCache.get(new CacheKey(id));
            if (value != null && Mode.WRITE.equals(mode)) {
                writeCache.put(id, value);
            }
        }
        return value;
    }
371081
public function getById($id)
    {
        $query = $this->createQuery();
        $query->where(
            $query->buildAndSet([$this->getModel()->getTableKey(), '=', $id])
        );
        $result = $this->database->query($query);

        $model = null;
        if ($result) {
            $result = $result->fetchAll(\PDO::FETCH_ASSOC);
            $entities = $this->handleResult($result);
            $model = current($entities);
        }
        return $model;
    }