<?php
namespace TheatreCore\Repository;
use TheatreCore\Entity\Typesstructures;
use TheatreCore\Traits\TheatreTrait;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* TypesstructuresRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class TypesstructuresRepository extends ServiceEntityRepository
{
use TheatreTrait;
private $em;
public $__table;
public $__table_object;
public $__idtable;
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Typesstructures::class);
$this->__table = $this->getClassMetadata()->getTableName();
$this->__table_object = $this->getClassMetadata()->name;
$this->__idtable = $this->getClassMetadata()->getSingleIdentifierFieldName();
}
// {{{ getTypeStructureList()
/** Récupére la liste des types de structures
*
* Récupére tous les types de structures pour les listes
* déroulantes par exemple
*
* @access public
* @return array
*/
public function getTypeStructureList($public_view = null, $pluriel = false, $choix_type = array(), $namesOnly = false)
{
if ($namesOnly) {
$sql = 'SELECT DISTINCT typestructure, idtypestructure';
} else {
$sql = 'SELECT DISTINCT idtypestructure, typestructure';
}
if ($pluriel) {
$sql .= ',typestructure_pluriel';
}
$sql .= ' FROM ' . $this->__table . ' WHERE 1 ';
if (!empty($public_view)) {
$sql .= ' AND public_view=1 ';
}
if (!empty($choix_type) && is_array($choix_type)) {
foreach ($choix_type as $k => $c) {
$choix_type[$k] = '\'' . $c . '\'';
}
$sql .= ' AND idtypestructure IN (' . join(',', $choix_type) . ') ';
}
$sql .= ' ORDER BY order_view, typestructure';
if ($pluriel) {
$typestructure_list = $this->getEntityManager()->getConnection()->fetchAllAssociativeIndexed($sql);
} else {
$typestructure_list = $this->getEntityManager()->getConnection()->fetchFirstColumn($sql);
}
return $typestructure_list;
}
// }}}
// {{{ getTypeStructure()
/** Récupérer un type de structure
*
* @access public
* @return array
*/
public function getInfosTypeStructure($idtypestructure)
{
return $this->get($idtypestructure);
}
// }}}
}