mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-04 07:56:12 +00:00
fix: SA: Fix "...invoked with..." rule.
SA stands for Static Analysis.
This commit is contained in:
parent
a3eb23478a
commit
c68bda5c9b
@ -85,16 +85,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
|
path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\ActivityBundle\\\\Timeline\\\\TimelineActivityProvider\\:\\:getFromClausePerson\\(\\) invoked with 1 parameter, 0 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:buildQueryEntities\\(\\) invoked with 3 parameters, 2 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
|
message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
@ -250,11 +240,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
|
path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Class Chill\\\\DocStoreBundle\\\\Entity\\\\DocumentCategory constructor invoked with 0 parameters, 2 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@ -360,16 +345,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
|
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getEntity\\(\\) invoked with 4 parameters, 3 required\\.$#"
|
|
||||||
count: 3
|
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\ApiController\\:\\:entityPostAction\\(\\) invoked with 4 parameters, 3 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
|
message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@ -385,16 +360,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
|
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:buildQueryEntities\\(\\) invoked with 3 parameters, 2 required\\.$#"
|
|
||||||
count: 2
|
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:onPreDelete\\(\\) invoked with 3 parameters, 2 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#"
|
message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@ -520,21 +485,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createAddLinkGroupCenterForm\\(\\) invoked with 1 parameter, 2 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditPasswordForm\\(\\) invoked with 2 parameters, 1 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:getDeleteLinkGroupCenterByUser\\(\\) invoked with 1 parameter, 2 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
@ -720,11 +670,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php
|
path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\Search\\\\SearchApi\\:\\:buildUnionQuery\\(\\) invoked with 4 parameters, 3 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Search/SearchApi.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
|
message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
@ -750,11 +695,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
|
path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AuthorizationHelper\\:\\:userCanReachCenter\\(\\) invoked with 3 parameters, 2 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
@ -945,11 +885,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillPersonBundle/Entity/Person.php
|
path: src/Bundle/ChillPersonBundle/Entity/Person.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:getCurrentPersonAddress\\(\\) invoked with 1 parameter, 0 required\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillPersonBundle/Entity/Person.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
|
@ -1,94 +1,53 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
declare(strict_types=1);
|
||||||
* Chill is a software for social workers
|
|
||||||
* Copyright (C) 2015 Champs Libres <info@champs-libres.coop>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Timeline;
|
namespace Chill\ActivityBundle\Timeline;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
|
use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide activity for inclusion in timeline
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class TimelineActivityProvider implements TimelineProviderInterface
|
class TimelineActivityProvider implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
|
protected EntityManagerInterface $em;
|
||||||
/**
|
|
||||||
*
|
protected AuthorizationHelperInterface $helper;
|
||||||
* @var EntityManager
|
|
||||||
*/
|
protected UserInterface $user;
|
||||||
protected $em;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $helper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var \Chill\MainBundle\Entity\User
|
|
||||||
*/
|
|
||||||
protected $user;
|
|
||||||
|
|
||||||
protected ActivityACLAwareRepository $aclAwareRepository;
|
protected ActivityACLAwareRepository $aclAwareRepository;
|
||||||
|
|
||||||
private const SUPPORTED_CONTEXTS = [ 'center', 'person'];
|
private const SUPPORTED_CONTEXTS = [ 'center', 'person'];
|
||||||
|
|
||||||
/**
|
|
||||||
* TimelineActivityProvider constructor.
|
|
||||||
*
|
|
||||||
* @param EntityManager $em
|
|
||||||
* @param AuthorizationHelper $helper
|
|
||||||
* @param TokenStorageInterface $storage
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManager $em,
|
EntityManagerInterface $em,
|
||||||
AuthorizationHelper $helper,
|
AuthorizationHelperInterface $helper,
|
||||||
TokenStorageInterface $storage,
|
TokenStorageInterface $storage,
|
||||||
ActivityACLAwareRepository $aclAwareRepository
|
ActivityACLAwareRepository $aclAwareRepository
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
$this->aclAwareRepository = $aclAwareRepository;
|
$this->aclAwareRepository = $aclAwareRepository;
|
||||||
|
|
||||||
if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User)
|
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();
|
$this->user = $storage->getToken()->getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function fetchQuery($context, array $args)
|
public function fetchQuery($context, array $args)
|
||||||
@ -97,23 +56,23 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
return TimelineSingleQuery::fromArray($this->aclAwareRepository
|
return TimelineSingleQuery::fromArray($this->aclAwareRepository
|
||||||
->queryTimelineIndexer($context, $args));
|
->queryTimelineIndexer($context, $args));
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||||
|
|
||||||
[$where, $parameters] = $this->getWhereClauseForPerson($args['person']);
|
[$where, $parameters] = $this->getWhereClauseForPerson($args['person']);
|
||||||
|
|
||||||
return TimelineSingleQuery::fromArray([
|
return TimelineSingleQuery::fromArray([
|
||||||
'id' => $metadataActivity->getTableName()
|
'id' => $metadataActivity->getTableName()
|
||||||
.'.'.$metadataActivity->getColumnName('id'),
|
.'.'.$metadataActivity->getColumnName('id'),
|
||||||
'type' => 'activity',
|
'type' => 'activity',
|
||||||
'date' => $metadataActivity->getTableName()
|
'date' => $metadataActivity->getTableName()
|
||||||
.'.'.$metadataActivity->getColumnName('date'),
|
.'.'.$metadataActivity->getColumnName('date'),
|
||||||
'FROM' => $this->getFromClausePerson($args['person']),
|
'FROM' => $this->getFromClausePerson(),
|
||||||
'WHERE' => $where,
|
'WHERE' => $where,
|
||||||
'parameters' => $parameters
|
'parameters' => $parameters
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getWhereClauseForPerson(Person $person)
|
private function getWhereClauseForPerson(Person $person)
|
||||||
{
|
{
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
@ -125,15 +84,15 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
|
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
|
||||||
$scopes_ids = [];
|
$scopes_ids = [];
|
||||||
|
|
||||||
// first parameter: activity.person_id
|
// first parameter: activity.person_id
|
||||||
$parameters[] = $person->getId();
|
$parameters[] = $person->getId();
|
||||||
|
|
||||||
// loop on reachable scopes
|
// loop on reachable scopes
|
||||||
foreach ($reachableScopes as $scope) {
|
foreach ($reachableScopes as $scope) {
|
||||||
if (\in_array($scope->getId(), $scopes_ids)) {
|
if (\in_array($scope->getId(), $scopes_ids)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$scopes_ids[] = '?';
|
$scopes_ids[] = '?';
|
||||||
$parameters[] = $scope->getId();
|
$parameters[] = $scope->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,47 +110,40 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
$parameters
|
$parameters
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFromClausePerson()
|
private function getFromClausePerson(): string
|
||||||
{
|
{
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
|
|
||||||
return $metadataActivity->getTableName().' JOIN '
|
return sprintf(
|
||||||
.$metadataPerson->getTableName().' ON '
|
"%s JOIN %s ON %s.%s = %s",
|
||||||
.$metadataPerson->getTableName().'.'.
|
$metadataActivity->getTableName(),
|
||||||
$associationMapping['joinColumns'][0]['referencedColumnName']
|
$metadataPerson->getTableName(),
|
||||||
.' = '
|
$metadataPerson->getTableName(),
|
||||||
.$associationMapping['joinColumns'][0]['name']
|
$associationMapping['joinColumns'][0]['referencedColumnName'],
|
||||||
;
|
$associationMapping['joinColumns'][0]['name']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getEntities(array $ids): array
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function getEntities(array $ids)
|
|
||||||
{
|
{
|
||||||
$activities = $this->em->getRepository(Activity::class)
|
$activities = $this->em->getRepository(Activity::class)
|
||||||
->findBy(array('id' => $ids));
|
->findBy(array('id' => $ids));
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach($activities as $activity) {
|
foreach($activities as $activity) {
|
||||||
$result[$activity->getId()] = $activity;
|
$result[$activity->getId()] = $activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getEntityTemplate($entity, $context, array $args): array
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function getEntityTemplate($entity, $context, array $args)
|
|
||||||
{
|
{
|
||||||
$this->checkContext($context);
|
$this->checkContext($context);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
|
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
|
||||||
'template_data' => [
|
'template_data' => [
|
||||||
@ -201,26 +153,25 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function supportsType($type): bool
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function supportsType($type)
|
|
||||||
{
|
{
|
||||||
return $type === 'activity';
|
return $type === 'activity';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the context is supported
|
* Check if the context is supported.
|
||||||
*
|
*
|
||||||
* @param string $context
|
|
||||||
* @throws \LogicException if the context is not supported
|
* @throws \LogicException if the context is not supported
|
||||||
*/
|
*/
|
||||||
private function checkContext($context)
|
private function checkContext(string $context)
|
||||||
{
|
{
|
||||||
if (FALSE === \in_array($context, self::SUPPORTED_CONTEXTS)) {
|
if (FALSE === \in_array($context, self::SUPPORTED_CONTEXTS)) {
|
||||||
throw new \LogicException("The context '$context' is not "
|
throw new \LogicException(
|
||||||
. "supported. Currently only 'person' is supported");
|
sprintf(
|
||||||
|
"The context '%s' is not supported. Currently only 'person' is supported",
|
||||||
|
$context
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ use Doctrine\Common\Collections\Criteria;
|
|||||||
|
|
||||||
final class AsideActivityController extends CRUDController
|
final class AsideActivityController extends CRUDController
|
||||||
{
|
{
|
||||||
|
private AsideActivityCategoryRepository $categoryRepository;
|
||||||
private $categoryRepository;
|
|
||||||
|
|
||||||
public function __construct(AsideActivityCategoryRepository $categoryRepository)
|
public function __construct(AsideActivityCategoryRepository $categoryRepository)
|
||||||
{
|
{
|
||||||
@ -25,7 +24,7 @@ final class AsideActivityController extends CRUDController
|
|||||||
|
|
||||||
protected function buildQueryEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null)
|
protected function buildQueryEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null)
|
||||||
{
|
{
|
||||||
$qb = parent::buildQueryEntities($action, $request, $filterOrder);
|
$qb = parent::buildQueryEntities($action, $request);
|
||||||
|
|
||||||
if ('index' === $action) {
|
if ('index' === $action) {
|
||||||
$qb->where($qb->expr()->eq('e.agent', ':user'));
|
$qb->where($qb->expr()->eq('e.agent', ':user'));
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\DocStoreBundle\Controller;
|
namespace Chill\DocStoreBundle\Controller;
|
||||||
|
|
||||||
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||||
@ -9,11 +11,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Chill\DocStoreBundle\ChillDocStoreBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DocumentCategoryController
|
|
||||||
*
|
|
||||||
* @package Chill\DocStoreBundle\Controller
|
|
||||||
* @Route("/{_locale}/admin/document/category")
|
* @Route("/{_locale}/admin/document/category")
|
||||||
*/
|
*/
|
||||||
class DocumentCategoryController extends AbstractController
|
class DocumentCategoryController extends AbstractController
|
||||||
@ -24,11 +24,14 @@ class DocumentCategoryController extends AbstractController
|
|||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$categories = $em->getRepository("ChillDocStoreBundle:DocumentCategory")->findAll();
|
$categories = $em->getRepository(DocumentCategory::class)->findAll();
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'ChillDocStoreBundle:DocumentCategory:index.html.twig',
|
'ChillDocStoreBundle:DocumentCategory:index.html.twig',
|
||||||
['document_categories' => $categories]);
|
[
|
||||||
|
'document_categories' => $categories,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,13 +40,10 @@ class DocumentCategoryController extends AbstractController
|
|||||||
public function new(Request $request): Response
|
public function new(Request $request): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$documentCategory = new DocumentCategory();
|
$documentCategory = new DocumentCategory(
|
||||||
$documentCategory
|
ChillDocStoreBundle::class,
|
||||||
->setBundleId('Chill\DocStoreBundle\ChillDocStoreBundle');
|
$em->getRepository(DocumentCategory::class)->nextIdInsideBundle()
|
||||||
$documentCategory
|
);
|
||||||
->setIdInsideBundle(
|
|
||||||
$em->getRepository("ChillDocStoreBundle:DocumentCategory")
|
|
||||||
->nextIdInsideBundle());
|
|
||||||
$documentCategory
|
$documentCategory
|
||||||
->setDocumentClass(PersonDocument::class);
|
->setDocumentClass(PersonDocument::class);
|
||||||
|
|
||||||
@ -56,11 +56,10 @@ class DocumentCategoryController extends AbstractController
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('document_category_index');
|
return $this->redirectToRoute('document_category_index');
|
||||||
} else {
|
|
||||||
$documentCategory->setBundleId(
|
|
||||||
'Chill\DocStoreBundle\ChillDocStoreBundle');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$documentCategory->setBundleId(ChillDocStoreBundle::class);
|
||||||
|
|
||||||
return $this->render('ChillDocStoreBundle:DocumentCategory:new.html.twig', [
|
return $this->render('ChillDocStoreBundle:DocumentCategory:new.html.twig', [
|
||||||
'document_category' => $documentCategory,
|
'document_category' => $documentCategory,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\MainBundle\CRUD\Controller;
|
namespace Chill\MainBundle\CRUD\Controller;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -17,36 +19,36 @@ class ApiController extends AbstractCRUDController
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The view action.
|
* The view action.
|
||||||
*
|
*
|
||||||
* Some steps may be overriden during this process of rendering:
|
* Some steps may be overriden during this process of rendering:
|
||||||
*
|
*
|
||||||
* This method:
|
* This method:
|
||||||
*
|
*
|
||||||
* 1. fetch the entity, using `getEntity`
|
* 1. fetch the entity, using `getEntity`
|
||||||
* 2. launch `onPostFetchEntity`. If postfetch is an instance of Response,
|
* 2. launch `onPostFetchEntity`. If postfetch is an instance of Response,
|
||||||
* this response is returned.
|
* this response is returned.
|
||||||
* 2. throw an HttpNotFoundException if entity is null
|
* 2. throw an HttpNotFoundException if entity is null
|
||||||
* 3. check ACL using `checkACL` ;
|
* 3. check ACL using `checkACL` ;
|
||||||
* 4. launch `onPostCheckACL`. If the result is an instance of Response,
|
* 4. launch `onPostCheckACL`. If the result is an instance of Response,
|
||||||
* this response is returned ;
|
* this response is returned ;
|
||||||
* 5. Serialize the entity and return the result. The serialization context is given by `getSerializationContext`
|
* 5. Serialize the entity and return the result. The serialization context is given by `getSerializationContext`
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function entityGet(string $action, Request $request, $id, $_format = 'html'): Response
|
protected function entityGet(string $action, Request $request, $id, $_format = 'html'): Response
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($action, $id, $request, $_format);
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
|
|
||||||
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
|
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
|
||||||
|
|
||||||
if ($postFetch instanceof Response) {
|
if ($postFetch instanceof Response) {
|
||||||
return $postFetch;
|
return $postFetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->checkACL($action, $request, $_format, $entity);
|
$response = $this->checkACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
@ -86,7 +88,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
case Request::METHOD_PATCH:
|
case Request::METHOD_PATCH:
|
||||||
return $this->entityPut('_entity', $request, $id, $_format);
|
return $this->entityPut('_entity', $request, $id, $_format);
|
||||||
case Request::METHOD_POST:
|
case Request::METHOD_POST:
|
||||||
return $this->entityPostAction('_entity', $request, $id, $_format);
|
return $this->entityPostAction('_entity', $request, $id);
|
||||||
case Request::METHOD_DELETE:
|
case Request::METHOD_DELETE:
|
||||||
return $this->entityDelete('_entity', $request, $id, $_format);
|
return $this->entityDelete('_entity', $request, $id, $_format);
|
||||||
default:
|
default:
|
||||||
@ -112,9 +114,9 @@ class ApiController extends AbstractCRUDController
|
|||||||
} catch (NotEncodableValueException $e) {
|
} catch (NotEncodableValueException $e) {
|
||||||
throw new BadRequestException("invalid json", 400, $e);
|
throw new BadRequestException("invalid json", 400, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = $this->validate($action, $request, $_format, $entity);
|
$errors = $this->validate($action, $request, $_format, $entity);
|
||||||
|
|
||||||
$response = $this->onAfterValidation($action, $request, $_format, $entity, $errors);
|
$response = $this->onAfterValidation($action, $request, $_format, $entity, $errors);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
@ -126,12 +128,12 @@ class ApiController extends AbstractCRUDController
|
|||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->checkACL($action, $request, $_format, $entity);
|
$response = $this->checkACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
@ -148,33 +150,33 @@ class ApiController extends AbstractCRUDController
|
|||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->json(
|
return $this->json(
|
||||||
$entity,
|
$entity,
|
||||||
Response::HTTP_OK,
|
Response::HTTP_OK,
|
||||||
[],
|
[],
|
||||||
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
|
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public function entityPut($action, Request $request, $id, string $_format): Response
|
public function entityPut($action, Request $request, $id, string $_format): Response
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($action, $id, $request, $_format);
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
|
|
||||||
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
|
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
|
||||||
if ($postFetch instanceof Response) {
|
if ($postFetch instanceof Response) {
|
||||||
return $postFetch;
|
return $postFetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL === $entity) {
|
if (NULL === $entity) {
|
||||||
throw $this->createNotFoundException(sprintf("The %s with id %s "
|
throw $this->createNotFoundException(sprintf("The %s with id %s "
|
||||||
. "is not found", $this->getCrudName(), $id));
|
. "is not found", $this->getCrudName(), $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->checkACL($action, $request, $_format, $entity);
|
$response = $this->checkACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
@ -184,7 +186,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$entity = $this->deserialize($action, $request, $_format, $entity);
|
$entity = $this->deserialize($action, $request, $_format, $entity);
|
||||||
} catch (NotEncodableValueException $e) {
|
} catch (NotEncodableValueException $e) {
|
||||||
@ -215,13 +217,13 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $this->json(
|
return $this->json(
|
||||||
$entity,
|
$entity,
|
||||||
Response::HTTP_OK,
|
Response::HTTP_OK,
|
||||||
[],
|
[],
|
||||||
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
|
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public function entityDelete($action, Request $request, $id, string $_format): Response
|
public function entityDelete($action, Request $request, $id, string $_format): Response
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($action, $id, $request, $_format);
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
|
|
||||||
if (NULL === $entity) {
|
if (NULL === $entity) {
|
||||||
throw $this->createNotFoundException(sprintf("The %s with id %s "
|
throw $this->createNotFoundException(sprintf("The %s with id %s "
|
||||||
@ -287,7 +289,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
protected function validate(string $action, Request $request, string $_format, $entity, array $more = []): ConstraintViolationListInterface
|
protected function validate(string $action, Request $request, string $_format, $entity, array $more = []): ConstraintViolationListInterface
|
||||||
{
|
{
|
||||||
$validationGroups = $this->getValidationGroups($action, $request, $_format, $entity);
|
$validationGroups = $this->getValidationGroups($action, $request, $_format, $entity);
|
||||||
|
|
||||||
return $this->getValidator()->validate($entity, null, $validationGroups);
|
return $this->getValidator()->validate($entity, null, $validationGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +311,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
|
|
||||||
return $this->getSerializer()->deserialize($request->getContent(), $this->getEntityClass(), $_format, $context);
|
return $this->getSerializer()->deserialize($request->getContent(), $this->getEntityClass(), $_format, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base action for indexing entities
|
* Base action for indexing entities
|
||||||
@ -327,11 +329,11 @@ class ApiController extends AbstractCRUDController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an index page.
|
* Build an index page.
|
||||||
*
|
*
|
||||||
* Some steps may be overriden during this process of rendering.
|
* Some steps may be overriden during this process of rendering.
|
||||||
*
|
*
|
||||||
* This method:
|
* This method:
|
||||||
*
|
*
|
||||||
* 1. Launch `onPreIndex`
|
* 1. Launch `onPreIndex`
|
||||||
* x. check acl. If it does return a response instance, return it
|
* x. check acl. If it does return a response instance, return it
|
||||||
* x. launch `onPostCheckACL`. If it does return a response instance, return it
|
* x. launch `onPostCheckACL`. If it does return a response instance, return it
|
||||||
@ -342,7 +344,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
* x. fetch the results, using `getQueryResult`
|
* x. fetch the results, using `getQueryResult`
|
||||||
* x. Launch `onPostIndexFetchQuery`. If it does return a response instance, return it
|
* x. Launch `onPostIndexFetchQuery`. If it does return a response instance, return it
|
||||||
* 4. Serialize the entities in a Collection, using `SerializeCollection`
|
* 4. Serialize the entities in a Collection, using `SerializeCollection`
|
||||||
*
|
*
|
||||||
* @param string $action
|
* @param string $action
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return type
|
* @return type
|
||||||
@ -350,50 +352,50 @@ class ApiController extends AbstractCRUDController
|
|||||||
protected function indexApiAction($action, Request $request, $_format)
|
protected function indexApiAction($action, Request $request, $_format)
|
||||||
{
|
{
|
||||||
$this->onPreIndex($action, $request, $_format);
|
$this->onPreIndex($action, $request, $_format);
|
||||||
|
|
||||||
$response = $this->checkACL($action, $request, $_format);
|
$response = $this->checkACL($action, $request, $_format);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($entity)) {
|
if (!isset($entity)) {
|
||||||
$entity = '';
|
$entity = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalItems = $this->countEntities($action, $request, $_format);
|
$totalItems = $this->countEntities($action, $request, $_format);
|
||||||
$paginator = $this->getPaginatorFactory()->create($totalItems);
|
$paginator = $this->getPaginatorFactory()->create($totalItems);
|
||||||
|
|
||||||
$response = $this->onPreIndexBuildQuery($action, $request, $_format, $totalItems,
|
$response = $this->onPreIndexBuildQuery($action, $request, $_format, $totalItems,
|
||||||
$paginator);
|
$paginator);
|
||||||
|
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->queryEntities($action, $request, $_format, $paginator);
|
$query = $this->queryEntities($action, $request, $_format, $paginator);
|
||||||
|
|
||||||
$response = $this->onPostIndexBuildQuery($action, $request, $_format, $totalItems,
|
$response = $this->onPostIndexBuildQuery($action, $request, $_format, $totalItems,
|
||||||
$paginator, $query);
|
$paginator, $query);
|
||||||
|
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entities = $this->getQueryResult($action, $request, $_format, $totalItems, $paginator, $query);
|
$entities = $this->getQueryResult($action, $request, $_format, $totalItems, $paginator, $query);
|
||||||
|
|
||||||
$response = $this->onPostIndexFetchQuery($action, $request, $_format, $totalItems,
|
$response = $this->onPostIndexFetchQuery($action, $request, $_format, $totalItems,
|
||||||
$paginator, $entities);
|
$paginator, $entities);
|
||||||
|
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->serializeCollection($action, $request, $_format, $paginator, $entities);
|
return $this->serializeCollection($action, $request, $_format, $paginator, $entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -402,7 +404,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
* This method:
|
* This method:
|
||||||
*
|
*
|
||||||
* 1. Fetch the base entity (throw 404 if not found)
|
* 1. Fetch the base entity (throw 404 if not found)
|
||||||
* 2. checkACL,
|
* 2. checkACL,
|
||||||
* 3. run onPostCheckACL, return response if any,
|
* 3. run onPostCheckACL, return response if any,
|
||||||
* 4. deserialize posted data into the entity given by $postedDataType, with the context in $postedDataContext
|
* 4. deserialize posted data into the entity given by $postedDataType, with the context in $postedDataContext
|
||||||
* 5. run 'add+$property' for POST method, or 'remove+$property' for DELETE method
|
* 5. run 'add+$property' for POST method, or 'remove+$property' for DELETE method
|
||||||
@ -410,7 +412,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
* 7. run onAfterValidation
|
* 7. run onAfterValidation
|
||||||
* 8. if errors, return a 422 response with errors
|
* 8. if errors, return a 422 response with errors
|
||||||
* 9. if $forcePersist === true, persist the entity
|
* 9. if $forcePersist === true, persist the entity
|
||||||
* 10. flush the data
|
* 10. flush the data
|
||||||
* 11. run onAfterFlush
|
* 11. run onAfterFlush
|
||||||
* 12. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
* 12. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
||||||
*
|
*
|
||||||
@ -425,7 +427,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
* @throw BadRequestException if unable to deserialize the posted data
|
* @throw BadRequestException if unable to deserialize the posted data
|
||||||
* @throw BadRequestException if the method is not POST or DELETE
|
* @throw BadRequestException if the method is not POST or DELETE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
|
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($action, $id, $request);
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
@ -500,14 +502,14 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $this->json(
|
return $this->json(
|
||||||
$postedData,
|
$postedData,
|
||||||
Response::HTTP_OK,
|
Response::HTTP_OK,
|
||||||
[],
|
[],
|
||||||
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData])
|
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception('Unable to handle such request method.');
|
throw new \Exception('Unable to handle such request method.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize collections
|
* Serialize collections
|
||||||
*
|
*
|
||||||
@ -520,7 +522,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
|
|
||||||
return $this->json($model, Response::HTTP_OK, [], $context);
|
return $this->json($model, Response::HTTP_OK, [], $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
|
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
|
||||||
{
|
{
|
||||||
@ -537,7 +539,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the context for serialization post alter query (in case of
|
* Get the context for serialization post alter query (in case of
|
||||||
* PATCH, PUT, or POST method)
|
* PATCH, PUT, or POST method)
|
||||||
*
|
*
|
||||||
* This is called **after** the entity was altered.
|
* This is called **after** the entity was altered.
|
||||||
@ -565,7 +567,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
throw new \RuntimeException(sprintf("the config does not have any role for the ".
|
throw new \RuntimeException(sprintf("the config does not have any role for the ".
|
||||||
"method %s nor a global role for the whole action. Add those to your ".
|
"method %s nor a global role for the whole action. Add those to your ".
|
||||||
"configuration or override the required method", $request->getMethod()));
|
"configuration or override the required method", $request->getMethod()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSerializer(): SerializerInterface
|
protected function getSerializer(): SerializerInterface
|
||||||
|
@ -52,7 +52,7 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function deleteAction(string $action, Request $request, $id, $formClass = null): Response
|
protected function deleteAction(string $action, Request $request, $id, $formClass = null): Response
|
||||||
{
|
{
|
||||||
$this->onPreDelete($action, $request, $id);
|
$this->onPreDelete($action, $request);
|
||||||
|
|
||||||
$entity = $this->getEntity($action, $id, $request);
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
|
|
||||||
@ -311,11 +311,12 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function buildQueryEntities(string $action, Request $request)
|
protected function buildQueryEntities(string $action, Request $request)
|
||||||
{
|
{
|
||||||
$query = $this->getDoctrine()->getManager()
|
$query = $this
|
||||||
|
->getDoctrine()
|
||||||
|
->getManager()
|
||||||
->createQueryBuilder()
|
->createQueryBuilder()
|
||||||
->select('e')
|
->select('e')
|
||||||
->from($this->getEntityClass(), 'e')
|
->from($this->getEntityClass(), 'e');
|
||||||
;
|
|
||||||
|
|
||||||
$this->customizeQuery($action, $request, $query);
|
$this->customizeQuery($action, $request, $query);
|
||||||
|
|
||||||
@ -340,7 +341,7 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function queryEntities(string $action, Request $request, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
|
protected function queryEntities(string $action, Request $request, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
|
||||||
{
|
{
|
||||||
$query = $this->buildQueryEntities($action, $request, $filterOrder)
|
$query = $this->buildQueryEntities($action, $request)
|
||||||
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
||||||
->setMaxResults($paginator->getItemsPerPage());
|
->setMaxResults($paginator->getItemsPerPage());
|
||||||
|
|
||||||
@ -389,7 +390,7 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
|
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
|
||||||
{
|
{
|
||||||
return $this->buildQueryEntities($action, $request, $filterOrder)
|
return $this->buildQueryEntities($action, $request)
|
||||||
->select('COUNT(e)')
|
->select('COUNT(e)')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getSingleScalarResult()
|
->getSingleScalarResult()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\MainBundle\Controller;
|
namespace Chill\MainBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\AbstractCRUDController;
|
use Chill\MainBundle\CRUD\Controller\AbstractCRUDController;
|
||||||
@ -7,6 +9,7 @@ use Chill\MainBundle\CRUD\Controller\CRUDController;
|
|||||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -16,40 +19,23 @@ use Chill\MainBundle\Form\UserType;
|
|||||||
use Chill\MainBundle\Entity\GroupCenter;
|
use Chill\MainBundle\Entity\GroupCenter;
|
||||||
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
|
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
|
||||||
use Chill\MainBundle\Form\UserPasswordType;
|
use Chill\MainBundle\Form\UserPasswordType;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class UserController
|
|
||||||
*
|
|
||||||
* @package Chill\MainBundle\Controller
|
|
||||||
*/
|
|
||||||
class UserController extends CRUDController
|
class UserController extends CRUDController
|
||||||
{
|
{
|
||||||
|
|
||||||
const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
|
const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
|
||||||
|
|
||||||
/**
|
private LoggerInterface $logger;
|
||||||
* @var \Psr\Log\LoggerInterface
|
|
||||||
*/
|
|
||||||
private $logger;
|
|
||||||
|
|
||||||
/**
|
private ValidatorInterface $validator;
|
||||||
* @var ValidatorInterface
|
|
||||||
*/
|
|
||||||
private $validator;
|
|
||||||
|
|
||||||
private UserPasswordEncoderInterface $passwordEncoder;
|
private UserPasswordEncoderInterface $passwordEncoder;
|
||||||
|
|
||||||
/**
|
|
||||||
* UserController constructor.
|
|
||||||
*
|
|
||||||
* @param LoggerInterface $logger
|
|
||||||
* @param ValidatorInterface $validator
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LoggerInterface $chillLogger,
|
LoggerInterface $chillLogger,
|
||||||
ValidatorInterface $validator,
|
ValidatorInterface $validator,
|
||||||
@ -121,7 +107,7 @@ class UserController extends CRUDController
|
|||||||
*/
|
*/
|
||||||
public function editPasswordAction(User $user, Request $request)
|
public function editPasswordAction(User $user, Request $request)
|
||||||
{
|
{
|
||||||
$editForm = $this->createEditPasswordForm($user, $request);
|
$editForm = $this->createEditPasswordForm($user);
|
||||||
$editForm->handleRequest($request);
|
$editForm->handleRequest($request);
|
||||||
|
|
||||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||||
@ -208,7 +194,7 @@ class UserController extends CRUDController
|
|||||||
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
|
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
|
||||||
* name="admin_user_add_groupcenter")
|
* name="admin_user_add_groupcenter")
|
||||||
*/
|
*/
|
||||||
public function addLinkGroupCenterAction(Request $request, $uid): RedirectResponse
|
public function addLinkGroupCenterAction(Request $request, $uid): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
@ -238,23 +224,22 @@ class UserController extends CRUDController
|
|||||||
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit',
|
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit',
|
||||||
\array_merge(['id' => $uid], $returnPathParams)));
|
\array_merge(['id' => $uid], $returnPathParams)));
|
||||||
|
|
||||||
} else {
|
}
|
||||||
foreach($this->validator->validate($user) as $error)
|
|
||||||
|
foreach($this->validator->validate($user) as $error) {
|
||||||
$this->addFlash('error', $error->getMessage());
|
$this->addFlash('error', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('@ChillMain/User/edit.html.twig', array(
|
return $this->render('@ChillMain/User/edit.html.twig', [
|
||||||
'entity' => $user,
|
'entity' => $user,
|
||||||
'edit_form' => $this->createEditForm($user)->createView(),
|
'edit_form' => $this->createEditForm($user)->createView(),
|
||||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user, $request)->createView(),
|
||||||
'delete_groupcenter_form' => array_map(
|
'delete_groupcenter_form' => array_map(
|
||||||
function(\Symfony\Component\Form\Form $form) {
|
static fn(Form $form) => $form->createView(),
|
||||||
return $form->createView();
|
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user, $request), true)
|
||||||
|
)
|
||||||
},
|
]);
|
||||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPersistedGroupCenter(GroupCenter $groupCenter)
|
private function getPersistedGroupCenter(GroupCenter $groupCenter)
|
||||||
@ -279,10 +264,8 @@ class UserController extends CRUDController
|
|||||||
* Creates a form to delete a link to a GroupCenter
|
* Creates a form to delete a link to a GroupCenter
|
||||||
*
|
*
|
||||||
* @param mixed $permissionsGroup The entity id
|
* @param mixed $permissionsGroup The entity id
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
*/
|
||||||
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request)
|
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request): FormInterface
|
||||||
{
|
{
|
||||||
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
|
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
|
||||||
|
|
||||||
@ -291,39 +274,29 @@ class UserController extends CRUDController
|
|||||||
array_merge($returnPathParams, ['uid' => $user->getId(), 'gcid' => $groupCenter->getId()])))
|
array_merge($returnPathParams, ['uid' => $user->getId(), 'gcid' => $groupCenter->getId()])))
|
||||||
->setMethod('DELETE')
|
->setMethod('DELETE')
|
||||||
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||||
->getForm()
|
->getForm();
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a form to add a link to a groupcenter
|
* Create a form to add a link to a groupcenter.
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @return \Symfony\Component\Form\Form
|
|
||||||
*/
|
*/
|
||||||
private function createAddLinkGroupCenterForm(User $user, Request $request)
|
private function createAddLinkGroupCenterForm(User $user, Request $request): FormInterface
|
||||||
{
|
{
|
||||||
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
|
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
|
||||||
|
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('admin_user_add_groupcenter',
|
->setAction($this->generateUrl('admin_user_add_groupcenter',
|
||||||
array_merge($returnPathParams, ['uid' => $user->getId()])))
|
array_merge($returnPathParams, ['uid' => $user->getId()])))
|
||||||
->setMethod('POST')
|
->setMethod('POST')
|
||||||
->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class)
|
->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class)
|
||||||
->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
|
->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
|
||||||
->getForm()
|
->getForm();
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
private function getDeleteLinkGroupCenterByUser(User $user, Request $request)
|
private function getDeleteLinkGroupCenterByUser(User $user, Request $request)
|
||||||
{
|
{
|
||||||
foreach ($user->getGroupCenters() as $groupCenter) {
|
foreach ($user->getGroupCenters() as $groupCenter) {
|
||||||
yield $groupCenter->getId() => $this
|
yield $groupCenter->getId() => $this->createDeleteLinkGroupCenterForm($user, $groupCenter, $request);
|
||||||
->createDeleteLinkGroupCenterForm($user, $groupCenter, $request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\MainBundle\Search;
|
namespace Chill\MainBundle\Search;
|
||||||
|
|
||||||
use Chill\MainBundle\Search\Entity\SearchUserApiProvider;
|
use Chill\MainBundle\Search\Entity\SearchUserApiProvider;
|
||||||
@ -13,8 +15,6 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
|||||||
use Chill\MainBundle\Search\SearchProvider;
|
use Chill\MainBundle\Search\SearchProvider;
|
||||||
use Symfony\Component\VarDumper\Resources\functions\dump;
|
use Symfony\Component\VarDumper\Resources\functions\dump;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
class SearchApi
|
class SearchApi
|
||||||
{
|
{
|
||||||
private EntityManagerInterface $em;
|
private EntityManagerInterface $em;
|
||||||
@ -28,8 +28,7 @@ class SearchApi
|
|||||||
ThirdPartyApiSearch $thirdPartyApiSearch,
|
ThirdPartyApiSearch $thirdPartyApiSearch,
|
||||||
SearchUserApiProvider $searchUser,
|
SearchUserApiProvider $searchUser,
|
||||||
PaginatorFactory $paginator
|
PaginatorFactory $paginator
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->providers[] = $searchPerson;
|
$this->providers[] = $searchPerson;
|
||||||
$this->providers[] = $thirdPartyApiSearch;
|
$this->providers[] = $thirdPartyApiSearch;
|
||||||
@ -126,7 +125,7 @@ class SearchApi
|
|||||||
|
|
||||||
private function fetchRawResult($queries, $types, $parameters, $paginator): array
|
private function fetchRawResult($queries, $types, $parameters, $paginator): array
|
||||||
{
|
{
|
||||||
list($union, $parameters) = $this->buildUnionQuery($queries, $types, $parameters, $paginator);
|
list($union, $parameters) = $this->buildUnionQuery($queries, $types, $parameters);
|
||||||
$rsm = new ResultSetMappingBuilder($this->em);
|
$rsm = new ResultSetMappingBuilder($this->em);
|
||||||
$rsm->addScalarResult('key', 'key', Types::STRING)
|
$rsm->addScalarResult('key', 'key', Types::STRING)
|
||||||
->addScalarResult('metadata', 'metadata', Types::JSON)
|
->addScalarResult('metadata', 'metadata', Types::JSON)
|
||||||
|
@ -1,21 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
declare(strict_types=1);
|
||||||
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Security\Authorization;
|
namespace Chill\MainBundle\Security\Authorization;
|
||||||
|
|
||||||
@ -43,7 +28,6 @@ use Chill\MainBundle\Entity\RoleScope;
|
|||||||
* Helper for authorizations.
|
* Helper for authorizations.
|
||||||
*
|
*
|
||||||
* Provides methods for user and entities information.
|
* Provides methods for user and entities information.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class AuthorizationHelper implements AuthorizationHelperInterface
|
class AuthorizationHelper implements AuthorizationHelperInterface
|
||||||
{
|
{
|
||||||
@ -74,11 +58,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
/**
|
/**
|
||||||
* Determines if a user is active on this center
|
* Determines if a user is active on this center
|
||||||
*
|
*
|
||||||
* If
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @param Center|Center[] $center May be an array of center
|
* @param Center|Center[] $center May be an array of center
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function userCanReachCenter(User $user, $center): bool
|
public function userCanReachCenter(User $user, $center): bool
|
||||||
{
|
{
|
||||||
@ -89,7 +69,9 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} elseif ($center instanceof Center) {
|
}
|
||||||
|
|
||||||
|
if ($center instanceof Center) {
|
||||||
foreach ($user->getGroupCenters() as $groupCenter) {
|
foreach ($user->getGroupCenters() as $groupCenter) {
|
||||||
if ($center->getId() === $groupCenter->getCenter()->getId()) {
|
if ($center->getId() === $groupCenter->getCenter()->getId()) {
|
||||||
return true;
|
return true;
|
||||||
@ -99,12 +81,16 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \UnexpectedValueException(sprintf("The entity given is not an ".
|
throw new \UnexpectedValueException(
|
||||||
"instance of %s, %s given", Center::class, get_class($center)));
|
sprintf(
|
||||||
|
'The entity given is not an instance of %s, %s given',
|
||||||
|
Center::class,
|
||||||
|
get_class($center)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Determines if the user has access to the given entity.
|
* Determines if the user has access to the given entity.
|
||||||
*
|
*
|
||||||
* if the entity implements Chill\MainBundle\Entity\HasScopeInterface,
|
* if the entity implements Chill\MainBundle\Entity\HasScopeInterface,
|
||||||
@ -243,7 +229,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($centers as $center) {
|
foreach ($centers as $center) {
|
||||||
if ($this->userCanReachCenter($user, $center, $role)) {
|
if ($this->userCanReachCenter($user, $center)) {
|
||||||
$results[] = $center;
|
$results[] = $center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,6 +494,7 @@ EOF
|
|||||||
$openingDateString = trim($row[array_search('opening_date', $headers)]);
|
$openingDateString = trim($row[array_search('opening_date', $headers)]);
|
||||||
$openingDate = $this->processDate($openingDateString, $this->input->getOption('opening_date_format'));
|
$openingDate = $this->processDate($openingDateString, $this->input->getOption('opening_date_format'));
|
||||||
|
|
||||||
|
// @TODO: Fix the constructor parameter, $openingDate does not exists.
|
||||||
$person = $openingDate instanceof \DateTime ? new Person($openingDate) : new Person();
|
$person = $openingDate instanceof \DateTime ? new Person($openingDate) : new Person();
|
||||||
// add the center
|
// add the center
|
||||||
$center = $this->getCenter($row, $headers);
|
$center = $this->getCenter($row, $headers);
|
||||||
|
@ -1,26 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity;
|
declare(strict_types=1);
|
||||||
|
|
||||||
/*
|
namespace Chill\PersonBundle\Entity;
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
@ -1330,7 +1312,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*/
|
*/
|
||||||
public function getLastAddress(DateTime $from = null)
|
public function getLastAddress(DateTime $from = null)
|
||||||
{
|
{
|
||||||
return $this->getCurrentPersonAddress($from);
|
return $this->getCurrentPersonAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user