Beispiel #1
0
 public function getBindingsFor($areaName)
 {
     $area = $this->em->getRepository('Zikula\\Component\\HookDispatcher\\Storage\\Doctrine\\Entity\\HookAreaEntity')->findOneBy(array('areaname' => $areaName));
     if (!$area) {
         return array();
     }
     if ($area->getAreatype() == self::PROVIDER) {
         $areaIdField = 'pareaid';
     } else {
         // $area->getAreatype() == self::SUBSCRIBER
         $areaIdField = 'sareaid';
     }
     $order = new \Doctrine\ORM\Query\Expr\OrderBy();
     $order->add('t.sortorder', 'ASC');
     $order->add('t.sareaid', 'ASC');
     $results = $this->em->createQueryBuilder()->select('t')->from('Zikula\\Component\\HookDispatcher\\Storage\\Doctrine\\Entity\\HookBindingEntity', 't')->where("t.{$areaIdField} = ?1")->orderBy($order)->getQuery()->setParameter(1, $area->getId())->getArrayResult();
     // this could be an area where related entities would help CAH - 23 Oct 2013
     $areas = array();
     foreach ($results as $result) {
         $area = $this->em->find('Zikula\\Component\\HookDispatcher\\Storage\\Doctrine\\Entity\\HookAreaEntity', $result['pareaid']);
         $areas[] = array('areaname' => $area->getAreaname(), 'category' => $area->getCategory());
     }
     return $areas;
 }
 public function getBindingsFor($areaName)
 {
     $area = $this->em->getRepository('Zikula\\Component\\HookDispatcher\\Storage\\Doctrine\\Entity\\HookBindingEntity')->findOneByAreaname($areaName);
     if (!$area) {
         return array();
     }
     if ($area->getAreatype() == self::PROVIDER) {
         $table = 'Zikula_Doctrine_Model_HookProvider';
         $areaIdField = 'pareaid';
     } elseif ($area->getAreatype() == self::SUBSCRIBER) {
         $table = 'Zikula_Doctrine_Model_HookSubscriber';
         $areaIdField = 'sareaid';
     }
     $order = new \Doctrine\ORM\Query\Expr\OrderBy();
     $order->add('t.sortorder', 'ASC');
     $order->add('t.sareaid', 'ASC');
     $results = $this->em->createQueryBuilder()->from('Zikula\\Component\\HookDispatcher\\Storage\\Doctrine\\Entity\\HookBindingEntity', 't')->where("{$areaIdField} = ?")->orderBy($order)->getQuery()->setParameter(1, $area->getId())->getArrayResult();
     $areas = array();
     foreach ($results as $result) {
         $area = $this->em->find('Zikula\\Component\\HookDispatcher\\Storage\\Doctrine\\Entity\\HookAreaEntity', $result['pareaid']);
         $areas[] = array('areaname' => $area->getAreaname(), 'category' => $area->getCategory());
     }
     return $areas;
 }