mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -20,12 +20,8 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Class TimelineEventProvider.
|
||||
*/
|
||||
@@ -58,7 +54,7 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
$this->helper = $helper;
|
||||
|
||||
if (!$storage->getToken()->getUser() instanceof User) {
|
||||
throw new RuntimeException('A user should be authenticated !');
|
||||
throw new \RuntimeException('A user should be authenticated !');
|
||||
}
|
||||
$this->user = $storage->getToken()->getUser();
|
||||
}
|
||||
@@ -66,9 +62,9 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
/**
|
||||
* @param string $context
|
||||
*
|
||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
||||
*
|
||||
* @return array|string[]
|
||||
*
|
||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
||||
*/
|
||||
public function fetchQuery($context, array $args)
|
||||
{
|
||||
@@ -79,9 +75,9 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
||||
|
||||
return TimelineSingleQuery::fromArray([
|
||||
'id' => $metadataEvent->getTableName() . '.' . $metadataEvent->getColumnName('id'),
|
||||
'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'),
|
||||
'type' => 'event',
|
||||
'date' => $metadataEvent->getTableName() . '.' . $metadataEvent->getColumnName('date'),
|
||||
'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'),
|
||||
'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson),
|
||||
'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']),
|
||||
'parameters' => [],
|
||||
@@ -106,7 +102,7 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event $entity
|
||||
* @param Event $entity
|
||||
* @param string $context
|
||||
*
|
||||
* @return array|mixed[]
|
||||
@@ -140,20 +136,19 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
*
|
||||
* @param string $context
|
||||
*
|
||||
* @throws LogicException if the context is not supported
|
||||
* @throws \LogicException if the context is not supported
|
||||
*/
|
||||
private function checkContext($context)
|
||||
{
|
||||
if ('person' !== $context) {
|
||||
throw new LogicException("The context '{$context}' is not "
|
||||
. "supported. Currently only 'person' is supported");
|
||||
throw new \LogicException("The context '{$context}' is not supported. Currently only 'person' is supported");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
||||
*/
|
||||
private function getFromClause(
|
||||
ClassMetadata $metadataEvent,
|
||||
@@ -164,23 +159,23 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
$participationPersonMapping = $metadataParticipation->getAssociationMapping('person');
|
||||
|
||||
return $metadataEvent->getTableName()
|
||||
. ' JOIN ' . $metadataParticipation->getTableName()
|
||||
. ' ON ' . $metadataParticipation->getTableName()
|
||||
. '.' . $eventParticipationMapping['joinColumns'][0]['name']
|
||||
. ' = ' . $metadataEvent->getTableName()
|
||||
. '.' . $eventParticipationMapping['joinColumns'][0]['referencedColumnName']
|
||||
.' JOIN '.$metadataParticipation->getTableName()
|
||||
.' ON '.$metadataParticipation->getTableName()
|
||||
.'.'.$eventParticipationMapping['joinColumns'][0]['name']
|
||||
.' = '.$metadataEvent->getTableName()
|
||||
.'.'.$eventParticipationMapping['joinColumns'][0]['referencedColumnName']
|
||||
|
||||
. ' JOIN ' . $metadataPerson->getTableName()
|
||||
. ' ON ' . $metadataPerson->getTableName()
|
||||
. '.' . $participationPersonMapping['joinColumns'][0]['referencedColumnName']
|
||||
. ' = ' . $metadataParticipation->getTableName()
|
||||
. '.' . $participationPersonMapping['joinColumns'][0]['name'];
|
||||
.' JOIN '.$metadataPerson->getTableName()
|
||||
.' ON '.$metadataPerson->getTableName()
|
||||
.'.'.$participationPersonMapping['joinColumns'][0]['referencedColumnName']
|
||||
.' = '.$metadataParticipation->getTableName()
|
||||
.'.'.$participationPersonMapping['joinColumns'][0]['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
||||
*/
|
||||
private function getWhereClause(
|
||||
ClassMetadata $metadataEvent,
|
||||
@@ -193,7 +188,7 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
$reachableCenters = $this->helper->getReachableCenters($this->user, $role);
|
||||
$associationMapping = $metadataParticipation->getAssociationMapping('person');
|
||||
|
||||
if (count($reachableCenters) === 0) {
|
||||
if (0 === \count($reachableCenters)) {
|
||||
return 'FALSE = TRUE';
|
||||
}
|
||||
|
||||
@@ -213,15 +208,15 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
);
|
||||
$centerAndScopeLines[] = sprintf(
|
||||
'(%s = %d AND %s IN (%s))',
|
||||
$metadataPerson->getTableName() . '.' .
|
||||
$metadataPerson->getTableName().'.'.
|
||||
$metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'],
|
||||
$center->getId(),
|
||||
$metadataEvent->getTableName() . '.' .
|
||||
$metadataEvent->getTableName().'.'.
|
||||
$metadataEvent->getAssociationMapping('circle')['joinColumns'][0]['name'],
|
||||
implode(',', $reachableCircleId)
|
||||
);
|
||||
}
|
||||
$whereClause .= ' AND (' . implode(' OR ', $centerAndScopeLines) . ')';
|
||||
$whereClause .= ' AND ('.implode(' OR ', $centerAndScopeLines).')';
|
||||
|
||||
return $whereClause;
|
||||
}
|
||||
|
Reference in New Issue
Block a user