/** * {@inheritDoc} */ public function id() { if ($this->__isInitialized__ === false) { return (int) parent::id(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); return parent::id(); }
/** * @param Curriculum $curriculum * @param $parent * @param $name * @param $type * @return Structure */ public function structure(Curriculum $curriculum, $parent, $name, $type) { $qb = $this->em->createQueryBuilder(); $qb->select('s')->from($this->strucClass, 's')->where($qb->expr()->eq('s.name', '?1'), $qb->expr()->eq('s.type', '?2'), $qb->expr()->eq('s.curriculum', '?3'))->setParameter(1, $name)->setParameter(2, $type)->setParameter(3, $curriculum->id()); if ($parent) { if ($parent instanceof Structure) { $qb->andWhere($qb->expr()->eq('s.parent', '?4'))->setParameter(4, $parent->id()); } } else { $qb->andWhere($qb->expr()->isNull('s.parent')); } return $qb->getQuery()->getOneOrNullResult(); }