<?php
/**
 * Created by IntelliJ IDEA.
 * User: damien
 * Date: 21/05/2014
 * Time: 17:09
 */

namespace Actigraph\ActipageBaseBundle\Entity;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;

class TypeActuRepository extends EntityRepository  {

    public function getAlerteType(){
        return $this->findBy(array("nomTypeActu"=>"Alerte"));
    }
    public function getActusType(){
    }
    public function getInfoTrafficType(){
        //1 quand pas d'infostraffic par ligne sinon 10
        $type = $this->find(0);
        if($type == null)
            return $this->find(10);
    }
    public function getPrincipauxTypes(){
        $principauxTypes = array("alerte"=>array(),"infotrafic"=>array(),"actu"=>array());

        $types = $this->findAll();
        foreach($types as $type){
            if($type->isAlerteStyle())
                $principauxTypes["alerte"][] = $type->getIdTypeActu();
            else if($type->isInfoTrafficStyle())
                $principauxTypes["infotrafic"][] = $type->getIdTypeActu();
            else
                $principauxTypes["actu"][] = $type->getIdTypeActu();
        }

        return $principauxTypes;
    }
} 