mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-25 00:53:48 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -17,16 +17,11 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Chill\ReportBundle\Form\ReportType;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Class ReportController.
|
||||
@@ -64,11 +59,11 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Create a new report for a given person and of a given type.
|
||||
*
|
||||
* @param int $person_id The id of the person.
|
||||
* @param int $cf_group_id The id of the report type.
|
||||
* @param Request $request The request containing the form data (from the newAction)
|
||||
* @param int $person_id the id of the person
|
||||
* @param int $cf_group_id the id of the report type
|
||||
* @param Request $request The request containing the form data (from the newAction)
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function createAction($person_id, $cf_group_id, Request $request)
|
||||
{
|
||||
@@ -127,10 +122,10 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Display a form to edit an existing Report entity.
|
||||
*
|
||||
* @param int|string $person_id The id of the person.
|
||||
* @param int|string $report_id The id of the report.
|
||||
* @param int|string $person_id the id of the person
|
||||
* @param int|string $report_id the id of the report
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function editAction(int|string $person_id, int|string $report_id)
|
||||
{
|
||||
@@ -140,16 +135,11 @@ class ReportController extends AbstractController
|
||||
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
|
||||
if (!$report) {
|
||||
throw $this->createNotFoundException(
|
||||
$this->get('translator')->trans('Unable to find this report.')
|
||||
);
|
||||
throw $this->createNotFoundException($this->get('translator')->trans('Unable to find this report.'));
|
||||
}
|
||||
|
||||
if ((int) $person_id !== (int) $report->getPerson()->getId()) {
|
||||
throw new RuntimeException(
|
||||
$this->get('translator')->trans('This is not the report of the person.'),
|
||||
1
|
||||
);
|
||||
throw new \RuntimeException($this->get('translator')->trans('This is not the report of the person.'), 1);
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report);
|
||||
@@ -174,8 +164,8 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Return a csv file with all the reports of a given type.
|
||||
*
|
||||
* @param int $cf_group_id The id of the report type to export
|
||||
* @param Request $request The request
|
||||
* @param int $cf_group_id The id of the report type to export
|
||||
* @param Request $request The request
|
||||
*
|
||||
* @return A csv file with all the reports of the selected type
|
||||
*/
|
||||
@@ -200,10 +190,10 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* List all the report entities for a given person.
|
||||
*
|
||||
* @param int $person_id The id of the person.
|
||||
* @param Request $request The request
|
||||
* @param int $person_id the id of the person
|
||||
* @param Request $request The request
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function listAction($person_id, Request $request)
|
||||
{
|
||||
@@ -222,7 +212,7 @@ class ReportController extends AbstractController
|
||||
|
||||
$total = $em
|
||||
->createQuery('SELECT COUNT(r.id) FROM ChillReportBundle:Report r '
|
||||
. 'WHERE r.person = :person AND r.scope IN (:scopes) ')
|
||||
.'WHERE r.person = :person AND r.scope IN (:scopes) ')
|
||||
->setParameter('person', $person)
|
||||
->setParameter('scopes', $reachableScopes)
|
||||
->getSingleScalarResult();
|
||||
@@ -256,11 +246,11 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Display a form for creating a new report for a given person and of a given type.
|
||||
*
|
||||
* @param int $person_id The id of the person.
|
||||
* @param int $cf_group_id The id of the report type.
|
||||
* @param Request $request The request
|
||||
* @param int $person_id the id of the person
|
||||
* @param int $cf_group_id the id of the report type
|
||||
* @param Request $request The request
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function newAction($person_id, $cf_group_id, Request $request)
|
||||
{
|
||||
@@ -289,7 +279,7 @@ class ReportController extends AbstractController
|
||||
|
||||
$entity = new Report();
|
||||
$entity->setUser($this->get('security.token_storage')->getToken()->getUser());
|
||||
$entity->setDate(new DateTime('now'));
|
||||
$entity->setDate(new \DateTime('now'));
|
||||
|
||||
$entity->setCFGroup($cFGroup);
|
||||
|
||||
@@ -305,10 +295,10 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Display a form for selecting which type of report to add for a given person.
|
||||
*
|
||||
* @param int $person_id The id of the person.
|
||||
* @param Request $request The request
|
||||
* @param int $person_id the id of the person
|
||||
* @param Request $request The request
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function selectReportTypeAction($person_id, Request $request)
|
||||
{
|
||||
@@ -338,7 +328,7 @@ class ReportController extends AbstractController
|
||||
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
|
||||
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
|
||||
|
||||
if (count($cFGroups) === 1) {
|
||||
if (1 === \count($cFGroups)) {
|
||||
return $this->redirectToRoute('report_new', ['person_id' => $person_id, 'cf_group_id' => $cFGroups[0]->getId()]);
|
||||
}
|
||||
|
||||
@@ -372,7 +362,7 @@ class ReportController extends AbstractController
|
||||
*
|
||||
* @param Request $request The request
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function selectReportTypeForExportAction(Request $request)
|
||||
{
|
||||
@@ -387,7 +377,7 @@ class ReportController extends AbstractController
|
||||
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
|
||||
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
|
||||
|
||||
if (count($cFGroups) === 1) {
|
||||
if (1 === \count($cFGroups)) {
|
||||
return $this->redirectToRoute('report_export_list', ['cf_group_id' => $cFGroups[0]->getId()]);
|
||||
}
|
||||
|
||||
@@ -416,10 +406,10 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Web page for editing an existing report.
|
||||
*
|
||||
* @param int $person_id The id of the person.
|
||||
* @param int $report_id The id of the report.
|
||||
* @param int $person_id the id of the person
|
||||
* @param int $report_id the id of the report
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function updateAction($person_id, $report_id, Request $request)
|
||||
{
|
||||
@@ -428,9 +418,7 @@ class ReportController extends AbstractController
|
||||
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
|
||||
if (!$report) {
|
||||
throw $this->createNotFoundException(
|
||||
$this->get('translator')->trans('Unable to find this report.')
|
||||
);
|
||||
throw $this->createNotFoundException($this->get('translator')->trans('Unable to find this report.'));
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_REPORT_UPDATE', $report);
|
||||
@@ -478,10 +466,10 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Find and display a report.
|
||||
*
|
||||
* @param int $report_id The id of the report.
|
||||
* @param int $person_id The id of the person.
|
||||
* @param int $report_id the id of the report
|
||||
* @param int $person_id the id of the person
|
||||
*
|
||||
* @return Response The web page.
|
||||
* @return Response the web page
|
||||
*/
|
||||
public function viewAction($report_id, $person_id)
|
||||
{
|
||||
@@ -492,9 +480,7 @@ class ReportController extends AbstractController
|
||||
$entity = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
|
||||
if (!$entity || !$person) {
|
||||
throw $this->createNotFoundException(
|
||||
$this->get('translator')->trans('Unable to find this report.')
|
||||
);
|
||||
throw $this->createNotFoundException($this->get('translator')->trans('Unable to find this report.'));
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_REPORT_SEE', $entity);
|
||||
@@ -537,7 +523,7 @@ class ReportController extends AbstractController
|
||||
/**
|
||||
* Creates a form to edit a Report entity.
|
||||
*
|
||||
* @param Report $entity The report to edit.
|
||||
* @param Report $entity the report to edit
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
|
@@ -16,8 +16,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Load CustomField for Report into database.
|
||||
*/
|
||||
@@ -68,7 +66,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
];
|
||||
|
||||
for ($i = 0; 25 >= $i; ++$i) {
|
||||
$cFType = $cFTypes[random_int(0, count($cFTypes) - 1)];
|
||||
$cFType = $cFTypes[random_int(0, \count($cFTypes) - 1)];
|
||||
|
||||
$customField = (new CustomField())
|
||||
->setSlug("cf_report_{$i}")
|
||||
@@ -76,7 +74,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
->setOptions($cFType['options'])
|
||||
->setName(['fr' => "CustomField {$i}"])
|
||||
->setOrdering(random_int(0, 1000) / 1000)
|
||||
->setCustomFieldsGroup($this->getReference('cf_group_report_' . (random_int(0, 3))));
|
||||
->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3)));
|
||||
|
||||
$manager->persist($customField);
|
||||
}
|
||||
@@ -88,7 +86,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
private function createExpectedFields(ObjectManager $manager)
|
||||
{
|
||||
//report logement
|
||||
// report logement
|
||||
$reportLogement = $this->getReference('cf_group_report_logement');
|
||||
|
||||
$houseTitle = (new CustomField())
|
||||
@@ -144,7 +142,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
|
||||
->setCustomFieldsGroup($reportLogement);
|
||||
$manager->persist($descriptionLogement);
|
||||
|
||||
//report problems
|
||||
// report problems
|
||||
$reportEducation = $this->getReference('cf_group_report_education');
|
||||
|
||||
$title = (new CustomField())
|
||||
|
@@ -44,9 +44,9 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt
|
||||
$this->addReference('cf_group_report_education', $report);
|
||||
|
||||
for ($i = 0; 3 >= $i; ++$i) {
|
||||
$report = $this->createReport($manager, ['fr' => 'ZZ Rapport aléatoire ' . $i]);
|
||||
$report = $this->createReport($manager, ['fr' => 'ZZ Rapport aléatoire '.$i]);
|
||||
|
||||
$this->addReference('cf_group_report_' . $i, $report);
|
||||
$this->addReference('cf_group_report_'.$i, $report);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
@@ -62,7 +62,7 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt
|
||||
array $name,
|
||||
array $options = []
|
||||
) {
|
||||
echo $name['fr'] . " \n";
|
||||
echo $name['fr']." \n";
|
||||
|
||||
$cFGroup = (new CustomFieldsGroup())
|
||||
->setName($name)
|
||||
|
@@ -18,8 +18,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Add a role CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE for all groups except administrative,
|
||||
* and a role CHILL_REPORT_SEE for administrative.
|
||||
@@ -40,10 +38,10 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
foreach (LoadScopes::$references as $scopeRef) {
|
||||
$scope = $this->getReference($scopeRef);
|
||||
printf("processing scope %s \n", $scope->getName()['en']);
|
||||
//create permission group
|
||||
// create permission group
|
||||
switch ($permissionsGroup->getName()) {
|
||||
case 'social':
|
||||
if ($scope->getName()['en'] === 'administrative') {
|
||||
if ('administrative' === $scope->getName()['en']) {
|
||||
printf("denying power on administrative \n");
|
||||
|
||||
break 2; // we do not want any power on administrative
|
||||
@@ -53,7 +51,7 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
case 'administrative':
|
||||
case 'direction':
|
||||
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||
if (\in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||
printf("denying power on %s\n", $scope->getName()['en']);
|
||||
|
||||
break 2; // we do not want any power on social or administrative
|
||||
@@ -64,7 +62,7 @@ class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
printf(
|
||||
'Adding CHILL_REPORT_UPDATE & CHILL_REPORT_CREATE to %s '
|
||||
. "permission group, scope '%s' \n",
|
||||
."permission group, scope '%s' \n",
|
||||
$permissionsGroup->getName(),
|
||||
$scope->getName()['en']
|
||||
);
|
||||
|
@@ -16,16 +16,11 @@ use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use DateTime;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Faker\Factory as FakerFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Load reports into DB.
|
||||
@@ -49,7 +44,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
{
|
||||
$this->createExpected($manager);
|
||||
|
||||
//create random 2 times, to allow multiple report on some people
|
||||
// create random 2 times, to allow multiple report on some people
|
||||
$this->createRandom($manager, 90);
|
||||
$this->createRandom($manager, 30);
|
||||
|
||||
@@ -66,7 +61,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$report = (new Report())
|
||||
->setPerson($charline)
|
||||
->setCFGroup($this->getReference('cf_group_report_logement'))
|
||||
->setDate(new DateTime('2015-01-05'))
|
||||
->setDate(new \DateTime('2015-01-05'))
|
||||
->setScope($this->getReference('scope_social'));
|
||||
$this->fillReport($report);
|
||||
|
||||
@@ -81,7 +76,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$people = $this->getPeopleRandom($percentage);
|
||||
|
||||
foreach ($people as $person) {
|
||||
//create a report, set logement or education report
|
||||
// create a report, set logement or education report
|
||||
$report = (new Report())
|
||||
->setPerson($person)
|
||||
->setCFGroup(
|
||||
@@ -97,16 +92,16 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
|
||||
private function fillReport(Report $report)
|
||||
{
|
||||
//setUser
|
||||
// setUser
|
||||
$usernameRef = array_rand(LoadUsers::$refs);
|
||||
$report->setUser(
|
||||
$this->getReference($usernameRef)
|
||||
);
|
||||
|
||||
//set date if null
|
||||
if ($report->getDate() === null) {
|
||||
//set date. 30% of the dates are 2015-05-01
|
||||
$expectedDate = new DateTime('2015-01-05');
|
||||
// set date if null
|
||||
if (null === $report->getDate()) {
|
||||
// set date. 30% of the dates are 2015-05-01
|
||||
$expectedDate = new \DateTime('2015-01-05');
|
||||
|
||||
if (random_int(0, 100) < 30) {
|
||||
$report->setDate($expectedDate);
|
||||
@@ -116,7 +111,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
}
|
||||
}
|
||||
|
||||
//fill data
|
||||
// fill data
|
||||
$datas = [];
|
||||
|
||||
foreach ($report->getCFGroup()->getCustomFields() as $field) {
|
||||
@@ -148,7 +143,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
->getRepository(Person::class)
|
||||
->findAll();
|
||||
|
||||
//keep only a part ($percentage) of the people
|
||||
// keep only a part ($percentage) of the people
|
||||
$selectedPeople = [];
|
||||
|
||||
foreach ($people as $person) {
|
||||
@@ -171,16 +166,16 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$multiple = $field->getOptions()['multiple'];
|
||||
$other = $field->getOptions()['other'];
|
||||
|
||||
//add other if allowed
|
||||
// add other if allowed
|
||||
if ($other) {
|
||||
$choices[] = ['slug' => '_other'];
|
||||
}
|
||||
|
||||
//initialize results
|
||||
// initialize results
|
||||
$picked = [];
|
||||
|
||||
if ($multiple) {
|
||||
$numberSelected = random_int(1, count($choices) - 1);
|
||||
$numberSelected = random_int(1, \count($choices) - 1);
|
||||
|
||||
for ($i = 0; $i < $numberSelected; ++$i) {
|
||||
$picked[] = $this->pickChoice($choices);
|
||||
@@ -189,7 +184,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
if ($other) {
|
||||
$result = ['_other' => null, '_choices' => $picked];
|
||||
|
||||
if (in_array('_other', $picked, true)) {
|
||||
if (\in_array('_other', $picked, true)) {
|
||||
$result['_other'] = $this->faker->realText(70);
|
||||
}
|
||||
|
||||
|
@@ -62,7 +62,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('services/fixtures.yaml');
|
||||
$loader->load('services/export.yaml');
|
||||
|
@@ -25,7 +25,9 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Class Report.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="report")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Report implements HasCenterInterface, HasScopeInterface
|
||||
@@ -47,10 +49,10 @@ class Report implements HasCenterInterface, HasScopeInterface
|
||||
private ?\DateTime $date = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -101,7 +103,7 @@ class Report implements HasCenterInterface, HasScopeInterface
|
||||
/**
|
||||
* Get date.
|
||||
*/
|
||||
public function getDate(): ?DateTime
|
||||
public function getDate(): ?\DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
@@ -173,7 +175,7 @@ class Report implements HasCenterInterface, HasScopeInterface
|
||||
/**
|
||||
* Set date.
|
||||
*
|
||||
* @param DateTime $date
|
||||
* @param \DateTime $date
|
||||
*
|
||||
* @return Report
|
||||
*/
|
||||
|
@@ -25,28 +25,14 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Chill\ReportBundle\Security\Authorization\ReportVoter;
|
||||
use Closure;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function array_merge;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function strlen;
|
||||
use function strtolower;
|
||||
use function ucfirst;
|
||||
use function uniqid;
|
||||
|
||||
class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
{
|
||||
protected array $fields = [
|
||||
@@ -86,16 +72,16 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
return [];
|
||||
},
|
||||
'choice_label' => fn (string $key, string $label): string => match (substr($key, 0, 7)) {
|
||||
'person_' => $this->translator->trans(substr($key, 7, strlen($key) - 7)) .
|
||||
' (' . $this->translator->trans('Person') . ')',
|
||||
'report_' => $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) .
|
||||
' (' . $this->translator->trans('Report') . ')',
|
||||
default => $label .
|
||||
' (' . $this->translator->trans("Report's question") . ')',
|
||||
'person_' => $this->translator->trans(substr($key, 7, \strlen($key) - 7)).
|
||||
' ('.$this->translator->trans('Person').')',
|
||||
'report_' => $this->translator->trans(\ucfirst(substr($key, 7, \strlen($key) - 7))).
|
||||
' ('.$this->translator->trans('Report').')',
|
||||
default => $label.
|
||||
' ('.$this->translator->trans("Report's question").')',
|
||||
},
|
||||
'constraints' => [new Callback([
|
||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
||||
if (count($selected) === 0) {
|
||||
if (0 === \count($selected)) {
|
||||
$context->buildViolation('You must select at least one element')
|
||||
->atPath('fields')
|
||||
->addViolation();
|
||||
@@ -110,9 +96,10 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
'block_name' => 'list_export_form_address_date',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['address_date' => new DateTime()];
|
||||
return ['address_date' => new \DateTime()];
|
||||
}
|
||||
|
||||
public function getAllowedFormattersTypes()
|
||||
@@ -147,14 +134,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
}
|
||||
|
||||
if ('person_birthdate' === $key) {
|
||||
$date = DateTime::createFromFormat('Y-m-d', $value);
|
||||
$date = \DateTime::createFromFormat('Y-m-d', $value);
|
||||
} else {
|
||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||
}
|
||||
// check that the creation could occurs.
|
||||
if (false === $date) {
|
||||
throw new Exception(sprintf('The value %s could '
|
||||
. 'not be converted to %s', $value, DateTime::class));
|
||||
throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class));
|
||||
}
|
||||
|
||||
return $date->format('d-m-Y');
|
||||
@@ -224,7 +210,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
|
||||
return function ($value) use ($key, $countryRepository) {
|
||||
if ('_header' === $value) {
|
||||
return strtolower($key);
|
||||
return \strtolower($key);
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -241,7 +227,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
case 'person_address_country_name':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return strtolower($key);
|
||||
return \strtolower($key);
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -253,10 +239,10 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
|
||||
default:
|
||||
// for fields which are associated with person
|
||||
if (in_array($key, $this->fields, true)) {
|
||||
if (\in_array($key, $this->fields, true)) {
|
||||
return static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return strtolower($key);
|
||||
return \strtolower($key);
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -272,13 +258,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
$fields = [];
|
||||
|
||||
foreach ($data['fields'] as $key) {
|
||||
if (in_array($key, $this->fields, true)) {
|
||||
if (\in_array($key, $this->fields, true)) {
|
||||
$fields[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
// add the key from slugs and return
|
||||
return [...$fields, ...array_keys($this->slugs)];
|
||||
return [...$fields, ...\array_keys($this->slugs)];
|
||||
}
|
||||
|
||||
public function getResult($query, $data)
|
||||
@@ -306,9 +292,8 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
// throw an error if any fields are present
|
||||
if (!array_key_exists('fields', $data)) {
|
||||
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields '
|
||||
. 'have been checked');
|
||||
if (!\array_key_exists('fields', $data)) {
|
||||
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields have been checked');
|
||||
}
|
||||
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
@@ -316,7 +301,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
// process fields which are not custom fields
|
||||
foreach ($this->fields as $f) {
|
||||
// do not add fields which are not selected
|
||||
if (!in_array($f, $data['fields'], true)) {
|
||||
if (!\in_array($f, $data['fields'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -367,8 +352,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
'person_' => $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)),
|
||||
'report_' => $qb->addSelect(sprintf('report.%s as %s', $suffix, $f)),
|
||||
// no break
|
||||
default => throw new LogicException("this prefix {$prefix} should "
|
||||
. "not be encountered. Full field: {$f}"),
|
||||
default => throw new \LogicException("this prefix {$prefix} should not be encountered. Full field: {$f}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -376,7 +360,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
// process fields which are custom fields
|
||||
foreach ($this->getCustomFields() as $cf) {
|
||||
// do not add custom fields which are not selected
|
||||
if (!in_array($cf->getSlug(), $data['fields'], true)) {
|
||||
if (!\in_array($cf->getSlug(), $data['fields'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -438,7 +422,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
);
|
||||
|
||||
// check if there is one field starting with address in data
|
||||
if (count(array_intersect($data['fields'], $addressFields)) > 0) {
|
||||
if (\count(array_intersect($data['fields'], $addressFields)) > 0) {
|
||||
// if a field address is checked, the date must not be empty
|
||||
if (empty($data['address_date'])) {
|
||||
$context
|
||||
@@ -467,7 +451,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
private function getCustomFields()
|
||||
{
|
||||
return array_filter($this->customfieldsGroup
|
||||
->getCustomFields()->toArray(), static fn (CustomField $cf) => $cf->getType() !== 'title');
|
||||
->getCustomFields()->toArray(), static fn (CustomField $cf) => 'title' !== $cf->getType());
|
||||
}
|
||||
|
||||
private function getLabelForCustomField($key, array $values, $data)
|
||||
@@ -498,7 +482,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
$label = $cfType->getChoices($cf)[$slugChoice];
|
||||
|
||||
return $this->translatableStringHelper->localize($cf->getName())
|
||||
. ' | ' . $label;
|
||||
.' | '.$label;
|
||||
}
|
||||
|
||||
if ('_other' === $slugChoice && $cfType->isChecked($cf, $slugChoice, $decoded)) {
|
||||
@@ -514,7 +498,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
||||
|
||||
private function slugToDQL($slug, $type = 'default', array $additionalInfos = [])
|
||||
{
|
||||
$uid = 'slug_' . uniqid('', true);
|
||||
$uid = 'slug_'.\uniqid('', true);
|
||||
|
||||
$this->slugs[$uid] = [
|
||||
'slug' => $slug,
|
||||
|
@@ -67,6 +67,7 @@ class ReportDateFilter implements FilterInterface
|
||||
'label' => 'Report is before this date',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];
|
||||
@@ -75,7 +76,7 @@ class ReportDateFilter implements FilterInterface
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return ['Filtered by report\'s date: '
|
||||
. 'between %date_from% and %date_to%', [
|
||||
.'between %date_from% and %date_to%', [
|
||||
'%date_from%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
|
||||
'%date_to%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
|
||||
], ];
|
||||
|
@@ -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']));
|
||||
}
|
||||
|
@@ -19,8 +19,6 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
final public const CREATE = 'CHILL_REPORT_CREATE';
|
||||
@@ -59,7 +57,7 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
if ($subject instanceof Report) {
|
||||
return in_array($attribute, [
|
||||
return \in_array($attribute, [
|
||||
self::CREATE, self::UPDATE, self::SEE,
|
||||
], true);
|
||||
}
|
||||
|
@@ -13,17 +13,14 @@ namespace Chill\ReportBundle\Tests\Controller;
|
||||
|
||||
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\BrowserKit\Client;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* This class is much well writtend than ReportControllerTest class, and will
|
||||
* replace ReportControllerTest in the future.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ReportControllerNextTest extends WebTestCase
|
||||
@@ -55,9 +52,7 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
);
|
||||
|
||||
if (null === $this->person) {
|
||||
throw new RuntimeException('The expected person is not present in the database. '
|
||||
. 'Did you run `php app/console doctrine:fixture:load` before launching tests ? '
|
||||
. "(expecting person is 'Charline Depardieu'");
|
||||
throw new \RuntimeException('The expected person is not present in the database. Did you run `php app/console doctrine:fixture:load` before launching tests ? '."(expecting person is 'Charline Depardieu'");
|
||||
}
|
||||
|
||||
// get custom fields group from fixture
|
||||
@@ -65,10 +60,10 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
|
||||
->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]);
|
||||
//filter customFieldsGroup to get only "situation de logement"
|
||||
// filter customFieldsGroup to get only "situation de logement"
|
||||
$filteredCustomFieldsGroupHouse = array_filter(
|
||||
$customFieldsGroups,
|
||||
static fn (CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true)
|
||||
static fn (CustomFieldsGroup $group) => \in_array('Situation de logement', $group->getName(), true)
|
||||
);
|
||||
$this->group = $filteredCustomFieldsGroupHouse[0];
|
||||
}
|
||||
@@ -85,7 +80,7 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
403,
|
||||
$client->getResponse()->getStatusCode(),
|
||||
'assert that user for center b has a 403 status code when listing'
|
||||
. 'reports on person from center a'
|
||||
.'reports on person from center a'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,7 +102,7 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
403,
|
||||
$client->getResponse()->getStatusCode(),
|
||||
'assert that user for center b has a 403 status code when '
|
||||
. 'trying to watch a report from person from center a'
|
||||
.'trying to watch a report from person from center a'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +119,7 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
403,
|
||||
$clientCenterB->getResponse()->getStatusCode(),
|
||||
'assert that user is denied on trying to show a form "new" for'
|
||||
. ' a person on another center'
|
||||
.' a person on another center'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,7 +137,7 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
403,
|
||||
$client->getResponse()->getStatusCode(),
|
||||
'assert that user is denied on trying to show a form "new" for'
|
||||
. ' a person on another center'
|
||||
.' a person on another center'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -152,7 +147,7 @@ final class ReportControllerNextTest extends WebTestCase
|
||||
$form = $this->getReportForm($this->person, $this->group, $client);
|
||||
|
||||
$form->get('chill_reportbundle_report[date]')->setValue(
|
||||
(new DateTime())->format('d-m-Y')
|
||||
(new \DateTime())->format('d-m-Y')
|
||||
);
|
||||
|
||||
$client->submit($form);
|
||||
|
@@ -13,20 +13,17 @@ namespace Chill\ReportBundle\Tests\Controller;
|
||||
|
||||
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Component\DomCrawler\Form;
|
||||
use Symfony\Component\DomCrawler\Link;
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Test the life cycles of controllers, according to
|
||||
* https://redmine.champs-libres.coop/projects/report/wiki/Test_plan_for_report_lifecycle.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ReportControllerTest extends WebTestCase
|
||||
@@ -59,7 +56,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
self::$em = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
//get a random person
|
||||
// get a random person
|
||||
self::$person = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository(\Chill\PersonBundle\Entity\Person::class)
|
||||
@@ -71,19 +68,17 @@ final class ReportControllerTest extends WebTestCase
|
||||
);
|
||||
|
||||
if (null === self::$person) {
|
||||
throw new RuntimeException('The expected person is not present in the database. '
|
||||
. 'Did you run `php app/console doctrine:fixture:load` before launching tests ? '
|
||||
. "(expecting person is 'Charline Depardieu'");
|
||||
throw new \RuntimeException('The expected person is not present in the database. Did you run `php app/console doctrine:fixture:load` before launching tests ? '."(expecting person is 'Charline Depardieu'");
|
||||
}
|
||||
|
||||
$customFieldsGroups = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
|
||||
->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]);
|
||||
//filter customFieldsGroup to get only "situation de logement"
|
||||
// filter customFieldsGroup to get only "situation de logement"
|
||||
$filteredCustomFieldsGroupHouse = array_filter(
|
||||
$customFieldsGroups,
|
||||
static fn (CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true)
|
||||
static fn (CustomFieldsGroup $group) => \in_array('Situation de logement', $group->getName(), true)
|
||||
);
|
||||
self::$group = $filteredCustomFieldsGroupHouse[0];
|
||||
|
||||
@@ -116,6 +111,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
|
||||
/**
|
||||
* @return type
|
||||
*
|
||||
* @depends testMenu
|
||||
*/
|
||||
public function testChooseReportModelPage(Link $link)
|
||||
@@ -134,7 +130,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
|
||||
$this->assertGreaterThan(
|
||||
1,
|
||||
count($form->get(self::REPORT_NAME_FIELD)
|
||||
\count($form->get(self::REPORT_NAME_FIELD)
|
||||
->availableOptionValues()),
|
||||
'I can choose between report models'
|
||||
);
|
||||
@@ -161,7 +157,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
$this->markTestSkipped('This test raise an error since symfony 2.7. '
|
||||
. 'The user is not correctly reloaded from database.');
|
||||
.'The user is not correctly reloaded from database.');
|
||||
$filledForm = $this->fillCorrectForm($form);
|
||||
$filledForm->get('chill_reportbundle_report[date]')->setValue('invalid date value');
|
||||
|
||||
@@ -206,7 +202,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$linkSee = $crawler->filter('.bt-view')->links();
|
||||
$this->assertGreaterThan(0, count($linkSee));
|
||||
$this->assertGreaterThan(0, \count($linkSee));
|
||||
$this->assertMatchesRegularExpression(sprintf(
|
||||
'|/fr/person/%s/report/[0-9]*/view$|',
|
||||
self::$person->getId(),
|
||||
@@ -214,7 +210,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
), $linkSee[0]->getUri());
|
||||
|
||||
$linkUpdate = $crawler->filter('.bt-update')->links();
|
||||
$this->assertGreaterThan(0, count($linkUpdate));
|
||||
$this->assertGreaterThan(0, \count($linkUpdate));
|
||||
$this->assertMatchesRegularExpression(sprintf(
|
||||
'|/fr/person/%s/report/[0-9]*/edit$|',
|
||||
self::$person->getId(),
|
||||
@@ -241,7 +237,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
if (!$client->getResponse()->isSuccessful()) {
|
||||
var_dump($crawlerPersonPage->html());
|
||||
|
||||
throw new RuntimeException('the request at person page failed');
|
||||
throw new \RuntimeException('the request at person page failed');
|
||||
}
|
||||
|
||||
$link = $crawlerPersonPage->selectLink("AJOUT D'UN RAPPORT")->link();
|
||||
@@ -264,6 +260,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
|
||||
/**
|
||||
* @return type
|
||||
*
|
||||
* @depends testChooseReportModelPage
|
||||
*/
|
||||
public function testNewReportPage(Crawler $crawlerNewReportPage)
|
||||
@@ -294,10 +291,10 @@ final class ReportControllerTest extends WebTestCase
|
||||
self::$group,
|
||||
$client
|
||||
);
|
||||
//var_dump($form);
|
||||
// var_dump($form);
|
||||
$filledForm = $this->fillCorrectForm($form);
|
||||
$filledForm->get('chill_reportbundle_report[date]')->setValue('');
|
||||
//$this->markTestSkipped();
|
||||
// $this->markTestSkipped();
|
||||
$crawler = $this->getAuthenticatedClient('center a_administrative')->submit($filledForm);
|
||||
|
||||
$this->assertFalse($client->getResponse()->isRedirect());
|
||||
@@ -326,7 +323,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
->form();
|
||||
|
||||
$form->get('chill_reportbundle_report[date]')->setValue(
|
||||
(new DateTime('yesterday'))->format('d-m-Y')
|
||||
(new \DateTime('yesterday'))->format('d-m-Y')
|
||||
);
|
||||
|
||||
$client->submit($form);
|
||||
@@ -339,7 +336,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertEquals(new DateTime('yesterday'), self::$kernel->getContainer()
|
||||
$this->assertEquals(new \DateTime('yesterday'), self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillReportBundle:Report')
|
||||
->find($reportId)
|
||||
@@ -355,7 +352,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
public function testValidCreate()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
//$this->markTestSkipped("This test raise an error since symfony 2.7. "
|
||||
// $this->markTestSkipped("This test raise an error since symfony 2.7. "
|
||||
// . "The user is not correctly reloaded from database.");
|
||||
$addForm = $this->getReportForm(self::$person, self::$group, $client);
|
||||
$filledForm = $this->fillCorrectForm($addForm);
|
||||
@@ -368,7 +365,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
$client->followRedirect();
|
||||
|
||||
$this->assertMatchesRegularExpression(
|
||||
'|/fr/person/' . self::$person->getId() . '/report/[0-9]*/view$|',
|
||||
'|/fr/person/'.self::$person->getId().'/report/[0-9]*/view$|',
|
||||
$client->getHistory()->current()->getUri(),
|
||||
"The next page is a redirection to the new report's view page"
|
||||
);
|
||||
@@ -433,7 +430,7 @@ final class ReportControllerTest extends WebTestCase
|
||||
private function fillCorrectForm(Form $form)
|
||||
{
|
||||
$form->get('chill_reportbundle_report[date]')->setValue(
|
||||
(new DateTime())->format('d-m-Y')
|
||||
(new \DateTime())->format('d-m-Y')
|
||||
);
|
||||
|
||||
return $form;
|
||||
@@ -459,14 +456,14 @@ final class ReportControllerTest extends WebTestCase
|
||||
->getType(), 'the user field is a select input');
|
||||
|
||||
if ($isDefault) {
|
||||
$date = new DateTime('now');
|
||||
$date = new \DateTime('now');
|
||||
$this->assertEquals(
|
||||
$date->format('d-m-Y'),
|
||||
$form->get('chill_reportbundle_report[date]')->getValue(),
|
||||
'the date field contains the current date by default'
|
||||
);
|
||||
|
||||
//resolve the user
|
||||
// resolve the user
|
||||
$userId = $form->get('chill_reportbundle_report[user]')->getValue();
|
||||
|
||||
$this->assertEquals(
|
||||
|
@@ -11,11 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ReportBundle\Tests\DependencyInjection;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ChillReportExtensionTest extends KernelTestCase
|
||||
@@ -41,7 +41,7 @@ final class ChillReportExtensionTest extends KernelTestCase
|
||||
}
|
||||
|
||||
if (!$reportFounded) {
|
||||
throw new Exception('Class Chill\\ReportBundle\\Entity\\Report not found in chill_custom_fields.customizables_entities', 1);
|
||||
throw new \Exception('Class Chill\\ReportBundle\\Entity\\Report not found in chill_custom_fields.customizables_entities', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,11 +15,11 @@ use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Chill\ReportBundle\Export\Filter\ReportDateFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ReportDateFilterTest extends AbstractFilterTest
|
||||
|
@@ -11,13 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ReportBundle\Tests\Search;
|
||||
|
||||
use DateTime;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* Test for report search.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ReportSearchTest extends WebTestCase
|
||||
@@ -27,7 +27,7 @@ final class ReportSearchTest extends WebTestCase
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', [
|
||||
'q' => '@report ' . (new DateTime('tomorrow'))->format('Y-m-d'), //there should be any result for future. And future is tomorrow
|
||||
'q' => '@report '.(new \DateTime('tomorrow'))->format('Y-m-d'), // there should be any result for future. And future is tomorrow
|
||||
'name' => 'report',
|
||||
]);
|
||||
|
||||
|
@@ -23,6 +23,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ReportVoterTest extends KernelTestCase
|
||||
@@ -123,7 +124,6 @@ final class ReportVoterTest extends KernelTestCase
|
||||
* @dataProvider dataProvider
|
||||
*
|
||||
* @param type $expectedResult
|
||||
* @param User $user
|
||||
* @param type $action
|
||||
* @param type $message
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ final class ReportVoterTest extends KernelTestCase
|
||||
Report $report,
|
||||
$action,
|
||||
$message,
|
||||
?User $user = null
|
||||
User $user = null
|
||||
) {
|
||||
$token = $this->prepareToken($user);
|
||||
$result = $this->voter->vote($token, $report, [$action]);
|
||||
@@ -157,15 +157,13 @@ final class ReportVoterTest extends KernelTestCase
|
||||
*
|
||||
* if $permissions = null, user will be null (no user associated with token
|
||||
*
|
||||
* @param User $user
|
||||
*
|
||||
* @return \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
|
||||
*/
|
||||
protected function prepareToken(?User $user = null)
|
||||
protected function prepareToken(User $user = null)
|
||||
{
|
||||
$token = $this->prophet->prophesize();
|
||||
$token
|
||||
->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
|
||||
->willImplement('\\'.\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
|
||||
|
||||
if (null === $user) {
|
||||
$token->getUser()->willReturn(null);
|
||||
|
@@ -15,14 +15,13 @@ use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Tests\TestHelper as MainTestHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use DateTime;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Test a report is shown into timeline.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class TimelineProviderTest extends WebTestCase
|
||||
@@ -49,7 +48,7 @@ final class TimelineProviderTest extends WebTestCase
|
||||
$center = self::$em->getRepository(\Chill\MainBundle\Entity\Center::class)
|
||||
->findOneBy(['name' => 'Center A']);
|
||||
|
||||
$person = (new Person(new DateTime('2015-05-01')))
|
||||
$person = (new Person(new \DateTime('2015-05-01')))
|
||||
->setGender(Person::FEMALE_GENDER)
|
||||
->setFirstName('Nelson')
|
||||
->setLastName('Mandela')
|
||||
@@ -61,13 +60,13 @@ final class TimelineProviderTest extends WebTestCase
|
||||
self::$em
|
||||
->getRepository(\Chill\MainBundle\Entity\Scope::class)
|
||||
->findAll(),
|
||||
static fn (Scope $scope) => $scope->getName()['en'] === 'social'
|
||||
static fn (Scope $scope) => 'social' === $scope->getName()['en']
|
||||
);
|
||||
|
||||
$report = (new Report())
|
||||
->setUser(self::$em->getRepository(\Chill\MainBundle\Entity\User::class)
|
||||
->findOneByUsername('center a_social'))
|
||||
->setDate(new DateTime('2015-05-02'))
|
||||
->setDate(new \DateTime('2015-05-02'))
|
||||
->setPerson($this->person)
|
||||
->setCFGroup($this->getHousingCustomFieldsGroup())
|
||||
->setCFData(['has_logement' => 'own_house',
|
||||
@@ -82,10 +81,10 @@ final class TimelineProviderTest extends WebTestCase
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
//static::$em->refresh($this->person);
|
||||
//static::$em->refresh($this->report);
|
||||
// static::$em->refresh($this->person);
|
||||
// static::$em->refresh($this->report);
|
||||
// static::$em->remove($this->person);
|
||||
//static::$em->remove($this->report);
|
||||
// static::$em->remove($this->report);
|
||||
}
|
||||
|
||||
public function testReportIsNotVisibleToUngrantedUsers()
|
||||
@@ -95,8 +94,8 @@ final class TimelineProviderTest extends WebTestCase
|
||||
MainTestHelper::getAuthenticatedClientOptions('center a_administrative')
|
||||
);
|
||||
|
||||
$crawler = $client->request('GET', '/fr/person/' . $this->person->getId()
|
||||
. '/timeline');
|
||||
$crawler = $client->request('GET', '/fr/person/'.$this->person->getId()
|
||||
.'/timeline');
|
||||
|
||||
$this->assertEquals(
|
||||
0,
|
||||
@@ -116,8 +115,8 @@ final class TimelineProviderTest extends WebTestCase
|
||||
MainTestHelper::getAuthenticatedClientOptions()
|
||||
);
|
||||
|
||||
$crawler = $client->request('GET', '/fr/person/' . $this->person->getId()
|
||||
. '/timeline');
|
||||
$crawler = $client->request('GET', '/fr/person/'.$this->person->getId()
|
||||
.'/timeline');
|
||||
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isSuccessful(),
|
||||
@@ -132,16 +131,16 @@ final class TimelineProviderTest extends WebTestCase
|
||||
|
||||
public function testTimelineReportWithSummaryField()
|
||||
{
|
||||
//load the page
|
||||
// load the page
|
||||
$client = self::createClient(
|
||||
[],
|
||||
MainTestHelper::getAuthenticatedClientOptions()
|
||||
);
|
||||
|
||||
$crawler = $client->request('GET', '/fr/person/' . $this->person->getId()
|
||||
. '/timeline');
|
||||
$crawler = $client->request('GET', '/fr/person/'.$this->person->getId()
|
||||
.'/timeline');
|
||||
|
||||
//performs tests
|
||||
// performs tests
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isSuccessful(),
|
||||
'The page timeline is loaded successfully'
|
||||
@@ -168,11 +167,11 @@ final class TimelineProviderTest extends WebTestCase
|
||||
->findAll();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
if ($group->getName()['fr'] === 'Situation de logement') {
|
||||
if ('Situation de logement' === $group->getName()['fr']) {
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
|
||||
return $groups[random_int(0, count($groups) - 1)];
|
||||
return $groups[random_int(0, \count($groups) - 1)];
|
||||
}
|
||||
}
|
||||
|
@@ -18,17 +18,7 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use LogicException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
|
||||
use function array_fill;
|
||||
use function array_key_exists;
|
||||
use function array_merge;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function strtr;
|
||||
|
||||
/**
|
||||
* Provide report for inclusion in timeline.
|
||||
@@ -46,10 +36,10 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
|
||||
return TimelineSingleQuery::fromArray([
|
||||
'id' => $report->getTableName()
|
||||
. '.' . $report->getColumnName('id'),
|
||||
.'.'.$report->getColumnName('id'),
|
||||
'type' => 'report',
|
||||
'date' => $report->getTableName()
|
||||
. '.' . $report->getColumnName('date'),
|
||||
.'.'.$report->getColumnName('date'),
|
||||
'FROM' => $this->getFromClause($context),
|
||||
'WHERE' => $where,
|
||||
'parameters' => $parameters,
|
||||
@@ -91,17 +81,17 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
|
||||
protected function getFieldsToRender(Report $entity, $context, array $args = [])
|
||||
{
|
||||
//gather all custom fields which should appears in summary
|
||||
// gather all custom fields which should appears in summary
|
||||
$gatheredFields = [];
|
||||
|
||||
if (array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) {
|
||||
if (\array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) {
|
||||
// keep in memory title
|
||||
$title = null;
|
||||
$subtitle = null;
|
||||
|
||||
foreach ($entity->getCFGroup()->getCustomFields() as $customField) {
|
||||
if (
|
||||
in_array(
|
||||
\in_array(
|
||||
$customField->getSlug(),
|
||||
$entity->getCFGroup()->getOptions()['summary_fields'],
|
||||
true
|
||||
@@ -109,7 +99,7 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
) {
|
||||
// if we do not want to show empty values
|
||||
if (false === $this->showEmptyValues) {
|
||||
if ($customField->getType() === 'title') {
|
||||
if ('title' === $customField->getType()) {
|
||||
$options = $customField->getOptions();
|
||||
|
||||
switch ($options['type']) {
|
||||
@@ -125,8 +115,8 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
$this->customFieldsHelper->isEmptyValue($entity->getCFData(), $customField)
|
||||
=== false
|
||||
false
|
||||
=== $this->customFieldsHelper->isEmptyValue($entity->getCFData(), $customField)
|
||||
) {
|
||||
if (null !== $title) {
|
||||
$gatheredFields[] = $title;
|
||||
@@ -155,13 +145,12 @@ class TimelineReportProvider 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 && 'center' !== $context) {
|
||||
throw new LogicException("The context '{$context}' is not "
|
||||
. "supported. Currently only 'person' and 'center' is supported");
|
||||
throw new \LogicException("The context '{$context}' is not supported. Currently only 'person' and 'center' is supported");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,10 +163,10 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
$personId = $report
|
||||
->getAssociationMapping('person')['joinColumns'][0]['referencedColumnName'];
|
||||
|
||||
$clause = '{report} ' .
|
||||
$clause = '{report} '.
|
||||
'JOIN {person} ON {report}.{person_id} = {person}.{id_person} ';
|
||||
|
||||
return strtr(
|
||||
return \strtr(
|
||||
$clause,
|
||||
[
|
||||
'{report}' => $report->getTableName(),
|
||||
@@ -193,7 +182,7 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
return match ($context) {
|
||||
'person' => $this->getWhereClauseForPerson($context, $args),
|
||||
'center' => $this->getWhereClauseForCenter($context, $args),
|
||||
default => throw new UnexpectedValueException("This context {$context} is not implemented"),
|
||||
default => throw new \UnexpectedValueException("This context {$context} is not implemented"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -212,7 +201,7 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
$parameters = [];
|
||||
|
||||
// the clause, that will be joined with an "OR"
|
||||
$centerScopesClause = '({person}.{center_id} = ? ' .
|
||||
$centerScopesClause = '({person}.{center_id} = ? '.
|
||||
'AND {report}.{scopes_id} IN ({scopes_ids}))';
|
||||
// container for formatted clauses
|
||||
$formattedClauses = [];
|
||||
@@ -220,7 +209,7 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
$askedCenters = $args['centers'];
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
if (false === in_array($center, $askedCenters, true)) {
|
||||
if (false === \in_array($center, $askedCenters, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -230,26 +219,26 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
$scopeIds = [];
|
||||
|
||||
foreach ($this->helper->getReachableScopes($this->security->getUser(), $role, $center) as $scope) {
|
||||
if (in_array($scope->getId(), $scopeIds, true)) {
|
||||
if (\in_array($scope->getId(), $scopeIds, true)) {
|
||||
continue;
|
||||
}
|
||||
$scopeIds[] = $scope->getId();
|
||||
}
|
||||
|
||||
$formattedClauses[] = strtr($centerScopesClause, [
|
||||
'{scopes_ids}' => implode(', ', array_fill(0, count($scopeIds), '?')),
|
||||
$formattedClauses[] = \strtr($centerScopesClause, [
|
||||
'{scopes_ids}' => \implode(', ', \array_fill(0, \count($scopeIds), '?')),
|
||||
]);
|
||||
// append $scopeIds to parameters
|
||||
$parameters = [...$parameters, ...$scopeIds];
|
||||
}
|
||||
|
||||
if (0 === count($formattedClauses)) {
|
||||
if (0 === \count($formattedClauses)) {
|
||||
return ['FALSE = TRUE', []];
|
||||
}
|
||||
|
||||
return [
|
||||
strtr(
|
||||
implode(' OR ', $formattedClauses),
|
||||
\strtr(
|
||||
\implode(' OR ', $formattedClauses),
|
||||
[
|
||||
'{person}' => $person->getTableName(),
|
||||
'{center_id}' => $personCenterId,
|
||||
@@ -278,28 +267,28 @@ class TimelineReportProvider implements TimelineProviderInterface
|
||||
$scopes = $this->helper->getReachableScopes($this->security->getUser(), $role, $args['person']->getCenter());
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
if (in_array($scope->getId(), $parameters, true)) {
|
||||
if (\in_array($scope->getId(), $parameters, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parameters[] = $scope->getId();
|
||||
}
|
||||
|
||||
if (1 === count($parameters)) {
|
||||
if (1 === \count($parameters)) {
|
||||
// nothing change, we simplify the clause
|
||||
$clause = '{report}.{person_id} = ? AND FALSE = TRUE';
|
||||
}
|
||||
|
||||
return [
|
||||
strtr(
|
||||
\strtr(
|
||||
$clause,
|
||||
[
|
||||
'{report}' => $report->getTableName(),
|
||||
'{person_id}' => $reportPersonId,
|
||||
'{scopes_id}' => $reportScopeId,
|
||||
'{scopes_ids}' => implode(
|
||||
'{scopes_ids}' => \implode(
|
||||
', ',
|
||||
array_fill(0, count($parameters) - 1, '?')
|
||||
\array_fill(0, \count($parameters) - 1, '?')
|
||||
),
|
||||
]
|
||||
),
|
||||
|
@@ -14,7 +14,6 @@ namespace Chill\Migrations\Report;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
@@ -28,7 +27,7 @@ class Version20150622233319 extends AbstractMigration implements ContainerAwareI
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf(
|
||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
'postgresql' !== $this->connection->getDatabasePlatform()->getName(),
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
@@ -38,11 +37,10 @@ class Version20150622233319 extends AbstractMigration implements ContainerAwareI
|
||||
$this->addSql('ALTER TABLE Report DROP scope_id');
|
||||
}
|
||||
|
||||
public function setContainer(?ContainerInterface $container = null)
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
if (null === $container) {
|
||||
throw new RuntimeException('Container is not provided. This migration '
|
||||
. 'need container to set a default center');
|
||||
throw new \RuntimeException('Container is not provided. This migration need container to set a default center');
|
||||
}
|
||||
|
||||
$this->container = $container;
|
||||
@@ -51,7 +49,7 @@ class Version20150622233319 extends AbstractMigration implements ContainerAwareI
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf(
|
||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
'postgresql' !== $this->connection->getDatabasePlatform()->getName(),
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
@@ -101,10 +99,10 @@ class Version20150622233319 extends AbstractMigration implements ContainerAwareI
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->addSql('ALTER TABLE report DROP scope'); //before this migration, scope was never used
|
||||
$this->addSql('ALTER TABLE report DROP scope'); // before this migration, scope was never used
|
||||
$this->addSql('ALTER TABLE report ADD CONSTRAINT FK_report_scope '
|
||||
. 'FOREIGN KEY (scope_id) '
|
||||
. 'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
.'FOREIGN KEY (scope_id) '
|
||||
.'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
if (isset($defaultScopeId)) {
|
||||
$this->addSql('UPDATE report SET scope_id = :id', [
|
||||
|
Reference in New Issue
Block a user