Пример #1
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->bulletinInfo = $options['bulletinInfo'];
     if (null == $this->bulletinInfo) {
         $builder->add('bulletinInfo', EntityType::class, array('label' => 'BulletinInfoTitle.bulletinInfo.label', 'class' => 'AcfDataBundle:BulletinInfo', 'query_builder' => function (BulletinInfoRepository $bir) {
             return $bir->createQueryBuilder('bi')->orderBy('bi.num', 'ASC');
         }, 'choice_label' => 'num', 'multiple' => false, 'by_reference' => true, 'required' => true));
     } else {
         $biId = $this->bulletinInfo->getId();
         $builder->add('bulletinInfo', EntityidType::class, array('label' => 'BulletinInfoTitle.bulletinInfo.label', 'class' => 'AcfDataBundle:BulletinInfo', 'query_builder' => function (BulletinInfoRepository $bir) use($biId) {
             return $bir->createQueryBuilder('bi')->where('bi.id = :id')->setParameter('id', $biId)->orderBy('bi.num', 'ASC');
         }, 'choice_label' => 'id', 'multiple' => false, 'by_reference' => true, 'required' => true));
     }
     $builder->add('title', TextType::class, array('label' => 'BulletinInfoTitle.title.label'));
 }
 /**
  * Get Query for All Entities
  *
  * @param BulletinInfo $bi
  *
  * @return \Doctrine\ORM\Query
  */
 public function getAllByBulletinInfoQuery(BulletinInfo $bi)
 {
     $qb = $this->createQueryBuilder('bt')->join('bt.bulletinInfo', 'bi')->where('bi.id = :id')->orderBy('bt.title', 'ASC')->setParameter('id', $bi->getId());
     $query = $qb->getQuery();
     return $query;
 }