mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-26 09:33:50 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -17,12 +17,8 @@ use Chill\MainBundle\Search\ParsingException;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use function array_key_exists;
|
||||
|
||||
/**
|
||||
* Search amongst reports.
|
||||
@@ -39,7 +35,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
|
||||
TokenStorageInterface $tokenStorage
|
||||
) {
|
||||
if (!$tokenStorage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User) {
|
||||
throw new RuntimeException('an user must be associated with token');
|
||||
throw new \RuntimeException('an user must be associated with token');
|
||||
}
|
||||
$this->user = $tokenStorage->getToken()->getUser();
|
||||
}
|
||||
@@ -70,7 +66,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
|
||||
|
||||
private function addACL(QueryBuilder $qb)
|
||||
{
|
||||
//adding join
|
||||
// adding join
|
||||
$qb->join('r.person', 'p');
|
||||
|
||||
$role = 'CHILL_REPORT_SEE';
|
||||
@@ -86,12 +82,12 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
|
||||
);
|
||||
$whereElement->add(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq('p.center', ':center_' . $i),
|
||||
$qb->expr()->in('r.scope', ':reachable_scopes_' . $i)
|
||||
$qb->expr()->eq('p.center', ':center_'.$i),
|
||||
$qb->expr()->in('r.scope', ':reachable_scopes_'.$i)
|
||||
)
|
||||
);
|
||||
$qb->setParameter('center_' . $i, $center);
|
||||
$qb->setParameter('reachable_scopes_' . $i, $reachableScopesId);
|
||||
$qb->setParameter('center_'.$i, $center);
|
||||
$qb->setParameter('reachable_scopes_'.$i, $reachableScopesId);
|
||||
}
|
||||
|
||||
return $whereElement;
|
||||
@@ -108,19 +104,19 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
|
||||
|
||||
$query->from('ChillReportBundle:Report', 'r');
|
||||
|
||||
//throw a parsing exception if key 'date' and default is set
|
||||
if (array_key_exists('date', $terms) && '' !== $terms['_default']) {
|
||||
// throw a parsing exception if key 'date' and default is set
|
||||
if (\array_key_exists('date', $terms) && '' !== $terms['_default']) {
|
||||
throw new ParsingException('You may not set a date argument and a date in default');
|
||||
}
|
||||
//throw a parsing exception if no argument except report
|
||||
if (!array_key_exists('date', $terms) && '' === $terms['_default']) {
|
||||
// throw a parsing exception if no argument except report
|
||||
if (!\array_key_exists('date', $terms) && '' === $terms['_default']) {
|
||||
throw new ParsingException('You must provide either a date:YYYY-mm-dd argument or a YYYY-mm-dd default search');
|
||||
}
|
||||
|
||||
if (array_key_exists('date', $terms)) {
|
||||
if (\array_key_exists('date', $terms)) {
|
||||
$query->andWhere($query->expr()->eq('r.date', ':date'))
|
||||
->setParameter('date', $this->parseDate($terms['date']));
|
||||
} elseif (array_key_exists('_default', $terms)) {
|
||||
} elseif (\array_key_exists('_default', $terms)) {
|
||||
$query->andWhere($query->expr()->eq('r.date', ':date'))
|
||||
->setParameter('date', $this->parseDate($terms['_default']));
|
||||
}
|
||||
|
Reference in New Issue
Block a user