apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -20,6 +20,7 @@ class AdminController extends AbstractController
{
/**
* @return \Symfony\Component\HttpFoundation\Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/document", name="chill_docstore_admin", options={null})
*/
public function indexAction()
@@ -29,6 +30,7 @@ class AdminController extends AbstractController
/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/document_redirect_to_main", name="chill_docstore_admin_redirect_to_admin_index", options={null})
*/
public function redirectToAdminIndexAction()

View File

@@ -13,12 +13,9 @@ namespace Chill\DocStoreBundle\Controller;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
use Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType;
use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository;
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use DateTime;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -85,7 +82,7 @@ class DocumentAccompanyingCourseController extends AbstractController
$this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::UPDATE, $document);
$document->setUser($this->getUser());
$document->setDate(new DateTime('Now'));
$document->setDate(new \DateTime('Now'));
$form = $this->createForm(
AccompanyingCourseDocumentType::class,
@@ -130,7 +127,7 @@ class DocumentAccompanyingCourseController extends AbstractController
$document = new AccompanyingCourseDocument();
$document->setUser($this->getUser());
$document->setCourse($course);
$document->setDate(new DateTime('Now'));
$document->setDate(new \DateTime('Now'));
$this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::CREATE, $document);

View File

@@ -37,7 +37,7 @@ class DocumentCategoryController extends AbstractController
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]
);
if ($this->isCsrfTokenValid('delete' . $bundleId . $idInsideBundle, $request->request->get('_token'))) {
if ($this->isCsrfTokenValid('delete'.$bundleId.$idInsideBundle, $request->request->get('_token'))) {
$em->remove($documentCategory);
$em->flush();
}

View File

@@ -13,14 +13,11 @@ namespace Chill\DocStoreBundle\Controller;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\DocStoreBundle\Form\PersonDocumentType;
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTime;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -92,7 +89,7 @@ class DocumentPersonController extends AbstractController
$this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_UPDATE', $document);
$document->setUser($this->getUser());
$document->setDate(new DateTime('Now'));
$document->setDate(new \DateTime('Now'));
$form = $this->createForm(
PersonDocumentType::class,
@@ -156,7 +153,7 @@ class DocumentPersonController extends AbstractController
$document = new PersonDocument();
$document->setUser($this->getUser());
$document->setPerson($person);
$document->setDate(new DateTime('Now'));
$document->setDate(new \DateTime('Now'));
$form = $this->createForm(PersonDocumentType::class, $document, [
'role' => 'CHILL_PERSON_DOCUMENT_CREATE',

View File

@@ -16,12 +16,10 @@ use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
final readonly class GenericDocForAccompanyingPeriodController
{
@@ -41,7 +39,7 @@ final readonly class GenericDocForAccompanyingPeriodController
public function list(AccompanyingPeriod $accompanyingPeriod): Response
{
if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) {
throw new AccessDeniedHttpException("not allowed to see the documents for accompanying period");
throw new AccessDeniedHttpException('not allowed to see the documents for accompanying period');
}
$filterBuilder = $this->filterOrderHelperFactory
@@ -51,7 +49,7 @@ final readonly class GenericDocForAccompanyingPeriodController
if ([] !== $places = $this->manager->placesForAccompanyingPeriod($accompanyingPeriod)) {
$filterBuilder->addCheckbox('places', $places, [], array_map(
static fn (string $k) => 'generic_doc.filter.keys.' . $k,
static fn (string $k) => 'generic_doc.filter.keys.'.$k,
$places
));
}
@@ -59,7 +57,7 @@ final readonly class GenericDocForAccompanyingPeriodController
$filter = $filterBuilder
->build();
['to' => $endDate, 'from' => $startDate ] = $filter->getDateRangeData('dateRange');
['to' => $endDate, 'from' => $startDate] = $filter->getDateRangeData('dateRange');
$content = $filter->getQueryString();
$nb = $this->manager->countDocForAccompanyingPeriod(

View File

@@ -20,7 +20,6 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
final readonly class GenericDocForPerson
{
@@ -40,7 +39,7 @@ final readonly class GenericDocForPerson
public function list(Person $person): Response
{
if (!$this->security->isGranted(PersonDocumentVoter::SEE, $person)) {
throw new AccessDeniedHttpException("not allowed to see the documents for person");
throw new AccessDeniedHttpException('not allowed to see the documents for person');
}
$filterBuilder = $this->filterOrderHelperFactory
@@ -50,7 +49,7 @@ final readonly class GenericDocForPerson
if ([] !== $places = $this->manager->placesForPerson($person)) {
$filterBuilder->addCheckbox('places', $places, [], array_map(
static fn (string $k) => 'generic_doc.filter.keys.' . $k,
static fn (string $k) => 'generic_doc.filter.keys.'.$k,
$places
));
}
@@ -58,7 +57,7 @@ final readonly class GenericDocForPerson
$filter = $filterBuilder
->build();
['to' => $endDate, 'from' => $startDate ] = $filter->getDateRangeData('dateRange');
['to' => $endDate, 'from' => $startDate] = $filter->getDateRangeData('dateRange');
$content = $filter->getQueryString();
$nb = $this->manager->countDocForPerson(

View File

@@ -19,8 +19,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function in_array;
/**
* Adding acl for person document.
*/
@@ -40,10 +38,10 @@ class LoadDocumentACL 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 LoadDocumentACL 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 LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
printf(
'Adding Person report acl to %s '
. "permission group, scope '%s' \n",
."permission group, scope '%s' \n",
$permissionsGroup->getName(),
$scope->getName()['en']
);

View File

@@ -32,7 +32,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
$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/media.yaml');
$loader->load('services/controller.yaml');
@@ -89,7 +89,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
protected function prependRoute(ContainerBuilder $container)
{
//declare routes for task bundle
// declare routes for task bundle
$container->prependExtensionConfig('chill_main', [
'routing' => [
'resources' => [

View File

@@ -18,19 +18,23 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table("chill_doc.accompanyingcourse_document")
*/
class AccompanyingCourseDocument extends Document implements HasScopesInterface, HasCentersInterface
{
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private ?AccompanyingPeriod $course = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -65,5 +69,4 @@ class AccompanyingCourseDocument extends Document implements HasScopesInterface,
return $this;
}
}

View File

@@ -16,8 +16,6 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\User;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@@ -32,7 +30,9 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\ManyToOne(targetEntity="Chill\DocStoreBundle\Entity\DocumentCategory")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="category_bundle_id", referencedColumnName="bundle_id"),
* @ORM\JoinColumn(name="category_id_inside_bundle", referencedColumnName="id_inside_bundle")
* })
@@ -54,7 +54,9 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
* targetEntity="Chill\DocStoreBundle\Entity\StoredObject",
* cascade={"persist"}
* )
*
* @Assert\Valid
*
* @Assert\NotNull(
* message="Upload a document"
* )
@@ -68,6 +70,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="text")
*
* @Assert\Length(
* min=2, max=250
* )
@@ -84,7 +87,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
return $this->category;
}
public function getDate(): ?DateTimeInterface
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
@@ -121,7 +124,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setDate(DateTimeInterface $date): self
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
@@ -135,7 +138,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setObject(?StoredObject $object = null)
public function setObject(StoredObject $object = null)
{
$this->object = $object;

View File

@@ -15,6 +15,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table("chill_doc.document_category")
*
* @ORM\Entity
*/
class DocumentCategory
@@ -33,11 +34,12 @@ class DocumentCategory
/**
* @param string $bundleId
* @param int $idInsideBundle
* @param int $idInsideBundle
*/
public function __construct(
/**
* @ORM\Id
*
* @ORM\Column(type="string", name="bundle_id")
*
* @var string The id of the bundle that has create the category (i.e. 'person', 'activity', ....)
@@ -45,6 +47,7 @@ class DocumentCategory
private $bundleId,
/**
* @ORM\Id
*
* @ORM\Column(type="integer", name="id_inside_bundle")
*
* @var int The id which is unique inside the bundle

View File

@@ -19,13 +19,16 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table("chill_doc.person_document")
*
* @ORM\Entity
*/
class PersonDocument extends Document implements HasCenterInterface, HasScopeInterface
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;

View File

@@ -17,8 +17,6 @@ use ChampsLibres\WopiLib\Contract\Entity\Document;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
@@ -28,7 +26,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* Represent a document stored in an object store.
*
* @ORM\Entity
*
* @ORM\Table("chill_doc.stored_object")
*
* @AsyncFileExists(
* message="The file is not stored properly"
* )
@@ -36,57 +36,68 @@ use Symfony\Component\Serializer\Annotation as Serializer;
class StoredObject implements AsyncFileInterface, Document, TrackCreationInterface
{
use TrackCreationTrait;
final public const STATUS_READY = "ready";
final public const STATUS_PENDING = "pending";
final public const STATUS_FAILURE = "failure";
final public const STATUS_READY = 'ready';
final public const STATUS_PENDING = 'pending';
final public const STATUS_FAILURE = 'failure';
/**
* @ORM\Column(type="json", name="datas")
*
* @Serializer\Groups({"read", "write"})
*/
private array $datas = [];
/**
* @ORM\Column(type="text")
*
* @Serializer\Groups({"read", "write"})
*/
private string $filename = '';
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "write"})
*/
private ?int $id = null;
/**
* @var int[]
*
* @ORM\Column(type="json", name="iv")
*
* @Serializer\Groups({"read", "write"})
*/
private array $iv = [];
/**
* @ORM\Column(type="json", name="key")
*
* @Serializer\Groups({"read", "write"})
*/
private array $keyInfos = [];
/**
* @ORM\Column(type="text", name="title")
*
* @Serializer\Groups({"read", "write"})
*/
private string $title = '';
/**
* @ORM\Column(type="text", name="type", options={"default": ""})
*
* @Serializer\Groups({"read", "write"})
*/
private string $type = '';
/**
* @ORM\Column(type="uuid", unique=true)
*
* @Serializer\Groups({"read", "write"})
*/
private UuidInterface $uuid;
@@ -111,27 +122,29 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
*/
public function __construct(/**
* @ORM\Column(type="text", options={"default": "ready"})
*
* @Serializer\Groups({"read"})
*/
private string $status = "ready"
private string $status = 'ready'
) {
$this->uuid = Uuid::uuid4();
}
public function addGenerationTrial(): self
{
$this->generationTrialsCounter++;
++$this->generationTrialsCounter;
return $this;
}
/**
* @Serializer\Groups({"read", "write"})
*
* @deprecated
*/
public function getCreationDate(): DateTime
public function getCreationDate(): \DateTime
{
return DateTime::createFromImmutable($this->createdAt);
return \DateTime::createFromImmutable($this->createdAt);
}
public function getDatas(): array
@@ -165,7 +178,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
}
/**
* @deprecated Use method "getFilename()".
* @deprecated use method "getFilename()"
*/
public function getObjectName()
{
@@ -202,9 +215,10 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
/**
* @Serializer\Groups({"write"})
*
* @deprecated
*/
public function setCreationDate(DateTime $creationDate): self
public function setCreationDate(\DateTime $creationDate): self
{
$this->createdAt = \DateTimeImmutable::createFromMutable($creationDate);
@@ -276,6 +290,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa
public function setTemplate(?DocGeneratorTemplate $template): StoredObject
{
$this->template = $template;
return $this;
}

View File

@@ -11,12 +11,9 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Exception;
use Exception;
use Throwable;
final class StoredObjectManagerException extends Exception
final class StoredObjectManagerException extends \Exception
{
public static function errorDuringHttpRequest(Throwable $exception): self
public static function errorDuringHttpRequest(\Throwable $exception): self
{
return new self('Error during HTTP request.', 500, $exception);
}
@@ -33,7 +30,7 @@ final class StoredObjectManagerException extends Exception
return new self(sprintf('Unable to decrypt content (reason: %s).', $message));
}
public static function unableToGetResponseContent(Throwable $exception): self
public static function unableToGetResponseContent(\Throwable $exception): self
{
return new self('Unable to get content from response.', 500, $exception);
}

View File

@@ -68,7 +68,7 @@ class AccompanyingCourseDocumentType extends AbstractType
'error_bubbling' => true,
])
->add('date', ChillDateType::class)
//TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none...
// TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none...
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => DocumentCategory::class,

View File

@@ -21,9 +21,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function json_decode;
use function json_encode;
/**
* Form type which allow to join a document.
*/
@@ -90,7 +87,7 @@ class StoredObjectType extends AbstractType
return null;
}
return json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
return \json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
}
public function reverseTransformObject($object)
@@ -115,7 +112,7 @@ class StoredObjectType extends AbstractType
return null;
}
return json_encode($object, JSON_THROW_ON_ERROR);
return \json_encode($object, JSON_THROW_ON_ERROR);
}
public function transformObject($object = null)

View File

@@ -77,7 +77,7 @@ class FetchQuery implements FetchQueryInterface
public function removeWhereClause(int $index): void
{
if (!array_key_exists($index, $this->wheres)) {
throw new \UnexpectedValueException("this index does not exists");
throw new \UnexpectedValueException('this index does not exists');
}
unset($this->wheres[$index], $this->whereParams[$index], $this->whereTypes[$index]);
@@ -86,7 +86,7 @@ class FetchQuery implements FetchQueryInterface
public function removeJoinClause(int $index): void
{
if (!array_key_exists($index, $this->joins)) {
throw new \UnexpectedValueException("this index does not exists");
throw new \UnexpectedValueException('this index does not exists');
}
unset($this->joins[$index], $this->joinParams[$index], $this->joinTypes[$index]);
@@ -102,9 +102,6 @@ class FetchQuery implements FetchQueryInterface
return $this->selectIdentifierJsonB;
}
/**
* @inheritDoc
*/
public function getSelectIdentifierParams(): array
{
return $this->selectIdentifierParams;
@@ -125,9 +122,6 @@ class FetchQuery implements FetchQueryInterface
return $this->selectDateTypes;
}
/**
* @inheritDoc
*/
public function getSelectDateParams(): array
{
return $this->selectDateParams;
@@ -135,12 +129,9 @@ class FetchQuery implements FetchQueryInterface
public function getFromQuery(): string
{
return $this->from . " " . implode(' ', $this->joins);
return $this->from.' '.implode(' ', $this->joins);
}
/**
* @inheritDoc
*/
public function getFromQueryParams(): array
{
$result = [];
@@ -168,9 +159,6 @@ class FetchQuery implements FetchQueryInterface
return implode(' AND ', $this->wheres);
}
/**
* @inheritDoc
*/
public function getWhereQueryParams(): array
{
$result = [];

View File

@@ -34,14 +34,14 @@ final readonly class FetchQueryToSqlBuilder
'{{ identifiers }}' => $query->getSelectIdentifierJsonB(),
'{{ date }}' => $query->getSelectDate(),
'{{ from }}' => $query->getFromQuery(),
'{{ where }}' => '' === ($w = $query->getWhereQuery()) ? '' : 'WHERE ' . $w,
'{{ where }}' => '' === ($w = $query->getWhereQuery()) ? '' : 'WHERE '.$w,
]);
$params = [
...$query->getSelectIdentifierParams(),
...$query->getSelectDateParams(),
...$query->getFromQueryParams(),
...$query->getWhereQueryParams()
...$query->getWhereQueryParams(),
];
$types = [

View File

@@ -17,10 +17,10 @@ interface GenericDocForAccompanyingPeriodProviderInterface
{
public function buildFetchQueryForAccompanyingPeriod(
AccompanyingPeriod $accompanyingPeriod,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
?string $origin = null
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
string $origin = null
): FetchQueryInterface;
/**

View File

@@ -12,16 +12,15 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\GenericDoc;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
interface GenericDocForPersonProviderInterface
{
public function buildFetchQueryForPerson(
Person $person,
?DateTimeImmutable $startDate = null,
?DateTimeImmutable $endDate = null,
?string $content = null,
?string $origin = null
Person $person,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
string $origin = null
): FetchQueryInterface;
/**

View File

@@ -38,13 +38,14 @@ final readonly class Manager
/**
* @param list<string> $places
*
* @throws Exception
*/
public function countDocForAccompanyingPeriod(
AccompanyingPeriod $accompanyingPeriod,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
array $places = []
): int {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places);
@@ -54,7 +55,7 @@ final readonly class Manager
private function countDoc(string $sql, array $params, array $types): int
{
if ($sql === '') {
if ('' === $sql) {
return 0;
}
@@ -64,7 +65,7 @@ final readonly class Manager
$number = $result->fetchOne();
if (false === $number) {
throw new \UnexpectedValueException("number of documents failed to load");
throw new \UnexpectedValueException('number of documents failed to load');
}
return $number;
@@ -72,9 +73,9 @@ final readonly class Manager
public function countDocForPerson(
Person $person,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
array $places = []
): int {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person, $startDate, $endDate, $content, $places);
@@ -84,16 +85,18 @@ final readonly class Manager
/**
* @param list<string> $places places to search. When empty, search in all places
*
* @return iterable<GenericDocDTO>
*
* @throws Exception
*/
public function findDocForAccompanyingPeriod(
AccompanyingPeriod $accompanyingPeriod,
int $offset = 0,
int $limit = 20,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
array $places = []
): iterable {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places);
@@ -107,7 +110,7 @@ final readonly class Manager
*/
private function findDocs(AccompanyingPeriod|Person $linked, string $sql, array $params, array $types, int $offset, int $limit): iterable
{
if ($sql === '') {
if ('' === $sql) {
return [];
}
@@ -127,15 +130,16 @@ final readonly class Manager
/**
* @param list<string> $places places to search. When empty, search in all places
*
* @return iterable<GenericDocDTO>
*/
public function findDocForPerson(
Person $person,
int $offset = 0,
int $limit = 20,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
array $places = []
): iterable {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person, $startDate, $endDate, $content, $places);
@@ -159,7 +163,7 @@ final readonly class Manager
private function places(string $sql, array $params, array $types): array
{
if ($sql === '') {
if ('' === $sql) {
return [];
}
@@ -179,9 +183,9 @@ final readonly class Manager
*/
private function buildUnionQuery(
AccompanyingPeriod|Person $linked,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null,
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
array $places = [],
): array {
$queries = [];
@@ -210,7 +214,7 @@ final readonly class Manager
continue;
}
['sql' => $q, 'params' => $p, 'types' => $t ] = $this->builder->toSql($query);
['sql' => $q, 'params' => $p, 'types' => $t] = $this->builder->toSql($query);
$sql[] = $q;
$params = [...$params, ...$p];

View File

@@ -20,7 +20,6 @@ use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use DateTimeImmutable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Security;
@@ -34,7 +33,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
private EntityManagerInterface $entityManager,
) {}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class);
@@ -42,7 +41,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
self::KEY,
sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]),
$classMetadata->getColumnName('date'),
$classMetadata->getSchemaName() . '.' . $classMetadata->getTableName()
$classMetadata->getSchemaName().'.'.$classMetadata->getTableName()
);
$query->addWhereClause(
@@ -59,7 +58,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod);
}
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class);
@@ -67,7 +66,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
self::KEY,
sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]),
$classMetadata->getColumnName('date'),
$classMetadata->getSchemaName() . '.' . $classMetadata->getTableName() . ' AS acc_course_document'
$classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS acc_course_document'
);
$atLeastOne = false;
@@ -98,7 +97,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
return $query;
}
$query->addWhereClause('(' . implode(' OR ', $or) . ')', $orParams, $orTypes);
$query->addWhereClause('('.implode(' OR ', $or).')', $orParams, $orTypes);
return $this->addWhereClause($query, $startDate, $endDate, $content);
}
@@ -108,7 +107,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person);
}
private function addWhereClause(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
private function addWhereClause(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
{
$classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class);
@@ -135,7 +134,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen
$classMetadata->getColumnName('title'),
$classMetadata->getColumnName('description')
),
['%' . $content . '%', '%' . $content . '%'],
['%'.$content.'%', '%'.$content.'%'],
[Types::STRING, Types::STRING]
);
}

View File

@@ -18,7 +18,6 @@ use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Symfony\Component\Security\Core\Security;
final readonly class PersonDocumentGenericDocProvider implements GenericDocForPersonProviderInterface, GenericDocForAccompanyingPeriodProviderInterface
@@ -32,10 +31,10 @@ final readonly class PersonDocumentGenericDocProvider implements GenericDocForPe
public function buildFetchQueryForPerson(
Person $person,
?DateTimeImmutable $startDate = null,
?DateTimeImmutable $endDate = null,
?string $content = null,
?string $origin = null
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null,
string $origin = null
): FetchQueryInterface {
return $this->personDocumentACLAwareRepository->buildFetchQueryForPerson(
$person,
@@ -50,7 +49,7 @@ final readonly class PersonDocumentGenericDocProvider implements GenericDocForPe
return $this->security->isGranted(PersonDocumentVoter::SEE, $person);
}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
{
return $this->personDocumentACLAwareRepository->buildFetchQueryForAccompanyingPeriod($accompanyingPeriod, $startDate, $endDate, $content);
}

View File

@@ -17,7 +17,6 @@ use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingCourseDocumentGenericDocProvider;
use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository;
use Chill\DocStoreBundle\Repository\PersonDocumentRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
final readonly class AccompanyingCourseDocumentGenericDocRenderer implements GenericDocRendererInterface
{
@@ -28,8 +27,8 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
{
return $genericDocDTO->key === AccompanyingCourseDocumentGenericDocProvider::KEY
|| $genericDocDTO->key === PersonDocumentGenericDocProvider::KEY;
return AccompanyingCourseDocumentGenericDocProvider::KEY === $genericDocDTO->key
|| PersonDocumentGenericDocProvider::KEY === $genericDocDTO->key;
}
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
@@ -47,6 +46,7 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen
'context' => $genericDocDTO->getContext(),
];
}
// this is a person
return [
'document' => $doc = $this->personDocumentRepository->find($genericDocDTO->identifiers['id']),

View File

@@ -22,7 +22,7 @@ final class GenericDocExtension extends AbstractExtension
new TwigFilter('chill_generic_doc_render', [GenericDocExtensionRuntime::class, 'renderGenericDoc'], [
'needs_environment' => true,
'is_safe' => ['html'],
])
]),
];
}
}

View File

@@ -43,6 +43,6 @@ final readonly class GenericDocExtensionRuntime implements RuntimeExtensionInter
}
}
throw new \LogicException("no renderer found");
throw new \LogicException('no renderer found');
}
}

View File

@@ -15,7 +15,6 @@ use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use LogicException;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -28,7 +27,7 @@ final readonly class MenuBuilder implements LocalMenuBuilderInterface
match ($menuId) {
'accompanyingCourse' => $this->buildMenuAccompanyingCourse($menu, $parameters),
'person' => $this->buildMenuPerson($menu, $parameters),
default => throw new LogicException("this menuid {$menuId} is not implemented"),
default => throw new \LogicException("this menuid {$menuId} is not implemented"),
};
}

View File

@@ -55,7 +55,7 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -28,9 +28,6 @@ class DocumentCategoryRepository implements ObjectRepository
$this->repository = $em->getRepository(DocumentCategory::class);
}
/**
* @param mixed $id
*/
public function find($id): ?DocumentCategory
{
return $this->repository->find($id);
@@ -44,7 +41,7 @@ class DocumentCategoryRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -18,14 +18,10 @@ use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
@@ -51,15 +47,14 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
return $qb;
}
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface
{
$query = $this->buildBaseFetchQueryForPerson($person, $startDate, $endDate, $content);
return $this->addFetchQueryByPersonACL($query, $person);
}
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $period, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface
{
$personDocMetadata = $this->em->getClassMetadata(PersonDocument::class);
$participationMetadata = $this->em->getClassMetadata(AccompanyingPeriodParticipation::class);
@@ -118,7 +113,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
return $this->addFilterClauses($query, $startDate, $endDate, $content);
}
public function buildBaseFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
public function buildBaseFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
{
$personDocMetadata = $this->em->getClassMetadata(PersonDocument::class);
@@ -138,7 +133,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
return $this->addFilterClauses($query, $startDate, $endDate, $content);
}
private function addFilterClauses(FetchQuery $query, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
private function addFilterClauses(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
{
$personDocMetadata = $this->em->getClassMetadata(PersonDocument::class);
@@ -165,10 +160,11 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
$personDocMetadata->getColumnName('title'),
$personDocMetadata->getColumnName('description')
),
['%' . $content . '%', '%' . $content . '%'],
['%'.$content.'%', '%'.$content.'%'],
[Types::STRING, Types::STRING]
);
}
return $query;
}
@@ -188,7 +184,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
$this->addACL($qb, $person);
foreach ($orderBy as $field => $order) {
$qb->addOrderBy('d.' . $field, $order);
$qb->addOrderBy('d.'.$field, $order);
}
$qb->setFirstResult($offset)->setMaxResults($limit);
@@ -207,7 +203,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
->getReachableScopes(
PersonDocumentVoter::SEE,
$center
)
),
];
}
@@ -230,7 +226,7 @@ final readonly class PersonDocumentACLAwareRepository implements PersonDocumentA
foreach ($this->centerResolverManager->resolveCenters($person) as $center) {
$reachableScopes = [
...$reachableScopes,
...$this->authorizationHelperForCurrentUser->getReachableScopes(PersonDocumentVoter::SEE, $center)
...$this->authorizationHelperForCurrentUser->getReachableScopes(PersonDocumentVoter::SEE, $center),
];
}

View File

@@ -29,15 +29,15 @@ interface PersonDocumentACLAwareRepositoryInterface
public function buildFetchQueryForPerson(
Person $person,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
): FetchQueryInterface;
public function buildFetchQueryForAccompanyingPeriod(
AccompanyingPeriod $period,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
): FetchQueryInterface;
}

View File

@@ -15,7 +15,6 @@ use Chill\DocStoreBundle\Entity\PersonDocument;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
use UnexpectedValueException;
/**
* @template ObjectRepository<PersonDocument::class>
@@ -40,7 +39,7 @@ readonly class PersonDocumentRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -44,7 +44,7 @@ final class StoredObjectRepository implements ObjectRepository
*
* @return array<int, StoredObject>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}

View File

@@ -23,8 +23,6 @@ use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use function in_array;
class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
final public const CREATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE';
@@ -96,7 +94,7 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
if (
AccompanyingPeriod::STEP_CLOSED === $subject->getCourse()->getStep()
&& in_array($attribute, [self::CREATE, self::DELETE, self::UPDATE], true)
&& \in_array($attribute, [self::CREATE, self::DELETE, self::UPDATE], true)
) {
return false;
}

View File

@@ -76,7 +76,7 @@ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHiera
}
/**
* @param string $attribute
* @param string $attribute
* @param PersonDocument $subject
*
* @return bool

View File

@@ -15,8 +15,6 @@ use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\StoredObjectRepository;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
use function array_key_exists;
use function is_array;
class StoredObjectDenormalizer implements DenormalizerInterface
{
@@ -37,11 +35,11 @@ class StoredObjectDenormalizer implements DenormalizerInterface
public function supportsDenormalization($data, $type, $format = null)
{
if (false === is_array($data)) {
if (false === \is_array($data)) {
return false;
}
if (false === array_key_exists('id', $data)) {
if (false === \array_key_exists('id', $data)) {
return false;
}

View File

@@ -15,19 +15,11 @@ use Base64Url\Base64Url;
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use RuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
use Throwable;
use function array_key_exists;
use const OPENSSL_RAW_DATA;
final class StoredObjectManager implements StoredObjectManagerInterface
{
@@ -37,7 +29,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
public function __construct(private readonly HttpClientInterface $client, private readonly TempUrlGeneratorInterface $tempUrlGenerator) {}
public function getLastModified(StoredObject $document): DateTimeInterface
public function getLastModified(StoredObject $document): \DateTimeInterface
{
if ($this->hasCache($document)) {
$response = $this->getResponseFromCache($document);
@@ -69,7 +61,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
try {
$data = $response->getContent();
} catch (Throwable $e) {
} catch (\Throwable $e) {
throw StoredObjectManagerException::unableToGetResponseContent($e);
}
@@ -82,7 +74,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
self::ALGORITHM,
// TODO: Why using this library and not use base64_decode() ?
Base64Url::decode($document->getKeyInfos()['k']),
OPENSSL_RAW_DATA,
\OPENSSL_RAW_DATA,
pack('C*', ...$document->getIv())
);
@@ -105,7 +97,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
self::ALGORITHM,
// TODO: Why using this library and not use base64_decode() ?
Base64Url::decode($document->getKeyInfos()['k']),
OPENSSL_RAW_DATA,
\OPENSSL_RAW_DATA,
pack('C*', ...$document->getIv())
)
: $clearContent;
@@ -130,24 +122,23 @@ final class StoredObjectManager implements StoredObjectManagerInterface
throw StoredObjectManagerException::errorDuringHttpRequest($exception);
}
if ($response->getStatusCode() !== Response::HTTP_CREATED) {
if (Response::HTTP_CREATED !== $response->getStatusCode()) {
throw StoredObjectManagerException::invalidStatusCode($response->getStatusCode());
}
}
private function extractLastModifiedFromResponse(ResponseInterface $response): DateTimeImmutable
private function extractLastModifiedFromResponse(ResponseInterface $response): \DateTimeImmutable
{
$lastModifiedString = (($response->getHeaders()['last-modified'] ?? [])[0] ?? '');
$date = DateTimeImmutable::createFromFormat(
DateTimeImmutable::RFC7231,
$date = \DateTimeImmutable::createFromFormat(
\DateTimeImmutable::RFC7231,
$lastModifiedString,
new DateTimeZone('GMT')
new \DateTimeZone('GMT')
);
if (false === $date) {
throw new RuntimeException('the date from remote storage could not be parsed: '
. $lastModifiedString);
throw new \RuntimeException('the date from remote storage could not be parsed: '.$lastModifiedString);
}
return $date;
@@ -168,11 +159,11 @@ final class StoredObjectManager implements StoredObjectManagerInterface
)
->url
);
} catch (Throwable $e) {
} catch (\Throwable $e) {
throw StoredObjectManagerException::errorDuringHttpRequest($e);
}
if ($response->getStatusCode() !== Response::HTTP_OK) {
if (Response::HTTP_OK !== $response->getStatusCode()) {
throw StoredObjectManagerException::invalidStatusCode($response->getStatusCode());
}
@@ -190,7 +181,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
private function hasCache(StoredObject $document): bool
{
return array_key_exists($document->getUuid()->toString(), $this->inMemory);
return \array_key_exists($document->getUuid()->toString(), $this->inMemory);
}
private function hasKeysAndIv(StoredObject $storedObject): bool

View File

@@ -12,26 +12,25 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Service;
use Chill\DocStoreBundle\Entity\StoredObject;
use DateTimeInterface;
interface StoredObjectManagerInterface
{
public function getLastModified(StoredObject $document): DateTimeInterface;
public function getLastModified(StoredObject $document): \DateTimeInterface;
/**
* Get the content of a StoredObject.
*
* @param StoredObject $document The document.
* @param StoredObject $document the document
*
* @return string The retrieved content in clear.
* @return string the retrieved content in clear
*/
public function read(StoredObject $document): string;
/**
* Set the content of a StoredObject.
*
* @param StoredObject $document The document.
* @param $clearContent The content to store in clear.
* @param StoredObject $document the document
* @param $clearContent The content to store in clear
*/
public function write(StoredObject $document, string $clearContent): void;
}

View File

@@ -18,8 +18,6 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Twig\Environment;
use Twig\Extension\RuntimeExtensionInterface;
use function in_array;
final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
{
public const SUPPORTED_MIMES = [
@@ -132,7 +130,7 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
*/
public function isEditable(StoredObject $document): bool
{
return in_array($document->getType(), self::SUPPORTED_MIMES, true);
return \in_array($document->getType(), self::SUPPORTED_MIMES, true);
}
/**
@@ -142,7 +140,7 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/
public function renderButtonGroup(Environment $environment, StoredObject $document, ?string $title = null, bool $canEdit = true, array $options = []): string
public function renderButtonGroup(Environment $environment, StoredObject $document, string $title = null, bool $canEdit = true, array $options = []): string
{
return $environment->render(self::TEMPLATE_BUTTON_GROUP, [
'document' => $document,
@@ -153,7 +151,7 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
]);
}
public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string
public function renderEditButton(Environment $environment, StoredObject $document, array $options = null): string
{
return $environment->render(self::TEMPLATE, [
'document' => $document,

View File

@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
*
* @coversNothing
*/
class FetchQueryToSqlBuilderTest extends KernelTestCase
@@ -35,21 +36,21 @@ class FetchQueryToSqlBuilderTest extends KernelTestCase
$query->addJoinClause('LEFT JOIN other d ON a.id = d.foreign_id', ['bar_baz'], [Types::STRING]);
$query->removeJoinClause($index);
$query->addWhereClause('b.item = ?', ['baz'], [Types::STRING]);
$index = $query->addWhereClause('b.cancel', [ 'foz'], [Types::STRING]);
$index = $query->addWhereClause('b.cancel', ['foz'], [Types::STRING]);
$query->removeWhereClause($index);
['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query);
$filteredSql =
implode(" ", array_filter(
explode(" ", str_replace("\n", "", $sql)),
fn (string $tok) => $tok !== ""
implode(' ', array_filter(
explode(' ', str_replace("\n", '', $sql)),
fn (string $tok) => '' !== $tok
))
;
self::assertEquals(
"SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ".
"a.datecolumn::date AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?",
'a.datecolumn::date AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?',
$filteredSql
);
self::assertEquals(['foo', 'bar_baz', 'baz'], $params);
@@ -68,15 +69,15 @@ class FetchQueryToSqlBuilderTest extends KernelTestCase
['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query);
$filteredSql =
implode(" ", array_filter(
explode(" ", str_replace("\n", "", $sql)),
fn (string $tok) => $tok !== ""
implode(' ', array_filter(
explode(' ', str_replace("\n", '', $sql)),
fn (string $tok) => '' !== $tok
))
;
self::assertEquals(
"SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ".
"a.datecolumn::date AS doc_date FROM my_table a",
'a.datecolumn::date AS doc_date FROM my_table a',
$filteredSql
);
self::assertEquals([], $params);

View File

@@ -19,7 +19,6 @@ use Chill\DocStoreBundle\GenericDoc\Manager;
use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface;
@@ -28,6 +27,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
*
* @coversNothing
*/
class ManagerTest extends KernelTestCase
@@ -52,7 +52,7 @@ class ManagerTest extends KernelTestCase
->getSingleResult();
if (null === $period) {
throw new \UnexpectedValueException("period not found");
throw new \UnexpectedValueException('period not found');
}
$manager = new Manager(
@@ -73,7 +73,7 @@ class ManagerTest extends KernelTestCase
->getSingleResult();
if (null === $person) {
throw new \UnexpectedValueException("person found");
throw new \UnexpectedValueException('person found');
}
$manager = new Manager(
@@ -94,7 +94,7 @@ class ManagerTest extends KernelTestCase
->getSingleResult();
if (null === $period) {
throw new \UnexpectedValueException("period not found");
throw new \UnexpectedValueException('period not found');
}
$manager = new Manager(
@@ -115,7 +115,7 @@ class ManagerTest extends KernelTestCase
->getSingleResult();
if (null === $person) {
throw new \UnexpectedValueException("person not found");
throw new \UnexpectedValueException('person not found');
}
$manager = new Manager(
@@ -136,7 +136,7 @@ class ManagerTest extends KernelTestCase
->getSingleResult();
if (null === $person) {
throw new \UnexpectedValueException("person not found");
throw new \UnexpectedValueException('person not found');
}
$manager = new Manager(
@@ -157,7 +157,7 @@ class ManagerTest extends KernelTestCase
->getSingleResult();
if (null === $period) {
throw new \UnexpectedValueException("period not found");
throw new \UnexpectedValueException('period not found');
}
$manager = new Manager(
@@ -174,7 +174,7 @@ class ManagerTest extends KernelTestCase
final readonly class SimpleGenericDocAccompanyingPeriodProvider implements GenericDocForAccompanyingPeriodProviderInterface
{
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
{
$query = new FetchQuery(
'accompanying_course_document_dummy',
@@ -196,7 +196,7 @@ final readonly class SimpleGenericDocAccompanyingPeriodProvider implements Gener
final readonly class SimpleGenericDocPersonProvider implements GenericDocForPersonProviderInterface
{
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
{
$query = new FetchQuery(
'dummy_person_doc',

View File

@@ -15,7 +15,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder;
use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingCourseDocumentGenericDocProvider;
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -23,6 +22,7 @@ use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase
@@ -40,14 +40,14 @@ class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase
/**
* @dataProvider provideSearchArguments
*/
public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content = null): void
public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, string $content = null): void
{
$period = $this->entityManager->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a')
->setMaxResults(1)
->getSingleResult();
if (null === $period) {
throw new \UnexpectedValueException("period not found");
throw new \UnexpectedValueException('period not found');
}
$security = $this->prophesize(Security::class);

View File

@@ -15,7 +15,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder;
use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider;
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -23,6 +22,7 @@ use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
class PersonDocumentGenericDocProviderTest extends KernelTestCase
@@ -42,11 +42,12 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase
/**
* @dataProvider provideDataBuildFetchQueryForPerson
*
* @throws \Doctrine\DBAL\Exception
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function testBuildFetchQueryForPerson(?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): void
public function testBuildFetchQueryForPerson(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void
{
$security = $this->prophesize(Security::class);
$person = $this->entityManager->createQuery('SELECT a FROM '.Person::class.' a')
@@ -54,7 +55,7 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase
->getSingleResult();
if (null === $person) {
throw new \UnexpectedValueException("person found");
throw new \UnexpectedValueException('person found');
}
$provider = new PersonDocumentGenericDocProvider(
@@ -69,16 +70,16 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase
$nb = $this->entityManager->getConnection()
->fetchOne("SELECT COUNT(*) AS nb FROM ({$sql}) AS sq", $params, $types);
self::assertIsInt($nb, "Test that the query is syntactically correct");
self::assertIsInt($nb, 'Test that the query is syntactically correct');
}
public function provideDataBuildFetchQueryForPerson(): iterable
{
yield [null, null, null];
yield [new DateTimeImmutable('1 year ago'), null, null];
yield [null, new DateTimeImmutable('1 year ago'), null];
yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null];
yield [new \DateTimeImmutable('1 year ago'), null, null];
yield [null, new \DateTimeImmutable('1 year ago'), null];
yield [new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), null];
yield [null, null, 'test'];
yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test'];
yield [new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), 'test'];
}
}

View File

@@ -17,13 +17,9 @@ use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
@@ -32,6 +28,7 @@ use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
@@ -51,11 +48,12 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
/**
* @dataProvider provideDataBuildFetchQueryForPerson
*
* @throws \Doctrine\DBAL\Exception
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function testBuildFetchQueryForPerson(?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): void
public function testBuildFetchQueryForPerson(\DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): void
{
$centerManager = $this->prophesize(CenterResolverManagerInterface::class);
$centerManager->resolveCenters(Argument::type(Person::class))
@@ -72,12 +70,12 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
$this->prophesize(Security::class)->reveal()
);
$person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p")
$person = $this->entityManager->createQuery('SELECT p FROM '.Person::class.' p')
->setMaxResults(1)
->getSingleResult();
if (null === $person) {
throw new \RuntimeException("person not exists in database");
throw new \RuntimeException('person not exists in database');
}
$query = $repository->buildFetchQueryForPerson($person, $startDate, $endDate, $content);
@@ -86,7 +84,7 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
$nb = $this->entityManager->getConnection()
->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types);
self::assertIsInt($nb, "test that the query could be executed");
self::assertIsInt($nb, 'test that the query could be executed');
}
/**
@@ -94,9 +92,9 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
*/
public function testBuildFetchQueryForAccompanyingPeriod(
AccompanyingPeriod $period,
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
): void {
$centerManager = $this->prophesize(CenterResolverManagerInterface::class);
$centerManager->resolveCenters(Argument::type(Person::class))
@@ -122,7 +120,7 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
$nb = $this->entityManager->getConnection()
->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types);
self::assertIsInt($nb, "test that the query could be executed");
self::assertIsInt($nb, 'test that the query could be executed');
}
public function provideDateForFetchQueryForAccompanyingPeriod(): iterable
@@ -130,27 +128,27 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase
$this->setUp();
if (null === $period = $this->entityManager->createQuery(
"SELECT p FROM " . AccompanyingPeriod::class . " p WHERE SIZE(p.participations) > 0"
'SELECT p FROM '.AccompanyingPeriod::class.' p WHERE SIZE(p.participations) > 0'
)
->setMaxResults(1)->getSingleResult()) {
throw new \RuntimeException("no course found");
throw new \RuntimeException('no course found');
}
yield [$period, null, null, null];
yield [$period, new DateTimeImmutable('1 year ago'), null, null];
yield [$period, null, new DateTimeImmutable('1 year ago'), null];
yield [$period, new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null];
yield [$period, new \DateTimeImmutable('1 year ago'), null, null];
yield [$period, null, new \DateTimeImmutable('1 year ago'), null];
yield [$period, new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), null];
yield [$period, null, null, 'test'];
yield [$period, new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test'];
yield [$period, new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), 'test'];
}
public function provideDataBuildFetchQueryForPerson(): iterable
{
yield [null, null, null];
yield [new DateTimeImmutable('1 year ago'), null, null];
yield [null, new DateTimeImmutable('1 year ago'), null];
yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null];
yield [new \DateTimeImmutable('1 year ago'), null, null];
yield [null, new \DateTimeImmutable('1 year ago'), null];
yield [new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), null];
yield [null, null, 'test'];
yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test'];
yield [new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), 'test'];
}
}

View File

@@ -16,9 +16,7 @@ use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
use Chill\DocStoreBundle\Service\StoredObjectManager;
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
use Generator;
use PHPUnit\Framework\TestCase;
use stdClass;
use Symfony\Component\HttpClient\Exception\TransportException;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
@@ -32,7 +30,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
*/
final class StoredObjectManagerTest extends TestCase
{
public function getDataProvider(): Generator
public function getDataProvider(): \Generator
{
/* HAPPY SCENARIO */
@@ -92,7 +90,7 @@ final class StoredObjectManagerTest extends TestCase
/**
* @dataProvider getDataProvider
*/
public function testRead(StoredObject $storedObject, string $encodedContent, string $clearContent, ?string $exceptionClass = null)
public function testRead(StoredObject $storedObject, string $encodedContent, string $clearContent, string $exceptionClass = null)
{
if (null !== $exceptionClass) {
$this->expectException($exceptionClass);
@@ -106,7 +104,7 @@ final class StoredObjectManagerTest extends TestCase
/**
* @dataProvider getDataProvider
*/
public function testWrite(StoredObject $storedObject, string $encodedContent, string $clearContent, ?string $exceptionClass = null)
public function testWrite(StoredObject $storedObject, string $encodedContent, string $clearContent, string $exceptionClass = null)
{
if (null !== $exceptionClass) {
$this->expectException($exceptionClass);
@@ -144,7 +142,6 @@ final class StoredObjectManagerTest extends TestCase
case 'https://example.com/error_during_http_request.txt':
throw new TransportException('error_during_http_request.txt');
case 'https://example.com/invalid_statuscode.txt':
return new MockResponse($encodedContent, ['http_code' => 404]);
}
@@ -166,7 +163,7 @@ final class StoredObjectManagerTest extends TestCase
private function getTempUrlGenerator(StoredObject $storedObject): TempUrlGeneratorInterface
{
$response = new stdClass();
$response = new \stdClass();
$response->url = $storedObject->getFilename();
$tempUrlGenerator = $this->createMock(TempUrlGeneratorInterface::class);

View File

@@ -64,7 +64,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
}
return $this->translator->trans('workflow.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()])
. ' - ' . $doc->getTitle();
.' - '.$doc->getTitle();
}
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingCourseDocument
@@ -119,7 +119,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
{
return $entityWorkflow->getRelatedEntityClass() === AccompanyingCourseDocument::class;
return AccompanyingCourseDocument::class === $entityWorkflow->getRelatedEntityClass();
}
public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool

View File

@@ -21,14 +21,14 @@ final class Version20180605102533 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP SCHEMA chill_doc CASCADE');
}
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA chill_doc');
$this->addSql('CREATE SEQUENCE chill_doc.person_document_id_seq INCREMENT BY 1 MINVALUE 1 START 1');

View File

@@ -21,7 +21,7 @@ final class Version20180606133338 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C232D562B');
$this->addSql('DROP SEQUENCE chill_doc.stored_object_id_seq CASCADE');
@@ -32,7 +32,7 @@ final class Version20180606133338 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE chill_doc.stored_object_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_doc.stored_object (id INT NOT NULL, filename TEXT NOT NULL, key JSON NOT NULL, iv JSON NOT NULL, creation_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, type TEXT NOT NULL, datas JSON NOT NULL, PRIMARY KEY(id))');