getEntityManager()->getRepository('ChamiloCoreBundle:Course'); break; case SequenceResource::SESSION_TYPE: $repo = $this->getEntityManager()->getRepository('ChamiloCoreBundle:Session'); break; } if ($repo) { $resource = $repo->find($itemId); } return $resource; } /** * @param int $id */ public function removeSequence($id) { $sequence = $this->find($id); $em = $this->getEntityManager(); $em ->createQuery('DELETE FROM ChamiloCoreBundle:SequenceResource sr WHERE sr.sequence = :seq') ->execute(['seq' => $sequence]); $em->remove($sequence); $em->flush(); } /** * @param string $type * * @return array */ public function findAllToSelect($type) { $qb = $this->createQueryBuilder('r'); $qb ->leftJoin('ChamiloCoreBundle:SequenceResource', 'sr', Join::WITH, 'sr.sequence = r'); $qb ->andWhere( $qb->expr()->orX( $qb->expr()->isNull('r.graph'), $qb->expr()->eq('sr.type', $type) ) ) ->orderBy('r.name'); return $qb->getQuery()->getResult(); } }