Exemple #1
0
 /**
  * 
  * @return type
  */
 public function all($entity)
 {
     $result = $this->manager->getRepository($entity)->findAll();
     #Verificando se algum registro foi encontrado
     if ($result == null) {
         throw new NoResultException("Nenhum registro encotrado");
     }
     return $result;
 }
 /**
  * 
  * @return type
  */
 public function all()
 {
     try {
         $arrayResult = $this->manager->getRepository("SerBinarioSecurityBundle:Perfil")->findAll();
         return $arrayResult;
     } catch (Exception $ex) {
         return null;
     }
 }
Exemple #3
0
 /**
  * @param type $tree  tree
  * @param type $begin begin
  * @param type &$end  end
  * @param type $em    em
  */
 public function postOrderTraversal($tree, $begin, &$end, $em)
 {
     //get $tree childrens
     $children = $em->getRepository('CMSAdminBUndle:Menu')->getChildren($tree->getId());
     $tree->setLft($begin);
     $end = ++$begin;
     //Travesal the tree
     foreach ($children as $child) {
         $repositor = $em->getRepository('CMSAdminBUndle:Menu');
         $repositor->postOrderTraversal($child, $begin, $end, $em);
         $begin = ++$end;
     }
     $tree->setRgt($end);
 }
 /**
  * 
  * @param type $manager
  * @param type $v
  */
 public function populateDogodekSplosni($manager, $v)
 {
     $rep = $manager->getRepository('Koledar\\Entity\\DogodekSplosni');
     $o = null;
     $nov = false;
     if (!$o) {
         $o = new \Koledar\Entity\DogodekSplosni();
         $nov = true;
     }
     $o->setTitle($v[1]);
     $o->setStatus($v[2]);
     $date = empty($v[3]) ? null : date_create($v[3]);
     $o->setZacetek($date);
     $date = empty($v[4]) ? null : date_create($v[4]);
     $o->setKonec($date);
     $ref = $v[5] ? $this->getReference($v[5]) : null;
     $o->setProstor($ref);
     $ref = $v[6] ? $this->getReference($v[6]) : null;
     //        $o->setSezona($ref);
     if ($nov) {
         $rep->create($o);
     } else {
         $rep->update($o);
     }
     $referenca = 'DogodekSplosni-' . $v[0];
     //        var_dump($referenca);
     $this->addReference($referenca, $o);
     $referencaDog = 'DogodekSpl-' . $v[0];
     $this->addReference($referencaDog, $o->getDogodek());
 }
Exemple #5
0
 /**
  * 
  * @param type $array
  */
 public function findBy($array = array())
 {
     try {
         $obj = $this->manager->getRepository($this->nameBundle)->findBy($array);
         return $obj;
     } catch (Exception $ex) {
         return false;
     }
 }
 /**
  * 
  * @param type $id
  * @return type
  */
 public function findId($id)
 {
     try {
         $obj = $this->manager->getRepository('ProtocoloBundle:Encaminhamentos')->find($id);
         return $obj;
     } catch (Exception $ex) {
         return null;
     }
 }
 /**
  * 
  * @param type $id
  * @return type
  */
 public function findId($id)
 {
     try {
         $obj = $this->manager->getRepository('Serbinario\\Bundles\\ProtocoloBundle\\Entity\\Subsecretaria')->find($id);
         return $obj;
     } catch (Exception $ex) {
         return null;
     }
 }
 /**
  * 
  * @param type $numOficio
  * @return type
  */
 public function findNumOficio($numOficio, $idSecretaria)
 {
     try {
         $obj = $this->manager->getRepository('Serbinario\\Bundles\\ProtocoloBundle\\Entity\\Documentos')->findBy(array('numOficio' => $numOficio, 'secretariasSecretaria' => $idSecretaria));
         return $obj;
     } catch (Exception $ex) {
         return null;
     }
 }
Exemple #9
0
 /**
  * Dodajanje opcij
  * 
  * Vsebino yml datoteke ažurira v entitetah Option in OptionValue
  * 
  * @param type $em  entity manager
  * @param type $val Ena opcija iz yml datoteke
  */
 public function populateOptions($em, $val)
 {
     $optR = $em->getRepository('App\\Entity\\Option');
     $o = $optR->findOneByName($val['name']);
     $readOnly = empty($val['readOnly']) ? false : $val['readOnly'];
     if (!$o) {
         $o = new Option();
         $em->persist($o);
         $o->setName($val['name']);
     } else {
         /**
          * spremembe naredimo le, če je readonly
          */
         if (!$readOnly) {
             return;
         }
     }
     $o->setReadOnly($readOnly);
     $o->setType($val['type']);
     $o->setDescription($val['description']);
     $o->setDefaultValue(empty($val['defaultValue']) ? null : $val['defaultValue']);
     $o->setPerUser(empty($val['perUser']) ? false : $val['perUser']);
     $o->setPublic(empty($val['public']) ? false : $val['public']);
     $o->setRole(empty($val['role']) ? null : $val['role']);
     /**
      *          če obstajajo globalne ali uporabniške vrednosti ažuriramo entiteto OptionValue:
      */
     if (!empty($val['optionValue'])) {
         echo " " . $val['name'] . '  ->  not empty Option Value ' . PHP_EOL;
         if (!empty($val['optionValue']['global'])) {
             echo "  global" . PHP_EOL;
             /**
              *  ali obstaja globalna opcija ?
              */
             $optValue = $em->getRepository('App\\Entity\\OptionValue')->getOptionValuesGlobalValue($o);
             // pričakujemo, da najde največ 1 globalno vrednost.
             if (empty($optValue)) {
                 $optVal = new OptionValue();
                 $optVal->setValue($val['optionValue']['global']['value']);
                 $optVal->setGlobal(true);
                 $optVal->addOption($o);
                 $em->persist($optVal);
             }
             echo "     opt val: " . $val['optionValue']['global']['value'][0]['key'] . "  " . $val['optionValue']['global']['value'][0]['value'] . PHP_EOL;
         }
         /**
          * ali obstajajo uporabniške vrednosti 
          */
         if (!empty($val['optionValue']['user'])) {
             $optValueUserY = $val['optionValue']['user'];
             foreach ($optValueUserY as $user) {
                 echo "  user    " . $user['email'] . PHP_EOL;
                 // najprej preverim, če uporabniško ime že obstaja v entiteti User
                 $u = $em->getRepository('Aaa\\Entity\\User')->findOneByemail($user['email']);
                 $this->expect($u, "Ni tega uporabnika", 1000300);
                 // $$ rb potrebno še implementirati trnsl
                 // ali obstajajo  opcije userja
                 $optValue = $em->getRepository('App\\Entity\\OptionValue')->getOptionValuesUserValue($o, $u);
                 if (empty($optValue)) {
                     $optVal = new OptionValue();
                     $optVal->setValue($user['value']);
                     $optVal->setGlobal(false);
                     $optVal->addOption($o);
                     $optVal->addUser($u);
                     $em->persist($optVal);
                     // ali je lahko več persistov pred flush-em?
                 }
                 echo "     opt val: " . $user['value'][0]['key'] . " " . $user['value'][0]['value'] . PHP_EOL;
             }
         }
     }
 }