mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
fix error with getInt() and inject PaginatorFactory service in EventController
This commit is contained in:
parent
d4948b176f
commit
7730f732ed
@ -24,6 +24,7 @@ namespace Chill\EventBundle\Controller;
|
||||
|
||||
use Chill\EventBundle\Entity\Participation;
|
||||
use Chill\EventBundle\Form\Type\PickEventType;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Csv;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
||||
@ -77,6 +78,11 @@ class EventController extends Controller
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @var PaginatorFactory
|
||||
*/
|
||||
protected $paginator;
|
||||
|
||||
/**
|
||||
* EventController constructor.
|
||||
*
|
||||
@ -84,18 +90,21 @@ class EventController extends Controller
|
||||
* @param AuthorizationHelper $authorizationHelper
|
||||
* @param FormFactoryInterface $formFactoryInterface
|
||||
* @param TranslatorInterface $translator
|
||||
* @param PaginatorFactory $paginator
|
||||
*/
|
||||
public function __construct(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
FormFactoryInterface $formFactoryInterface,
|
||||
TranslatorInterface $translator
|
||||
TranslatorInterface $translator,
|
||||
PaginatorFactory $paginator
|
||||
)
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->formFactoryInterface = $formFactoryInterface;
|
||||
$this->translator = $translator;
|
||||
$this->paginator = $paginator;
|
||||
}
|
||||
|
||||
|
||||
@ -388,11 +397,7 @@ class EventController extends Controller
|
||||
|
||||
$total = $em->getRepository('ChillEventBundle:Participation')->countByPerson($person_id);
|
||||
|
||||
/**
|
||||
* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory
|
||||
*/
|
||||
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
||||
$paginator = $paginatorFactory->create($total);
|
||||
$paginator = $this->paginator->create($total);
|
||||
|
||||
$participations = $em->getRepository('ChillEventBundle:Participation')->findByPersonInCircle(
|
||||
$person_id,
|
||||
|
@ -369,7 +369,8 @@ class ParticipationController extends Controller
|
||||
. "the object manager using the method ".__METHOD__);
|
||||
}
|
||||
|
||||
$event_id = $request->query->getInt('event_id', null);
|
||||
$event_id = $request->query->getInt('event_id', 0); // sf4 check:
|
||||
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
|
||||
|
||||
if ($event_id !== NULL) {
|
||||
$event = $em->getRepository('ChillEventBundle:Event')
|
||||
@ -388,9 +389,9 @@ class ParticipationController extends Controller
|
||||
// this script should be able to handle multiple, so we translate
|
||||
// single person_id in an array
|
||||
$persons_ids = $request->query->has('person_id') ?
|
||||
array($request->query->getInt('person_id', null)):
|
||||
explode(',', $request->query->get('persons_ids'))
|
||||
;
|
||||
[$request->query->getInt('person_id', 0)] // sf4 check:
|
||||
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
|
||||
: explode(',', $request->query->get('persons_ids'));
|
||||
$participations = array();
|
||||
|
||||
foreach($persons_ids as $person_id) {
|
||||
|
@ -1,4 +1,2 @@
|
||||
services:
|
||||
Chill\EventBundle\:
|
||||
resource: '../../*'
|
||||
exclude: '../../{Entity,Resources/migrations,Resources/test}'
|
||||
|
||||
|
@ -6,5 +6,6 @@ services:
|
||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||
$formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface'
|
||||
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||
$paginator: '@chill_main.paginator_factory'
|
||||
public: true
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user