You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
![]()
7 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
|
|
||
|
namespace Chamilo\CoreBundle\Repository;
|
||
|
|
||
|
use Doctrine\ORM\EntityRepository;
|
||
|
|
||
|
/**
|
||
|
* Class LegalRepository.
|
||
|
*
|
||
|
* @package Chamilo\CoreBundle\Repository
|
||
|
*/
|
||
|
class LegalRepository extends EntityRepository
|
||
|
{
|
||
|
/**
|
||
|
* Count the legal terms by language (only count one set of terms for each
|
||
|
* language).
|
||
|
*
|
||
|
* @throws \Exception
|
||
|
*
|
||
|
* @return int
|
||
|
*/
|
||
|
public function countAllActiveLegalTerms()
|
||
|
{
|
||
|
$qb = $this->createQueryBuilder('l');
|
||
|
$qb->select('l.languageId, COUNT(l.id)')
|
||
|
->groupBy('l.languageId');
|
||
|
|
||
|
return count($qb->getQuery()->getResult());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the latest version of terms of the given type and language.
|
||
|
*
|
||
|
* @param int $typeId The type of terms:
|
||
|
* 0 for general text,
|
||
|
* 1 for general HTML link,
|
||
|
* 101 for private data collection,
|
||
|
* etc - see personal_data.php
|
||
|
* @param int $languageId The Id of the language
|
||
|
*
|
||
|
* @return array The terms for those type and language
|
||
|
*/
|
||
|
public function findOneByTypeAndLanguage($typeId, $languageId)
|
||
|
{
|
||
|
$qb = $this->createQueryBuilder('l');
|
||
|
$qb->select('l.content')
|
||
|
->where($qb->expr()->eq('l.type', $typeId))
|
||
|
->andWhere($qb->expr()->eq('l.languageId', $languageId));
|
||
|
|
||
|
return $qb->getQuery()->getResult();
|
||
|
}
|
||
|
}
|