public function constructData() { $this->datos = $this->getRepo("MySecurityBundle:Usuario")->getInstances(UtilRepository2::getParameter('idUser'), $this->getTableFiltersByRquest()); $result = array(); foreach ($this->datos as $row) { $tmpArray = array(); $tmpArray[] = $row['tipoInstancia']; $tmpArray[] = $row['instancia']; $result[] = $tmpArray; } return $result; }
/** * @param $entity * @param array $filter * @param bool $empty Esto es para indicar si va a devolver vacio en caso de que no se filtre por nada * @return JsonResponse */ public function jsonRead($entity, $filter = array(), $empty = false) { $repo = $this->getRepo($entity); $alias = UtilRepository2::createAlias($entity); $query = $this->getParameter('query'); $qb = $repo->getQB()->select("{$alias}.id", "{$alias}.denominacion"); $param = $this->getParameter('param'); $index = $this->getParameter('index'); $value = $this->getParameter($param)[$index]; // ld($this->getParameter('filter')); // ld($index); // ld($param); // ldd($value); if ($value != null || $empty == false) { // $filter = array(); $name = $this->getParameter('filter'); if (strpos($name, ".") != false) { // ldd('paco'); $join = explode(".", $name)[0]; if ($join != $alias) { $qb->join($alias . "." . $join, $join); } } if (is_array($value) && count($value) > 0) { $value = array('in', $value); $filter[$name] = $value; } if (!is_array($value)) { $filter[$name] = $value; } // ldd($filter); /** * Query debe ser una consulta que devuelve un QueryBuilder */ if ($query) { $qb = $repo->{$query}(); } $r = $repo->filterQB($qb, $filter, ResultType::ArrayType); $result = array(); foreach ($r as $row) { $result[$row['id']] = $row['denominacion']; } return new JsonResponse($result); } return new JsonResponse(array()); }
public static function autoIndexSearch() { $em = UtilRepository2::getEntityManager(); $leyes = UtilRepository2::getRepo("CatarinoBundle:Ley")->findAll(); $i = 1; foreach ($leyes as $ley) { $array = DiccionarioIndexacion::excludefromSearch($ley->__toString()); foreach ($array as $arr) { $palabra = UtilRepository2::getRepo("CatarinoBundle:Palabra")->findOneBy(array('valor_norm' => DiccionarioIndexacion::normalizeString($arr))); if ($palabra != null) { $palabraLey = UtilRepository2::getRepo("CatarinoBundle:PalabraLey")->findBy(array("palabra" => $palabra->getId(), "ley" => $ley->getId())); if ($palabraLey != null) { $palabraLey = $palabraLey[0]; $palabraLey->setFrecuencia($palabraLey->getFrecuencia() + 1); $em->persist($palabraLey); $em->flush(); } else { $palabraLey = new PalabraLey(); $palabraLey->setValor(" "); $palabraLey->setPeso("0.15"); $palabraLey->setFrecuencia("1"); $palabraLey->setPalabra($palabra); $palabraLey->setLey($ley); $em->persist($palabraLey); $em->flush(); } } else { $palabra = new Palabra(); $palabra->setClave("0.15"); $palabra->setValor($arr); $palabra->setValorNorm(DiccionarioIndexacion::normalizeString($arr)); $em->persist($palabra); $palabraLey = new PalabraLey(); $palabraLey->setValor(" "); $palabraLey->setPeso("0.15"); $palabraLey->setFrecuencia("1"); $palabraLey->setPalabra($palabra); $palabraLey->setLey($ley); $em->persist($palabraLey); $em->flush(); } } } return; }
public function obtenerMenusPadresXUsuarioLogueado() { $markedPadres = array(); $hojas = $this->obtenerHojas(); for ($i = 0; $i < count($hojas); $i++) { // ld($hojas[$i]->getId()); if (UtilRepository2::getContainer()->get('security.context')->isGranted($hojas[$i]->getPermiso()) && $hojas[$i]->getId() != -1 && !array_key_exists($hojas[$i]->getPadre()->getId(), $markedPadres)) { $markedPadres[$hojas[$i]->getPadre()->getId()] = $hojas[$i]->getPadre()->getId(); $padre = $hojas[$i]->getPadre(); while ($padre->getId() != -1 && !array_key_exists($padre->getPadre()->getId(), $markedPadres)) { $markedPadres[$padre->getPadre()->getId()] = $padre->getPadre()->getId(); $padre = $padre->getPadre(); } } } return array_keys($markedPadres); // UtilRepository2::getContainer()->get('security.context')->isGranted() }
/** * @Route("/read") * @Template() */ public function readAction() { $em = UtilRepository2::getEntityManager(); $repo = $this->getDoctrine()->getRepository("BaseBundle:Litigante"); $tramite = $repo->obtenerXEscritoDemanda(18); ldd($tramite); // $this->get('comunes.motorgtr')->registrarTramite($tramite); // $em->flush(); // $em->persist($tramite); // $em->flush(); die('paco'); // $this->parameters = UtilRepository2::createFiltersFromRequest($this->getRequest()); // $method = $this->method; // $result = $repo->$method($this->parameters); // return new \Symfony\Component\HttpFoundation\Response(json_encode($result)); // $obj = $repo->generateEnumFromCollection($repo->filterObjects(array('tipoEstado'=> \backend\ComunBundle\Enums\ETipoEstado::Tramite)),'EEstadoTramite'); // $obj = $repo->generateEnumToEntity(); // $var['total']= UtilRepository2::getSession()->get('total'); // ld($table); // ldd(\backend\ComunBundle\Util\UtilRepository2::getEntityManager()->getRepository('ComunBundle:'.$table)->filterObjects()); // ldd(\backend\BiomexpressServicesBundle\Manager\BiomexpressServiceManager::authenticate(1, 1)); // ldd($obj); }
/** * @return NomencladoresRepository */ protected function getRepo($entity = null) { if (!$entity) { return UtilRepository2::getContainer()->get('doctrine.orm.entity_manager')->getRepository($this->entity); } else { return UtilRepository2::getContainer()->get('doctrine.orm.entity_manager')->getRepository($entity); } }
/** * @Route("/crud/tree/details",name="comun_tree_crud_details") * @return Response */ public function detailsAction() { $tableModel = $this->get($this->treeModelService); $id = $this->getParameter('id'); if (!is_numeric($id)) { $array = explode("_", $id); $id = $array[count($array) - 1]; } $entity = $this->getEm()->getRepository($tableModel->getEntity())->find($id); $fields = UtilRepository2::getFields($this->getEm(), $tableModel->getEntity()); $r = array(); foreach ($fields as $field) { if (!is_array($entity->{"get" . ucfirst($field)}())) { $r[] = array('key' => $field, 'value' => $entity->{"get" . ucfirst($field)}()); } } return $this->render($this->detailsView, array('obj' => $r)); }
/** * @author Franlin Rivero Garcia <*****@*****.**> * @param array $include * @param type $order * @return QueryBuilder */ public function getQBCustomJoin($join = 'innerJoin', $include = array()) { $joinType = UtilRepository2Config::$defaultJoinType; UtilRepository2Config::$defaultJoinType = $join; $em = $this->getEntityManager(); $class = $this->getEntityName(); $r = UtilRepository2::getQBTable($em, $class, $include); UtilRepository2Config::$defaultJoinType = $joinType; return $r; }
public function getMenuParents() { $padres = UtilRepository2::getRepo('MenuBundle:Menu')->obtenerMenusPadresXUsuarioLogueado(); return $padres; }
public function getTransformedData($rowActions = array(RowActions::Editar, RowActions::Eliminar, RowActions::Detalles)) { $records = $this->constructData(); $iTotalRecords = $this->getTotalElements(); $iDisplayStart = $this->container->get('request')->get('iDisplayStart'); $iDisplayLength = $this->container->get('request')->get('iDisplayLength'); $iDisplayLength = $iDisplayLength == -1 ? UtilRepository2::getTotalElements() : $iDisplayLength; $end = $iDisplayStart + $iDisplayLength; $end = count($this->datos); // $cant = $end > $iTotalRecords ? $iTotalRecords : $end; $cant = $end; $start = $iDisplayStart; $result = array(); $result["aaData"] = array(); for ($i = 0; $i < $cant; $i++) { $row = $start + $i + 1; $tmpArray = array(); if ($this->rowNumberColumn) { $tmpArray[] = $row; } if ($this->hasCheck()) { if (is_array($this->datos[$i])) { $tmpArray[] = $this->getCheckBox($this->datos[$i][$this->id]); } else { $tmpArray[] = $this->getCheckBox($this->datos[$i]->getId()); } } $tmpArray = array_merge($tmpArray, $records[$i]); if (count($rowActions) > 0) { $tmpArray[] = $this->getRowActions($rowActions); } if (is_array($this->datos[$i])) { $tmpArray["DT_RowId"] = $this->datos[$i]['id']; } else { $tmpArray["DT_RowId"] = $this->tableId . "_" . $this->datos[$i]->getId(); } $result["aaData"][] = $tmpArray; } $result["iTotalDisplayRecords"] = $iTotalRecords; $result["iTotalRecords"] = $iTotalRecords; $result["checkeds"] = $this->checkeds; $result["extraData"] = $this->detailData(); return $result; }
/** * NO USAR, ESTO NO SE DBE USAR * * @deprecated since version 2 * @author Franlin Rivero Grcia <*****@*****.**> * @param EntityManager $em * @param QueryBuilder $qb * @param array $filters Arreglo asociativo campo => valor * @param ResultType $resultType * @param type $order * @param type $page * @return array */ public static function filterRecordsQueryString(EntityManager $em, $dql, $filters = array(), $order = null, $resultType = ResultType::ArrayType, $page = null) { $op = UtilRepository2Config::$defaultQueryStringCompareOperator; $query = $dql; if (is_array($dql)) { $query = $dql[0]; $query .= " " . $dql[1]; } $i = 0; foreach ($filters as $key => $value) { $param = str_replace(".", '', $key); if ($i == 0 && !is_array($dql)) { if (is_array($value)) { $query .= " where {$key} {$value['0']} :{$param}"; } else { $query .= " where {$key} {$op} :{$param}"; } } else { if (is_array($value)) { $query .= " and {$key} {$value['0']} :{$param}"; } else { $query .= " and {$key} {$op} :{$param}"; } } $i++; } if ($order != null) { $query .= " order by {$order}"; } $query = $em->createQuery($query); foreach ($filters as $key => $value) { $param = str_replace(".", '', $key); if (!is_array($value)) { if ($op == 'like') { $query->setParameter($param, "%{$value}%"); } else { $query->setParameter($param, $value); } } elseif ($value[0] == 'like') { $query->setParameter($param, "%" . strtolower($value[1]) . "%"); } else { $query->setParameter($param, $value[1]); } } return UtilRepository2::doQueryResult($query, $resultType); }
/** * @return NomencladoresRepository */ public static function getRepo($entity) { return \backend\ComunBundle\Util\UtilRepository2::getContainer()->get('doctrine.orm.entity_manager')->getRepository($entity); }