mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
cs: Enable more risky rules.
This commit is contained in:
@@ -23,6 +23,8 @@ 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;
|
||||
use function intval;
|
||||
|
||||
/**
|
||||
* Class ReportController.
|
||||
|
@@ -13,6 +13,7 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Load CustomField for Report into database.
|
||||
|
@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\RoleScope;
|
||||
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,
|
||||
|
@@ -19,6 +19,8 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
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.
|
||||
|
@@ -40,6 +40,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
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;
|
||||
@@ -107,13 +109,13 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
return [];
|
||||
},
|
||||
'choice_label' => function (string $key, string $label): string {
|
||||
switch (\substr($key, 0, 7)) {
|
||||
switch (substr($key, 0, 7)) {
|
||||
case 'person_':
|
||||
return $this->translator->trans(\substr($key, 7, strlen($key) - 7)) .
|
||||
return $this->translator->trans(substr($key, 7, strlen($key) - 7)) .
|
||||
' (' . $this->translator->trans('Person') . ')';
|
||||
|
||||
case 'report_':
|
||||
return $this->translator->trans(ucfirst(\substr($key, 7, strlen($key) - 7))) .
|
||||
return $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) .
|
||||
' (' . $this->translator->trans('Report') . ')';
|
||||
|
||||
default:
|
||||
@@ -342,7 +344,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
// 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'])) {
|
||||
if (!in_array($f, $data['fields'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -350,7 +352,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
switch ($f) {
|
||||
case 'person_countryOfBirth':
|
||||
case 'person_nationality':
|
||||
$suffix = \substr($f, 7);
|
||||
$suffix = substr($f, 7);
|
||||
$qb->addSelect(sprintf('IDENTITY(person.%s) as %s', $suffix, $f));
|
||||
|
||||
break;
|
||||
@@ -363,7 +365,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
case 'person_address_country_name':
|
||||
case 'person_address_country_code':
|
||||
// remove 'person_'
|
||||
$suffix = \substr($f, 7);
|
||||
$suffix = substr($f, 7);
|
||||
|
||||
$qb->addSelect(sprintf(
|
||||
'GET_PERSON_ADDRESS_%s(person.id, :address_date) AS %s',
|
||||
@@ -386,8 +388,8 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
$prefix = \substr($f, 0, 7);
|
||||
$suffix = \substr($f, 7);
|
||||
$prefix = substr($f, 0, 7);
|
||||
$suffix = substr($f, 7);
|
||||
|
||||
switch ($prefix) {
|
||||
case 'person_':
|
||||
@@ -410,7 +412,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
// 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'])) {
|
||||
if (!in_array($cf->getSlug(), $data['fields'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -500,7 +502,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
*/
|
||||
private function getCustomFields()
|
||||
{
|
||||
return \array_filter($this->customfieldsGroup
|
||||
return array_filter($this->customfieldsGroup
|
||||
->getCustomFields()->toArray(), function (CustomField $cf) {
|
||||
return $cf->getType() !== 'title';
|
||||
});
|
||||
@@ -528,7 +530,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
||||
if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) {
|
||||
return function ($value) use ($cf, $cfType, $key) {
|
||||
$slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug'];
|
||||
$decoded = \json_decode($value, true);
|
||||
$decoded = json_decode($value, true);
|
||||
|
||||
if ('_header' === $value) {
|
||||
$label = $cfType->getChoices($cf)[$slugChoice];
|
||||
|
@@ -19,6 +19,7 @@ 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.
|
||||
|
@@ -15,6 +15,7 @@ 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
|
||||
|
@@ -17,6 +17,8 @@ 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
|
||||
|
@@ -15,6 +15,7 @@ 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.
|
||||
|
@@ -22,8 +22,11 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -236,7 +239,7 @@ break;
|
||||
$askedCenters = $args['centers'];
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
if (false === \in_array($center, $askedCenters)) {
|
||||
if (false === in_array($center, $askedCenters)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -246,14 +249,14 @@ break;
|
||||
$scopeIds = [];
|
||||
|
||||
foreach ($this->helper->getReachableScopes($this->security->getUser(), $role, $center) as $scope) {
|
||||
if (\in_array($scope->getId(), $scopeIds)) {
|
||||
if (in_array($scope->getId(), $scopeIds)) {
|
||||
continue;
|
||||
}
|
||||
$scopeIds[] = $scope->getId();
|
||||
}
|
||||
|
||||
$formattedClauses[] = strtr($centerScopesClause, [
|
||||
'{scopes_ids}' => implode(', ', array_fill(0, \count($scopeIds), '?')),
|
||||
'{scopes_ids}' => implode(', ', array_fill(0, count($scopeIds), '?')),
|
||||
]);
|
||||
// append $scopeIds to parameters
|
||||
$parameters = array_merge($parameters, $scopeIds);
|
||||
@@ -294,7 +297,7 @@ break;
|
||||
$scopes = $this->helper->getReachableScopes($this->security->getUser(), $role, $args['person']->getCenter());
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
if (\in_array($scope->getId(), $parameters)) {
|
||||
if (in_array($scope->getId(), $parameters)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -315,7 +318,7 @@ break;
|
||||
'{scopes_id}' => $reportScopeId,
|
||||
'{scopes_ids}' => implode(
|
||||
', ',
|
||||
array_fill(0, \count($parameters) - 1, '?')
|
||||
array_fill(0, count($parameters) - 1, '?')
|
||||
),
|
||||
]
|
||||
),
|
||||
|
Reference in New Issue
Block a user