Merge remote-tracking branch 'origin/master' into features/docgen-widget-generate-template

This commit is contained in:
2021-11-30 16:38:36 +01:00
1055 changed files with 5050 additions and 2165 deletions

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

View File

@@ -39,6 +39,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Serializer\SerializerInterface;
use function array_key_exists;
final class ActivityController extends AbstractController
{
@@ -105,18 +106,19 @@ final class ActivityController extends AbstractController
[$person, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig';
} elseif ($person instanceof Person) {
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
}
$activity = $this->activityRepository->find($id);
if (!$activity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
if ($activity->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig';
$accompanyingPeriod = $activity->getAccompanyingPeriod();
} else {
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
}
// TODO
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
@@ -137,7 +139,7 @@ final class ActivityController extends AbstractController
static fn (ActivityReason $ar): int => $ar->getId()
)
->toArray(),
'type_id' => $activity->getType()->getId(),
'type_id' => $activity->getActivityType()->getId(),
'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
'date' => $activity->getDate()->format('Y-m-d'),
'attendee' => $activity->getAttendee(),
@@ -176,25 +178,25 @@ final class ActivityController extends AbstractController
[$person, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig';
} elseif ($person instanceof Person) {
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
}
$entity = $this->activityRepository->find($id);
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
if ($entity->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig';
$accompanyingPeriod = $entity->getAccompanyingPeriod();
} else {
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
}
// TODO
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);
$form = $this->createForm(ActivityType::class, $entity, [
'center' => $entity->getCenter(),
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
'activityType' => $entity->getType(),
'activityType' => $entity->getActivityType(),
'accompanyingPeriod' => $accompanyingPeriod,
])->handleRequest($request);
@@ -327,7 +329,7 @@ final class ActivityController extends AbstractController
$entity->setAccompanyingPeriod($accompanyingPeriod);
}
$entity->setType($activityType);
$entity->setActivityType($activityType);
$entity->setDate(new DateTime('now'));
if ($request->query->has('activityData')) {
@@ -385,7 +387,7 @@ final class ActivityController extends AbstractController
$form = $this->createForm(ActivityType::class, $entity, [
'center' => $entity->getCenter(),
'role' => new Role('CHILL_ACTIVITY_CREATE'),
'activityType' => $entity->getType(),
'activityType' => $entity->getActivityType(),
'accompanyingPeriod' => $accompanyingPeriod,
])->handleRequest($request);
@@ -408,7 +410,7 @@ final class ActivityController extends AbstractController
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
$defaultLocationId = $this->getUser()->getCurrentLocation()->getId();
$defaultLocation = $this->getUser()->getCurrentLocation();
return $this->render($view, [
'person' => $person,
@@ -416,7 +418,7 @@ final class ActivityController extends AbstractController
'entity' => $entity,
'form' => $form->createView(),
'activity_json' => $activity_array,
'default_location_id' => $defaultLocationId,
'default_location' => $defaultLocation,
]);
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReason;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
@@ -23,6 +25,7 @@ class AdminActivityTypeController extends CRUDController
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
/** @var \Doctrine\ORM\QueryBuilder $query */
return $query->orderBy('e.ordering', 'ASC');
return $query->orderBy('e.ordering', 'ASC')
->addOrderBy('e.id', 'ASC');
}
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\Activity;
@@ -48,7 +50,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
->findAll();
foreach ($persons as $person) {
$activityNbr = rand(0, 3);
$activityNbr = mt_rand(0, 3);
for ($i = 0; $i < $activityNbr; ++$i) {
$activity = $this->newRandomActivity($person);
@@ -73,7 +75,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
// ->setAttendee($this->faker->boolean())
for ($i = 0; rand(0, 4) > $i; ++$i) {
for ($i = 0; mt_rand(0, 4) > $i; ++$i) {
$reason = $this->getRandomActivityReason();
if (null !== $reason) {

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\Activity;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityReason;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityType;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityTypeCategory;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@@ -17,6 +19,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_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
@@ -47,7 +50,7 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
case 'administrative':
case 'direction':
if (in_array($scope->getName()['en'], ['administrative', 'social'])) {
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
break 2; // we do not want any power on social or administrative
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DependencyInjection;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
@@ -67,7 +69,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
]);
}
/* (non-PHPdoc)
/** (non-PHPdoc).
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
public function prependRoutes(ContainerBuilder $container)

View File

@@ -7,10 +7,13 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use function is_int;
/**
* This is the class that validates and merges configuration from your app/config files.
@@ -55,7 +58,7 @@ class Configuration implements ConfigurationInterface
->info('The number of seconds of this duration. Must be an integer.')
->cannotBeEmpty()
->validate()
->ifTrue(function ($data) {
->ifTrue(static function ($data) {
return !is_int($data);
})->thenInvalid('The value %s is not a valid integer')
->end()

View File

@@ -7,8 +7,11 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Chill\ActivityBundle\Validator\Constraints as ActivityValidator;
use Chill\DocStoreBundle\Entity\Document;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
@@ -17,6 +20,7 @@ use Chill\MainBundle\Entity\HasScopeInterface;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
@@ -41,17 +45,14 @@ use Symfony\Component\Serializer\Annotation\SerializedName;
* @DiscriminatorMap(typeProperty="type", mapping={
* "activity": Activity::class
* })
*/
/*
* TODO : revoir
* @ActivityValidator\ActivityValidity
*
* @UserCircleConsistency(
* "CHILL_ACTIVITY_SEE_DETAILS",
* getUserFunction="getUser",
* path="scope")
* "CHILL_ACTIVITY_SEE_DETAILS",
* getUserFunction="getUser",
* path="scope")
*/
class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, HasCenterInterface, HasScopeInterface
{
public const SENTRECEIVED_RECEIVED = 'received';
@@ -202,7 +203,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
public function addPerson(?Person $person): self
{
if (null !== $person) {
$this->persons[] = $person;
if (!$this->persons->contains($person)) {
$this->persons[] = $person;
}
}
return $this;
@@ -236,7 +239,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
public function addThirdParty(?ThirdParty $thirdParty): self
{
if (null !== $thirdParty) {
$this->thirdParties[] = $thirdParty;
if (!$this->thirdParties->contains($thirdParty)) {
$this->thirdParties[] = $thirdParty;
}
}
return $this;
@@ -245,7 +250,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
public function addUser(?User $user): self
{
if (null !== $user) {
$this->users[] = $user;
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
}
return $this;
@@ -346,8 +353,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
if (null !== $this->accompanyingPeriod) {
$personsNotAssociated = [];
// TODO better semantic with: return $this->persons->filter(...);
foreach ($this->persons as $person) {
if (!in_array($person, $this->getPersonsAssociated())) {
if ($this->accompanyingPeriod->getOpenParticipationContainsPerson($person) === null) {
$personsNotAssociated[] = $person;
}
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;

View File

@@ -7,11 +7,14 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class ActivityType.
@@ -29,11 +32,13 @@ class ActivityType
public const FIELD_REQUIRED = 2;
/**
* @deprecated not in use
* @ORM\Column(type="string", nullable=false, options={"default": ""})
*/
private string $accompanyingPeriodLabel = '';
/**
* @deprecated not in use
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
*/
private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE;
@@ -195,16 +200,21 @@ class ActivityType
/**
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
* @Assert\EqualTo(propertyPath="socialIssuesVisible", message="This parameter must be equal to social issue parameter")
*/
private int $socialActionsVisible = self::FIELD_INVISIBLE;
/**
* @ORM\Column(type="string", nullable=false, options={"default": ""})
*
* @deprecated not in use
*/
private string $socialDataLabel = '';
/**
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
*
* @deprecated not in use
*/
private int $socialDataVisible = self::FIELD_INVISIBLE;
@@ -260,16 +270,6 @@ class ActivityType
*/
private int $userVisible = self::FIELD_REQUIRED;
public function getAccompanyingPeriodLabel(): string
{
return $this->accompanyingPeriodLabel;
}
public function getAccompanyingPeriodVisible(): int
{
return $this->accompanyingPeriodVisible;
}
/**
* Get active
* return true if the type is active.
@@ -446,16 +446,6 @@ class ActivityType
return $this->socialActionsVisible;
}
public function getSocialDataLabel(): string
{
return $this->socialDataLabel;
}
public function getSocialDataVisible(): int
{
return $this->socialDataVisible;
}
public function getSocialIssuesLabel(): ?string
{
return $this->socialIssuesLabel;
@@ -537,20 +527,6 @@ class ActivityType
return self::FIELD_INVISIBLE !== $this->{$property};
}
public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): self
{
$this->accompanyingPeriodLabel = $accompanyingPeriodLabel;
return $this;
}
public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): self
{
$this->accompanyingPeriodVisible = $accompanyingPeriodVisible;
return $this;
}
/**
* Set active
* set to true if the type is active.
@@ -768,20 +744,6 @@ class ActivityType
return $this;
}
public function setSocialDataLabel(string $socialDataLabel): self
{
$this->socialDataLabel = $socialDataLabel;
return $this;
}
public function setSocialDataVisible(int $socialDataVisible): self
{
$this->socialDataVisible = $socialDataVisible;
return $this;
}
public function setSocialIssuesLabel(string $socialIssuesLabel): self
{
$this->socialIssuesLabel = $socialIssuesLabel;

View File

@@ -25,6 +25,8 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface
{
@@ -72,7 +74,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
array_key_exists('activity', $join)
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
)
or (!array_key_exists('activity', $join))
|| (!array_key_exists('activity', $join))
) {
$qb->add(
'join',

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;

View File

@@ -28,6 +28,8 @@ use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
use function in_array;
class ListActivity implements ListInterface
{
@@ -73,7 +75,7 @@ class ListActivity implements ListInterface
'choices' => array_combine($this->fields, $this->fields),
'label' => 'Fields to include in export',
'constraints' => [new Callback([
'callback' => function ($selected, ExecutionContextInterface $context) {
'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
$context->buildViolation('You must select at least one element')
->atPath('fields')
@@ -187,7 +189,7 @@ class ListActivity implements ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(function ($el) { return $el['center']; }, $acl);
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {
@@ -204,7 +206,7 @@ class ListActivity implements ListInterface
->setParameter('authorized_centers', $centers);
foreach ($this->fields as $f) {
if (in_array($f, $data['fields'])) {
if (in_array($f, $data['fields'], true)) {
switch ($f) {
case 'id':
$qb->addSelect('activity.id AS id');

View File

@@ -89,7 +89,7 @@ class ActivityDateFilter implements FilterInterface
);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/* @var $filterForm \Symfony\Component\Form\FormInterface */
/** @var \Symfony\Component\Form\FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();

View File

@@ -25,8 +25,10 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
class ActivityReasonFilter implements FilterInterface, ExportElementValidatedInterface
class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInterface
{
protected ActivityReasonRepository $activityReasonRepository;

View File

@@ -24,8 +24,9 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class ActivityTypeFilter implements FilterInterface, ExportElementValidatedInterface
class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface
{
protected ActivityTypeRepository $activityTypeRepository;

View File

@@ -31,8 +31,9 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportElementValidatedInterface
class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInterface, FilterInterface
{
protected ActivityReasonRepository $activityReasonRepository;
@@ -134,7 +135,7 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportEl
]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/* @var FormInterface $filterForm */
/** @var FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Entity\ActivityPresence;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Entity\Activity;
@@ -46,6 +48,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array;
class ActivityType extends AbstractType
{
@@ -124,7 +127,7 @@ class ActivityType extends AbstractType
$builder->add('socialIssues', HiddenType::class);
$builder->get('socialIssues')
->addModelTransformer(new CallbackTransformer(
function (iterable $socialIssuesAsIterable): string {
static function (iterable $socialIssuesAsIterable): string {
$socialIssueIds = [];
foreach ($socialIssuesAsIterable as $value) {
@@ -150,7 +153,7 @@ class ActivityType extends AbstractType
$builder->add('socialActions', HiddenType::class);
$builder->get('socialActions')
->addModelTransformer(new CallbackTransformer(
function (iterable $socialActionsAsIterable): string {
static function (iterable $socialActionsAsIterable): string {
$socialActionIds = [];
foreach ($socialActionsAsIterable as $value) {
@@ -202,7 +205,7 @@ class ActivityType extends AbstractType
'choice_label' => function (ActivityPresence $activityPresence) {
return $this->translatableStringHelper->localize($activityPresence->getName());
},
'query_builder' => function (EntityRepository $er) {
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('a')
->where('a.active = true');
},
@@ -228,7 +231,7 @@ class ActivityType extends AbstractType
return $this->translatableStringHelper->localize($activityReason->getName());
},
'attr' => ['class' => 'select2 '],
'query_builder' => function (EntityRepository $er) {
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('a')
->where('a.active = true');
},
@@ -247,7 +250,7 @@ class ActivityType extends AbstractType
$builder->add('persons', HiddenType::class);
$builder->get('persons')
->addModelTransformer(new CallbackTransformer(
function (iterable $personsAsIterable): string {
static function (iterable $personsAsIterable): string {
$personIds = [];
foreach ($personsAsIterable as $value) {
@@ -269,7 +272,7 @@ class ActivityType extends AbstractType
$builder->add('thirdParties', HiddenType::class);
$builder->get('thirdParties')
->addModelTransformer(new CallbackTransformer(
function (iterable $thirdpartyAsIterable): string {
static function (iterable $thirdpartyAsIterable): string {
$thirdpartyIds = [];
foreach ($thirdpartyAsIterable as $value) {
@@ -302,7 +305,7 @@ class ActivityType extends AbstractType
$builder->add('users', HiddenType::class);
$builder->get('users')
->addModelTransformer(new CallbackTransformer(
function (iterable $usersAsIterable): string {
static function (iterable $usersAsIterable): string {
$userIds = [];
foreach ($usersAsIterable as $value) {
@@ -324,7 +327,7 @@ class ActivityType extends AbstractType
$builder->add('location', HiddenType::class)
->get('location')
->addModelTransformer(new CallbackTransformer(
function (?Location $location): string {
static function (?Location $location): string {
if (null === $location) {
return '';
}
@@ -364,7 +367,7 @@ class ActivityType extends AbstractType
->addModelTransformer($durationTimeTransformer);
$builder->get($fieldName)
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $formEvent) use (
->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $formEvent) use (
$timeChoices,
$builder,
$durationTimeTransformer,
@@ -374,7 +377,7 @@ class ActivityType extends AbstractType
// set the timezone to GMT, and fix the difference between current and GMT
// the datetimetransformer will then handle timezone as GMT
$timezoneUTC = new DateTimeZone('GMT');
/* @var $data \DateTime */
/** @var DateTime $data */
$data = $formEvent->getData() === null ?
DateTime::createFromFormat('U', 300) :
$formEvent->getData();
@@ -384,7 +387,7 @@ class ActivityType extends AbstractType
// test if the timestamp is in the choices.
// If not, recreate the field with the new timestamp
if (!in_array($data->getTimestamp(), $timeChoices)) {
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
// the data are not in the possible values. add them
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
$form = $builder->create($fieldName, ChoiceType::class, array_merge(

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Entity\ActivityTypeCategory;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
@@ -56,7 +58,7 @@ class ActivityTypeType extends AbstractType
'persons', 'user', 'date', 'place', 'persons',
'thirdParties', 'durationTime', 'travelTime', 'attendee',
'reasons', 'comment', 'sentReceived', 'documents',
'emergency', 'accompanyingPeriod', 'socialData', 'users',
'emergency', 'socialIssues', 'socialActions', 'users',
];
foreach ($fields as $field) {

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
use Chill\ActivityBundle\Entity\ActivityType;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
use Chill\ActivityBundle\Entity\ActivityReason;
@@ -55,7 +57,7 @@ class TranslatableActivityReason extends AbstractType
return null;
},
'query_builder' => function (EntityRepository $er) {
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('r')
->where('r.active = true');
},

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
@@ -37,7 +39,7 @@ class TranslatableActivityReasonCategory extends AbstractType
[
'class' => 'ChillActivityBundle:ActivityReasonCategory',
'choice_label' => 'name[' . $locale . ']',
'query_builder' => function (EntityRepository $er) {
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.active = true');
},

View File

@@ -37,7 +37,7 @@ class TranslatableActivityType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
/* @var QueryBuilder $qb */
/** @var QueryBuilder $qb */
$qb = $options['query_builder'];
if (true === $options['active_only']) {

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Menu;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;

View File

@@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security;
use function in_array;
final class AdminMenuBuilder implements LocalMenuBuilderInterface
{
@@ -30,7 +31,7 @@ final class AdminMenuBuilder implements LocalMenuBuilderInterface
return;
}
if (in_array($menuId, ['admin_index', 'admin_section'])) {
if (in_array($menuId, ['admin_index', 'admin_section'], true)) {
$menu->addChild('Activities', [
'route' => 'chill_admin_activity_index',
])

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Menu;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
@@ -37,7 +39,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
/* @var $person \Chill\PersonBundle\Entity\Person */
/** @var \Chill\PersonBundle\Entity\Person $person */
$person = $parameters['person'];
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Notification;
use Chill\ActivityBundle\Entity\Activity;
@@ -26,6 +28,6 @@ final class ActivityNotificationRenderer
public function supports(Notification $notification, array $options = []): bool
{
return $notification->getRelatedEntityClass() == Activity::class;
return $notification->getRelatedEntityClass() === Activity::class;
}
}

View File

@@ -22,6 +22,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security;
use function count;
use function in_array;
final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface
@@ -159,14 +160,14 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
foreach ($reachableCenters as $center) {
// we pass if not in centers
if (!in_array($center, $args['centers'])) {
if (!in_array($center, $args['centers'], true)) {
continue;
}
// we get all the reachable scopes for this center
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
// we get the ids for those scopes
$reachablesScopesId = array_map(
function (Scope $scope) { return $scope->getId(); },
static function (Scope $scope) { return $scope->getId(); },
$reachableScopes
);

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Repository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;

View File

@@ -1,7 +1,7 @@
<template>
<concerned-groups></concerned-groups>
<social-issues-acc></social-issues-acc>
<location></location>
<concerned-groups v-if="hasPerson"></concerned-groups>
<social-issues-acc v-if="hasSocialIssues"></social-issues-acc>
<location v-if="hasLocation"></location>
</template>
<script>
@@ -11,6 +11,7 @@ import Location from './components/Location.vue';
export default {
name: "App",
props: ['hasSocialIssues', 'hasLocation', 'hasPerson'],
components: {
ConcernedGroups,
SocialIssuesAcc,

View File

@@ -1,4 +1,5 @@
import { getSocialIssues } from 'ChillPersonAssets/vuejs/AccompanyingCourse/api.js';
import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods';
/*
* Load socialActions by socialIssue (id)
@@ -12,33 +13,20 @@ const getSocialActionByIssue = (id) => {
});
};
/*
* Load Locations
*/
const getLocations = () => {
const url = `/api/1.0/main/location.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
const getLocations = () => fetchResults('/api/1.0/main/location.json');
const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json');
/*
* Load Location Types
* Load Location Type by defaultFor
* @param {string} entity - can be "person" or "thirdparty"
*/
const getLocationTypes = () => {
const url = `/api/1.0/main/location-type.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
const getLocationTypeByDefaultFor = (entity) => {
return getLocationTypes().then(results =>
results.filter(t => t.defaultFor === entity)[0]
);
};
/*
* Post a Location
*/
const postLocation = (body) => {
const url = `/api/1.0/main/location.json`;
return fetch(url, {
@@ -59,5 +47,6 @@ export {
getSocialActionByIssue,
getLocations,
getLocationTypes,
getLocationTypeByDefaultFor,
postLocation
};

View File

@@ -1,35 +1,33 @@
<template>
<teleport to="#add-persons" v-if="isComponentVisible">
<teleport to="#add-persons" v-if="isComponentVisible">
<div class="flex-bloc concerned-groups" :class="getContext">
<persons-bloc
v-for="bloc in contextPersonsBlocs"
v-bind:key="bloc.key"
v-bind:bloc="bloc"
v-bind:setPersonsInBloc="setPersonsInBloc">
</persons-bloc>
</div>
<div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0">
<ul class="list-unstyled">
<li v-for="p in suggestedEntities" @click="addSuggestedEntity(p)">
<span class="badge bg-primary" style="cursor: pointer;">
<i class="fa fa-plus fa-fw text-success"></i>
{{ p.text }}
</span>
</li>
</ul>
</div>
<div class="flex-bloc concerned-groups" :class="getContext">
<persons-bloc
v-for="bloc in contextPersonsBlocs"
v-bind:key="bloc.key"
v-bind:bloc="bloc"
v-bind:blocWidth="getBlocWidth"
v-bind:setPersonsInBloc="setPersonsInBloc">
</persons-bloc>
</div>
<div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0">
<ul class="list-suggest add-items">
<li v-for="p in suggestedEntities" @click="addSuggestedEntity(p)">
<span>{{ p.text }}</span>
</li>
</ul>
</div>
<add-persons
buttonTitle="activity.add_persons"
modalTitle="activity.add_persons"
v-bind:key="addPersons.key"
v-bind:options="addPersonsOptions"
@addNewPersons="addNewPersons"
ref="addPersons">
</add-persons>
<add-persons
buttonTitle="activity.add_persons"
modalTitle="activity.add_persons"
v-bind:key="addPersons.key"
v-bind:options="addPersonsOptions"
@addNewPersons="addNewPersons"
ref="addPersons">
</add-persons>
</teleport>
</teleport>
</template>
<script>
@@ -122,6 +120,9 @@ export default {
}
}
},
getBlocWidth() {
return Math.round(100/(this.contextPersonsBlocs.length)) + '%';
}
},
mounted() {
this.setPersonsInBloc();

View File

@@ -1,12 +1,8 @@
<template>
<li>
<span class="badge bg-primary" :title="person.text">
<span class="chill_denomination">
{{ textCutted }}
</span>
<a class="fa fa-fw fa-times text-danger text-decoration-none"
@click.prevent="$emit('remove', person)">
</a>
<span :title="person.text">
<span class="chill_denomination">{{ textCutted }}</span>
<a @click.prevent="$emit('remove', person)"></a>
</span>
</li>
</template>

View File

@@ -1,11 +1,11 @@
<template>
<div class="item-bloc">
<div class="item-bloc" :style="{ 'flex-basis': blocWidth }">
<div class="item-row">
<div class="item-col">
<h4>{{ $t(bloc.title) }}</h4>
</div>
<div class="item-col">
<ul class="list-content">
<ul class="list-suggest remove-items">
<person-badge
v-for="person in bloc.persons"
v-bind:key="person.id"
@@ -25,7 +25,7 @@ export default {
components: {
PersonBadge
},
props: ['bloc', 'setPersonsInBloc'],
props: ['bloc', 'setPersonsInBloc', 'blocWidth'],
methods: {
removePerson(item) {
console.log('@@ CLICK remove person: item', item);

View File

@@ -2,10 +2,9 @@
<teleport to="#location">
<div class="mb-3 row">
<label class="col-form-label col-sm-4">
{{ $t('activity.location') }}
{{ $t("activity.location") }}
</label>
<div class="col-sm-8">
<VueMultiselect
name="selectLocation"
id="selectLocation"
@@ -17,7 +16,10 @@
:placeholder="$t('activity.choose_location')"
:custom-label="customLabel"
:options="locations"
v-model="location">
group-values="locations"
group-label="locationGroup"
v-model="location"
>
</VueMultiselect>
<new-location v-bind:locations="locations"></new-location>
@@ -27,49 +29,146 @@
</template>
<script>
import { mapState } from "vuex";
import VueMultiselect from 'vue-multiselect';
import NewLocation from './Location/NewLocation.vue';
import { getLocations } from '../api.js';
import { mapState, mapGetters } from "vuex";
import VueMultiselect from "vue-multiselect";
import NewLocation from "./Location/NewLocation.vue";
import { getLocations, getLocationTypeByDefaultFor } from "../api.js";
export default {
name: "Location",
components: {
NewLocation,
VueMultiselect
VueMultiselect,
},
data() {
return {
locations: []
}
locations: [],
};
},
computed: {
...mapState(['activity']),
...mapState(["activity"]),
...mapGetters(["suggestedEntities"]),
location: {
get() {
return this.activity.location;
},
set(value) {
this.$store.dispatch('updateLocation', value);
}
}
this.$store.dispatch("updateLocation", value);
},
},
},
mounted() {
getLocations().then(response => new Promise(resolve => {
console.log('getLocations', response);
this.locations = response.results;
if (window.default_location_id) {
let location = this.locations.filter(l => l.id === window.default_location_id);
this.$store.dispatch('updateLocation', location);
}
resolve();
}))
getLocations().then(
(results) => {
getLocationTypeByDefaultFor('person').then(
(personLocationType) => {
if (personLocationType) {
const personLocation = this.makeAccompanyingPeriodLocation(personLocationType);
const concernedPersonsLocation =
this.makeConcernedPersonsLocation(personLocationType);
getLocationTypeByDefaultFor('thirdparty').then(
thirdpartyLocationType => {
const concernedThirdPartiesLocation =
this.makeConcernedThirdPartiesLocation(thirdpartyLocationType);
this.locations = [
{
locationGroup: 'Localisation du parcours',
locations: [personLocation]
},
{
locationGroup: 'Parties concernées',
locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation]
},
{
locationGroup: 'Autres localisations',
locations: results
}
];
}
)
} else {
this.locations = [
{
locationGroup: 'Localisations',
locations: response.results
}
];
}
if (window.default_location_id) {
let location = this.locations.filter(
(l) => l.id === window.default_location_id
);
this.$store.dispatch("updateLocation", location);
}
}
)
})
},
methods: {
labelAccompanyingCourseLocation(value) {
return `${value.address.text} (${value.locationType.title.fr})`
},
customLabel(value) {
return `${value.locationType.title.fr} ${value.name ? value.name : ''}`;
return value.locationType
? value.name
? value.name === '__AccompanyingCourseLocation__'
? this.labelAccompanyingCourseLocation(value)
: `${value.name} (${value.locationType.title.fr})`
: value.locationType.title.fr
: '';
},
makeConcernedPersonsLocation(locationType) {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
if (e.type === 'person' && e.current_household_address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: {
id: e.current_household_address.address_id,
},
locationType: locationType
});
}
}
)
return locations;
},
makeConcernedThirdPartiesLocation(locationType) {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
if (e.type === 'thirdparty' && e.address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: { id: e.address.address_id },
locationType: locationType
});
}
}
)
return locations;
},
makeAccompanyingPeriodLocation(locationType) {
const accPeriodLocation = this.activity.accompanyingPeriod.location;
return {
type: 'location',
id: -1,
onthefly: true,
name: '__AccompanyingCourseLocation__',
address: {
id: accPeriodLocation.address_id,
text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}`
},
locationType: locationType
}
}
}
}
},
};
</script>

View File

@@ -214,11 +214,9 @@ export default {
return cond;
},
getLocationTypesList() {
getLocationTypes().then(response => new Promise(resolve => {
console.log('getLocationTypes', response);
this.locationTypes = response.results.filter(t => t.availableForUsers === true);
resolve();
}))
getLocationTypes().then(results => {
this.locationTypes = results.filter(t => t.availableForUsers === true);
})
},
openModal() {
this.modal.showModal = true;
@@ -247,7 +245,6 @@ export default {
postLocation(body)
.then(
location => new Promise(resolve => {
console.log('postLocation', location);
this.locations.push(location);
this.$store.dispatch('updateLocation', location);
resolve();

View File

@@ -50,19 +50,26 @@
<i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i>
</div>
<check-social-action
v-if="socialIssuesSelected.length || socialActionsSelected.length"
v-for="action in socialActionsList"
v-bind:key="action.id"
v-bind:action="action"
v-bind:selection="socialActionsSelected"
@updateSelected="updateActionsSelected">
</check-social-action>
<span v-else class="inline-choice chill-no-data-statement mt-3">
<span v-else-if="socialIssuesSelected.length === 0" class="inline-choice chill-no-data-statement mt-3">
{{ $t('activity.select_first_a_social_issue') }}
</span>
<template v-else-if="socialActionsList.length > 0">
<check-social-action
v-if="socialIssuesSelected.length || socialActionsSelected.length"
v-for="action in socialActionsList"
v-bind:key="action.id"
v-bind:action="action"
v-bind:selection="socialActionsSelected"
@updateSelected="updateActionsSelected">
</check-social-action>
</template>
<span v-else-if="actionAreLoaded && socialActionsList.length === 0" class="inline-choice chill-no-data-statement mt-3">
{{ $t('activity.social_action_list_empty') }}
</span>
</div>
</div>
@@ -85,7 +92,8 @@ export default {
data() {
return {
issueIsLoading: false,
actionIsLoading: false
actionIsLoading: false,
actionAreLoaded: false,
}
},
computed: {
@@ -109,6 +117,7 @@ export default {
/* Load others issues in multiselect
*/
this.issueIsLoading = true;
this.actionAreLoaded = false;
getSocialIssues().then(response => new Promise((resolve, reject) => {
this.$store.commit('updateIssuesOther', response.results);
@@ -141,6 +150,8 @@ export default {
this.$store.commit('filterList', 'actions');
this.issueIsLoading = false;
this.actionAreLoaded = true;
this.updateActionsList();
resolve();
}));
},
@@ -173,7 +184,6 @@ export default {
to get social actions concerned
*/
updateActionsList() {
//console.log('updateActionsList');
this.resetActionsList();
this.socialIssuesSelected.forEach(item => {
@@ -188,6 +198,7 @@ export default {
this.$store.commit('filterList', 'actions');
this.actionIsLoading = false;
this.actionAreLoaded = true;
resolve();
}));
}, this);
@@ -196,6 +207,7 @@ export default {
*/
resetActionsList() {
this.$store.commit('resetActionsList');
this.actionAreLoaded = false;
this.socialActionsSelected.forEach(item => {
this.$store.commit('addActionInList', item);
}, this);

View File

@@ -1,18 +1,18 @@
<template>
<span class="inline-choice">
<div class="form-check">
<input class="form-check-input"
type="checkbox"
type="checkbox"
v-model="selected"
name="action"
v-bind:id="action.id"
v-bind:id="action.id"
v-bind:value="action"
/>
<label class="form-check-label" v-bind:for="action.id">
{{ action.text }}
<span class="badge bg-light text-dark">{{ action.text }}</span>
</label>
</div>
</span>
</template>
@@ -34,3 +34,15 @@ export default {
}
}
</script>
<style lang="scss" scoped>
@import 'ChillMainAssets/module/bootstrap/shared';
@import 'ChillPersonAssets/chill/scss/mixins';
@import 'ChillMainAssets/chill/scss/chill_variables';
span.badge {
@include badge_social($social-action-color);
font-size: 95%;
margin-bottom: 5px;
margin-right: 1em;
}
</style>

View File

@@ -1,18 +1,18 @@
<template>
<span class="inline-choice">
<div class="form-check">
<input class="form-check-input"
type="checkbox"
type="checkbox"
v-model="selected"
name="issue"
v-bind:id="issue.id"
v-bind:id="issue.id"
v-bind:value="issue"
/>
<label class="form-check-label" v-bind:for="issue.id">
{{ issue.text }}
<span class="badge bg-chill-l-gray text-dark">{{ issue.text }}</span>
</label>
</div>
</span>
</template>
@@ -34,3 +34,15 @@ export default {
}
}
</script>
<style lang="scss" scoped>
@import 'ChillMainAssets/module/bootstrap/shared';
@import 'ChillPersonAssets/chill/scss/mixins';
@import 'ChillMainAssets/chill/scss/chill_variables';
span.badge {
@include badge_social($social-issue-color);
font-size: 95%;
margin-bottom: 5px;
margin-right: 1em;
}
</style>

View File

@@ -9,6 +9,7 @@ const activityMessages = {
choose_other_social_issue: "Ajouter une autre problématique sociale...",
social_actions: "Actions d'accompagnement",
select_first_a_social_issue: "Sélectionnez d'abord une problématique sociale",
social_action_list_empty: "Aucune action sociale disponible",
//
add_persons: "Ajouter des personnes concernées",

View File

@@ -7,8 +7,19 @@ import App from './App.vue';
const i18n = _createI18n(activityMessages);
const hasSocialIssues = document.querySelector('#social-issues-acc') !== null;
const hasLocation = document.querySelector('#location') !== null;
const hasPerson = document.querySelector('#add-persons') !== null;
const app = createApp({
template: `<app></app>`,
template: `<app :hasSocialIssues="hasSocialIssues", :hasLocation="hasLocation", :hasPerson="hasPerson"></app>`,
data() {
return {
hasSocialIssues,
hasLocation,
hasPerson,
};
}
})
.use(store)
.use(i18n)

View File

@@ -1,5 +1,6 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postLocation } from './api';
const debug = process.env.NODE_ENV !== 'production';
//console.log('window.activity', window.activity);
@@ -27,7 +28,6 @@ const store = createStore({
},
getters: {
suggestedEntities(state) {
console.log(state.activity);
if (typeof state.activity.accompanyingPeriod === "undefined") {
return [];
}
@@ -303,7 +303,33 @@ const store = createStore({
let hiddenLocation = document.getElementById(
"chill_activitybundle_activity_location"
);
hiddenLocation.value = value.id;
if (value.onthefly) {
const body = {
"type": "location",
"name": value.name === '__AccompanyingCourseLocation__' ? null : value.name,
"locationType": {
"id": value.locationType.id,
"type": "location-type"
}
};
if (value.address.id) {
Object.assign(body, {
"address": {
"id": value.address.id
},
})
}
postLocation(body)
.then(
location => hiddenLocation.value = location.id
).catch(
err => {
console.log(err.message);
}
);
} else {
hiddenLocation.value = value.id;
}
commit("updateLocation", value);
},
},

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
@@ -18,7 +20,7 @@ use Symfony\Component\HttpFoundation\Request;
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
|| !(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');

View File

@@ -26,23 +26,45 @@
{{ activity.type.name | localize_translatable_string }}
<ul class="small_in_title">
{% if activity.location and t.locationVisible %}
<li>
<span class="item-key">{{ 'location'|trans ~ ': ' }}</span>
<span>{{ activity.location.locationType.title|localize_translatable_string }}</span>
{{ activity.location.name }}
</li>
{% if activity.emergency %}
<span class="badge bg-danger rounded-pill fs-6">{{ 'Emergency'|trans|upper }}</span>
{% endif %}
<ul class="small_in_title mt-3">
{% if activity.sentReceived is not empty and t.sentReceivedVisible %}
<li>
<span class="item-key">{{ 'Sent received'|trans ~ ' : ' }}</span>
<b>{{ activity.sentReceived|capitalize|trans }}</b>
</li>
{% endif %}
{% if activity.location and t.locationVisible %}
<li>
<span class="item-key">{{ 'location'|trans ~ ': ' }}</span>
<b>
<span>{{ activity.location.locationType.title|localize_translatable_string }}</span>
{{ activity.location.name }}
</b>
</li>
{% endif %}
{% if activity.user and t.userVisible %}
<li>
<span class="item-key">{{ 'Referrer'|trans ~ ': ' }}</span>
{{ activity.user.usernameCanonical }}
<b>{{ activity.user.usernameCanonical }}</b>
</li>
{% endif %}
<li class="associated-persons">
<span class="item-key">{{ 'Participants'|trans ~ ' : ' }}</span>
{% for p in activity.personsAssociated %}
<span class="badge-person">{{ p|chill_entity_render_box }}</span>
{% endfor %}
</li>
</ul>
<ul class="list-content">
<ul class="list-content my-3">
{%- if t.reasonsVisible -%}
{%- if activity.reasons is not empty -%}
<li class="reasons">
@@ -71,11 +93,9 @@
{%- endif -%}
{% endif %}
</ul>
</span>
</h2>
{#
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
<div class="mt-3">
<a class="btn btn-sm btn-outline-primary"
@@ -87,4 +107,4 @@
</a>
</div>
{% endif %}
#}

View File

@@ -3,89 +3,93 @@
{{ path(pathname, parms) }}
{% endmacro %}
{% if context == 'person' %}
{% set blocs = [
{ 'title': 'Others persons'|trans,
{% macro computeWidth(nbBlocks) %}
{{ 'flex-basis: ' ~ (100 / nbBlocks)|round(1) ~ '%;' }}
{% endmacro %}
{% set blocks = [] %}
{% if entity.activityType.personsVisible %}
{% if context == 'person' %}
{% set blocks = blocks|merge([{
'title': 'Others persons'|trans,
'items': entity.persons,
'path' : 'chill_person_view',
'key' : 'person_id'
},
{ 'title': 'Third parties'|trans,
'items': entity.thirdParties,
'path' : 'chill_crud_3party_3party_view',
'key' : 'id'
},
{ 'title': 'Users concerned'|trans,
'items': entity.users,
'key' : 'id'
},
] %}
{% else %}
{% set blocs = [
{ 'title': 'Persons in accompanying course'|trans,
}]) %}
{% else %}
{% set blocks = blocks|merge([{
'title': 'Persons in accompanying course'|trans,
'items': entity.personsAssociated,
'path' : 'chill_person_view',
'key' : 'person_id'
},
{ 'title': 'Third persons'|trans,
},{
'title': 'Third persons'|trans,
'items': entity.personsNotAssociated,
'path' : 'chill_person_view',
'key' : 'person_id'
},
{ 'title': 'Third parties'|trans,
'items': entity.thirdParties,
'path' : 'chill_crud_3party_3party_view',
'key' : 'id'
},
{ 'title': 'Users concerned'|trans,
'items': entity.users,
'key' : 'id'
},
] %}
'key' : 'person_id',
}]) %}
{% endif %}
{% endif %}
{% if entity.activityType.thirdPartiesVisible %}
{% set blocks = blocks|merge([{
'title': 'Third parties'|trans,
'items': entity.thirdParties,
'path' : 'chill_crud_3party_3party_view',
'key' : 'id',
}]) %}
{% endif %}
{% if entity.activityType.usersVisible %}
{% set blocks = blocks|merge([{
'title': 'Users concerned'|trans,
'items': entity.users,
'key' : 'id',
}]) %}
{% endif %}
{% if (with_display == 'bloc') %}
<div class="{{ context }} flex-bloc concerned-groups">
{% for bloc in blocs %}
<div class="item-bloc">
<div class="item-row">
<div class="item-col">
<h4>{{ bloc.title }}</h4>
</div>
<div class="item-col">
<ul class="list-content">
{% for item in bloc.items %}
<li>
{% if bloc.path is defined %}
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
{{ item|chill_entity_render_box({
'render': 'raw',
'addAltNames': false
}) }}
</span>
</a>
{% else %}
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
{{ item|chill_entity_render_box({
'render': 'raw',
'addAltNames': false
}) }}
</span>
{% endif %}
</li>
{% endfor %}
</ul>
{% for bloc in blocks %}
<div class="item-bloc" style="{{ _self.computeWidth(loop.length) }}">
<div class="item-row">
<div class="item-col">
<h4>{{ bloc.title }}</h4>
</div>
<div class="item-col">
<ul class="list-content">
{% for item in bloc.items %}
<li>
{% if bloc.path is defined %}
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
{{ item|chill_entity_render_box({
'render': 'raw',
'addAltNames': false
}) }}
</span>
</a>
{% else %}
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
{{ item|chill_entity_render_box({
'render': 'raw',
'addAltNames': false
}) }}
</span>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if (with_display == 'row') %}
<div class="concerned-groups">
{% for bloc in blocs %}
{% for bloc in blocks %}
<div class="group">
{% if bloc.items|length > 0 %}
<h4>{{ bloc.title }}</h4>
@@ -118,7 +122,7 @@
{% if (with_display == 'wrap-list') %}
<div class="concerned-groups wrap-list">
{% for bloc in blocs %}
{% for bloc in blocks %}
<div class="wl-row">
{% if bloc.items|length > 0 %}
<div class="wl-col title">

View File

@@ -28,7 +28,9 @@
{{ form_row(edit_form.socialActions) }}
{% endif %}
{%- if edit_form.socialIssues is defined or edit_form.socialIssues is defined -%}
<div id="social-issues-acc"></div>
{% endif %}
{%- if edit_form.reasons is defined -%}
{{ form_row(edit_form.reasons) }}
@@ -46,9 +48,10 @@
{%- if edit_form.users is defined -%}
{{ form_widget(edit_form.users) }}
{% endif %}
<div id="add-persons"></div>
{% endif %}
<div id="add-persons"></div>
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>

View File

@@ -2,9 +2,11 @@
{% for activity in activities | slice(0,5) %}
{% set t = activity.type %}
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}"></a>
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}"
class="badge-link" title="{{ 'Show the activity'|trans }}">
{% include '@ChillActivity/Activity/activity-badge-title.html.twig' %}
{% include '@ChillActivity/Activity/activity-badge-title.html.twig' %}
</a>
{% endfor %}
</div>

View File

@@ -29,25 +29,31 @@
{{ form_row(form.socialActions) }}
{% endif %}
<div id="social-issues-acc"></div>
{%- if form.socialIssues is defined or form.socialIssues is defined -%}
<div id="social-issues-acc"></div>
{% endif %}
{%- if form.reasons is defined -%}
{{ form_row(form.reasons) }}
{% endif %}
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
{%- if form.persons is defined or form.thirdParties is defined or form.users is defined -%}
{%- if form.persons is defined -%}
{{ form_widget(form.persons) }}
{% endif %}
{%- if form.thirdParties is defined -%}
{{ form_widget(form.thirdParties) }}
{% endif %}
{%- if form.users is defined -%}
{{ form_widget(form.users) }}
{% endif %}
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
<div id="add-persons"></div>
{%- if form.persons is defined -%}
{{ form_widget(form.persons) }}
{% endif %}
{%- if form.thirdParties is defined -%}
{{ form_widget(form.thirdParties) }}
{% endif %}
{%- if form.users is defined -%}
{{ form_widget(form.users) }}
{% endif %}
<div id="add-persons"></div>
{% endif %}
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>

View File

@@ -22,7 +22,7 @@
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
});
window.activity = {{ activity_json|json_encode|raw }};
window.default_location_id = {{ default_location_id }};
{% if default_location is not null %}window.default_location_id = {{ default_location.id }}{% endif %};
</script>
{{ encore_entry_script_tags('vue_activity') }}
{% endblock %}

View File

@@ -27,7 +27,7 @@
<dt class="inline">{{ 'Social issues'|trans }}</dt>
<dd>
{% if entity.socialIssues|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any social issues'|trans }}</p>
<p class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</p>
{% else %}
{% for si in entity.socialIssues %}{{ si|chill_entity_render_box }}{% endfor %}
{% endif %}
@@ -38,7 +38,7 @@
<dt class="inline">{{ 'Social actions'|trans }}</dt>
<dd>
{% if entity.socialActions|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any social actions'|trans }}</p>
<p class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</p>
{% else %}
{% for sa in entity.socialActions %}{{ sa|chill_entity_render_box }}{% endfor %}
{% endif %}
@@ -67,8 +67,8 @@
<dd>
{% if entity.location is not null %}
<p>
<span>{{ entity.location.locationType.title|localize_translatable_string }}</span>
{{ entity.location.name }}
<span> ({{ entity.location.locationType.title|localize_translatable_string }})</span>
</p>
{{ entity.location.address|chill_entity_render_box }}
{% else %}

View File

@@ -9,7 +9,7 @@
{% block content -%}
<div class="activity-show">
{% include 'ChillActivityBundle:Activity:show.html.twig' with {'context': 'accompanyingCourse'} %}
{% include 'ChillActivityBundle:Activity:show.html.twig' with {'context': 'accompanyingCourse'} %}
</div>
{% endblock content %}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Security\Authorization;
use Chill\MainBundle\Entity\Center;
@@ -63,7 +65,7 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
protected function supports($attribute, $subject)
{
if ($subject instanceof Center
&& in_array($attribute, $this->getAttributes())) {
&& in_array($attribute, $this->getAttributes(), true)) {
return true;
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Templating\Entity;
use Chill\ActivityBundle\Entity\ActivityReason;

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Test;
use Chill\ActivityBundle\Entity\Activity;

View File

@@ -7,21 +7,25 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Role\Role;
use function count;
use function in_array;
/**
* @internal
* @coversNothing
*/
class ActivityControllerTest extends WebTestCase
final class ActivityControllerTest extends WebTestCase
{
public function getSecuredPagesAuthenticated()
{
static::bootKernel();
self::bootKernel();
$person = $this->getPersonFromFixtures();
$activities = $this->getActivitiesForPerson($person);
@@ -57,7 +61,7 @@ class ActivityControllerTest extends WebTestCase
*/
public function getSecuredPagesUnauthenticated()
{
static::bootKernel();
self::bootKernel();
$person = $this->getPersonFromFixtures();
$activities = $this->getActivitiesForPerson($person);
@@ -200,7 +204,7 @@ class ActivityControllerTest extends WebTestCase
*/
private function createFakeUser()
{
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$em = $container->get('doctrine.orm.entity_manager');
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
@@ -242,7 +246,7 @@ class ActivityControllerTest extends WebTestCase
private function getActivitiesForPerson(\Chill\PersonBundle\Entity\Person $person)
{
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$activities = $em->getRepository('ChillActivityBundle:Activity')
@@ -263,7 +267,7 @@ class ActivityControllerTest extends WebTestCase
*/
private function getAuthenticatedClient($username = 'center a_social')
{
return static::createClient([], [
return self::createClient([], [
'PHP_AUTH_USER' => $username,
'PHP_AUTH_PW' => 'password',
]);
@@ -274,7 +278,7 @@ class ActivityControllerTest extends WebTestCase
*/
private function getPersonFromFixtures()
{
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$person = $em->getRepository('ChillPersonBundle:Person')
@@ -298,14 +302,14 @@ class ActivityControllerTest extends WebTestCase
*/
private function getRandomActivityReason(array $excludeIds = [])
{
$reasons = static::$kernel->getContainer()
$reasons = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillActivityBundle:ActivityReason')
->findAll();
$reason = $reasons[array_rand($reasons)];
if (in_array($reason->getId(), $excludeIds)) {
if (in_array($reason->getId(), $excludeIds, true)) {
return $this->getRandomActivityReason($excludeIds);
}
@@ -317,7 +321,7 @@ class ActivityControllerTest extends WebTestCase
*/
private function getRandomActivityType()
{
$types = static::$kernel->getContainer()
$types = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillActivityBundle:ActivityType')
->findAll();
@@ -333,7 +337,7 @@ class ActivityControllerTest extends WebTestCase
*/
private function getRandomScope($username, $centerName)
{
$user = static::$kernel->getContainer()
$user = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:User')
->findOneByUsername($username);
@@ -343,20 +347,20 @@ class ActivityControllerTest extends WebTestCase
. 'does not exists in database. Did you add fixtures ?');
}
$center = static::$kernel->getContainer()
$center = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:Center')
->findOneByName($centerName);
// get scope reachable by both role UPDATE and DELETE
$reachableScopesUpdate = static::$kernel->getContainer()
$reachableScopesUpdate = self::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes(
$user,
new Role('CHILL_ACTIVITY_UPDATE'),
$center
);
$reachableScopesDelete = static::$kernel->getContainer()
$reachableScopesDelete = self::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes(
$user,
@@ -364,8 +368,8 @@ class ActivityControllerTest extends WebTestCase
$center
);
$reachableScopesId = array_intersect(
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete),
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate)
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
);
if (count($reachableScopesId) === 0) {
@@ -374,7 +378,7 @@ class ActivityControllerTest extends WebTestCase
}
foreach ($reachableScopesUpdate as $scope) {
if (in_array($scope->getId(), $reachableScopesId)) {
if (in_array($scope->getId(), $reachableScopesId, true)) {
$reachableScopes[] = $scope;
}
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -15,7 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ActivityReasonCategoryControllerTest extends WebTestCase
final class ActivityReasonCategoryControllerTest extends WebTestCase
{
public function testToWrite()
{

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -15,7 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ActivityReasonControllerTest extends WebTestCase
final class ActivityReasonControllerTest extends WebTestCase
{
public function testToWrite()
{

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -15,7 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ActivityTypeControllerTest extends WebTestCase
final class ActivityTypeControllerTest extends WebTestCase
{
public function testToWrite()
{

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Aggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
@@ -17,7 +19,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
class ActivityReasonAggregatorTest extends AbstractAggregatorTest
final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
@@ -26,9 +28,9 @@ class ActivityReasonAggregatorTest extends AbstractAggregatorTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
@@ -57,11 +59,11 @@ class ActivityReasonAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Aggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
@@ -17,7 +19,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
class ActivityTypeAggregatorTest extends AbstractAggregatorTest
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
@@ -26,9 +28,9 @@ class ActivityTypeAggregatorTest extends AbstractAggregatorTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
@@ -56,11 +58,11 @@ class ActivityTypeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Aggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
@@ -17,7 +19,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
class ActivityUserAggregatorTest extends AbstractAggregatorTest
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
@@ -26,9 +28,9 @@ class ActivityUserAggregatorTest extends AbstractAggregatorTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
@@ -56,11 +58,11 @@ class ActivityUserAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
@@ -15,7 +17,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
class CountActivityTest extends AbstractExportTest
final class CountActivityTest extends AbstractExportTest
{
/**
* @var
@@ -24,9 +26,9 @@ class CountActivityTest extends AbstractExportTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.count_activity');

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
@@ -15,7 +17,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
class ListActivityTest extends AbstractExportTest
final class ListActivityTest extends AbstractExportTest
{
/**
* @var \Chill\ActivityBundle\Export\Export\ListActivity
@@ -24,9 +26,9 @@ class ListActivityTest extends AbstractExportTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.list_activity');

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
@@ -17,7 +19,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
class StatActivityDurationSumTest extends AbstractExportTest
final class StatActivityDurationSumTest extends AbstractExportTest
{
/**
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
@@ -26,9 +28,9 @@ class StatActivityDurationSumTest extends AbstractExportTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.sum_activity_duration');

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
@@ -16,7 +18,7 @@ use Doctrine\Common\Collections\ArrayCollection;
* @internal
* @coversNothing
*/
class ActivityReasonFilterTest extends AbstractFilterTest
final class ActivityReasonFilterTest extends AbstractFilterTest
{
/**
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
@@ -25,9 +27,9 @@ class ActivityReasonFilterTest extends AbstractFilterTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->filter = $container->get('chill.activity.export.reason_filter');
@@ -48,11 +50,11 @@ class ActivityReasonFilterTest extends AbstractFilterTest
public function getFormData()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$reasons = $em->createQuery('SELECT reason '
@@ -69,11 +71,11 @@ class ActivityReasonFilterTest extends AbstractFilterTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -7,16 +7,19 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use DateTime;
use function array_slice;
/**
* @internal
* @coversNothing
*/
class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
{
/**
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
@@ -25,9 +28,9 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
public function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->filter = $container->get('chill.activity.export.'
. 'person_having_an_activity_between_date_filter');
@@ -68,11 +71,11 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [
@@ -97,11 +100,11 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
*/
private function getActivityReasons()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
return static::$kernel->getContainer()
return self::$kernel->getContainer()
->get('chill_activity.repository.reason')
->findAll();
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form;
use Chill\ActivityBundle\Entity\Activity;
@@ -21,7 +23,7 @@ use Symfony\Component\Security\Core\Role\Role;
* @internal
* @coversNothing
*/
class ActivityTypeTest extends KernelTestCase
final class ActivityTypeTest extends KernelTestCase
{
/**
* @var \Chill\MainBundle\Entity\Center
@@ -119,7 +121,7 @@ class ActivityTypeTest extends KernelTestCase
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
// test the activity
/* @var $activity Activity */
/** @var Activity $activity */
$activity = $form->getData()['activity'];
$this->assertEquals(
@@ -170,7 +172,7 @@ class ActivityTypeTest extends KernelTestCase
$this->assertTrue($form->isValid());
// test the activity
/* @var $activity Activity */
/** @var Activity $activity */
$activity = $form->getData()['activity'];
$this->assertEquals(
@@ -186,7 +188,7 @@ class ActivityTypeTest extends KernelTestCase
// map all the values in an array
$values = array_map(
function ($choice) { return $choice->value; },
static function ($choice) { return $choice->value; },
$view['activity']['durationTime']->vars['choices']
);

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form\Type;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
@@ -20,7 +22,7 @@ use Symfony\Component\Form\Test\TypeTestCase;
* @internal
* @coversNothing
*/
class TranslatableActivityReasonTest extends TypeTestCase
final class TranslatableActivityReasonTest extends TypeTestCase
{
/**
* @var Prophecy\Prophet
@@ -81,7 +83,7 @@ class TranslatableActivityReasonTest extends TypeTestCase
$request->getLocale()->willReturn($fallbackLocale);
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
$requestStack->getCurrentRequest()->will(function () use ($request) {
$requestStack->getCurrentRequest()->will(static function () use ($request) {
return $request;
});

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form\Type;
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
@@ -17,7 +19,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
* @internal
* @coversNothing
*/
class TranslatableActivityTypeTest extends KernelTestCase
final class TranslatableActivityTypeTest extends KernelTestCase
{
/**
* @var \Symfony\Component\Form\FormBuilderInterface

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Security\Authorization;
use Chill\ActivityBundle\Test\PrepareActivityTrait;
@@ -24,7 +26,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
* @internal
* @coversNothing
*/
class ActivityVoterTest extends KernelTestCase
final class ActivityVoterTest extends KernelTestCase
{
use PrepareActivityTrait;
use PrepareCenterTrait;
@@ -44,8 +46,8 @@ class ActivityVoterTest extends KernelTestCase
public function setUp()
{
static::bootKernel();
$this->voter = static::$kernel->getContainer()
self::bootKernel();
$this->voter = self::$kernel->getContainer()
->get('chill.activity.security.authorization.activity_voter');
$this->prophet = new \Prophecy\Prophet();
}

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Timeline;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -15,7 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class TimelineProviderTest extends WebTestCase
final class TimelineProviderTest extends WebTestCase
{
public function testAnActivityIsShownOnTimeline()
{

View File

@@ -119,7 +119,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
*/
private function checkContext(string $context)
{
if (false === in_array($context, self::SUPPORTED_CONTEXTS)) {
if (false === in_array($context, self::SUPPORTED_CONTEXTS, true)) {
throw new LogicException(
sprintf(
"The context '%s' is not supported. Currently only 'person' is supported",
@@ -152,7 +152,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
$associationMapping = $metadataActivity->getAssociationMapping('person');
$role = new Role('CHILL_ACTIVITY_SEE');
$reachableScopes = $this->helper->getReachableScopes($this->user, $role->getRole(), $person->getCenter());
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
$whereClause = ' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ';
$scopes_ids = [];
// first parameter: activity.person_id
@@ -160,7 +160,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
// loop on reachable scopes
foreach ($reachableScopes as $scope) {
if (in_array($scope->getId(), $scopes_ids)) {
if (in_array($scope->getId(), $scopes_ids, true)) {
continue;
}
$scopes_ids[] = '?';

View File

@@ -0,0 +1,44 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class ActivityValidity extends Constraint
{
public const IS_REQUIRED_MESSAGE = ' is required';
public const ROOT_MESSAGE = 'For this type of activity, ';
public $noPersonsMessage = 'For this type of activity, you must add at least one person';
public $noThirdPartiesMessage = 'For this type of activity, you must add at least one third party';
public $noUsersMessage = 'For this type of activity, you must add at least one user';
public $socialActionsMessage = 'For this type of activity, you must add at least one social action';
public $socialIssuesMessage = 'For this type of activity, you must add at least one social issue';
public function getTargets()
{
return self::CLASS_CONSTRAINT;
}
public function makeIsRequiredMessage(string $property)
{
return self::ROOT_MESSAGE . $property . self::IS_REQUIRED_MESSAGE;
}
}

View File

@@ -0,0 +1,141 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Validator\Constraints;
use Chill\ActivityBundle\Entity\Activity;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function array_merge;
use function count;
class ActivityValidityValidator extends ConstraintValidator
{
public function validate($activity, Constraint $constraint)
{
if (!$constraint instanceof ActivityValidity) {
throw new UnexpectedTypeException($constraint, ActivityValidity::class);
}
if (!$activity instanceof Activity) {
throw new UnexpectedValueException($activity, Activity::class);
}
if ($activity->getActivityType()->getPersonsVisible() === 2 && count($activity->getPersons()) === 0) {
$this->context
->buildViolation($constraint->noPersonsMessage)
->addViolation();
}
if ($activity->getActivityType()->getUsersVisible() === 2 && count($activity->getUsers()) === 0) {
$this->context
->buildViolation($constraint->noUsersMessage)
->addViolation();
}
if ($activity->getActivityType()->getThirdPartiesVisible() === 2 && count($activity->getThirdParties()) === 0) {
$this->context
->buildViolation($constraint->noThirdPartiesMessage)
->addViolation();
}
if ($activity->getActivityType()->getUserVisible() === 2 && null === $activity->getUser()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('user'))
->addViolation();
}
if ($activity->getActivityType()->getDateVisible() === 2 && null === $activity->getDate()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('date'))
->addViolation();
}
if ($activity->getActivityType()->getLocationVisible() === 2 && null === $activity->getLocation()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('location'))
->addViolation();
}
if ($activity->getActivityType()->getDurationTimeVisible() === 2 && null === $activity->getDurationTime()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('duration time'))
->addViolation();
}
if ($activity->getActivityType()->getTravelTimeVisible() === 2 && null === $activity->getTravelTime()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('travel time'))
->addViolation();
}
if ($activity->getActivityType()->getAttendeeVisible() === 2 && null === $activity->getAttendee()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('attendee'))
->addViolation();
}
if ($activity->getActivityType()->getReasonsVisible() === 2 && null === $activity->getReasons()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('reasons'))
->addViolation();
}
if ($activity->getActivityType()->getCommentVisible() === 2 && null === $activity->getComment()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('comment'))
->addViolation();
}
if ($activity->getActivityType()->getSentReceivedVisible() === 2 && null === $activity->getSentReceived()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('sent/received'))
->addViolation();
}
if ($activity->getActivityType()->getDocumentsVisible() === 2 && null === $activity->getDocuments()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('document'))
->addViolation();
}
if ($activity->getActivityType()->getEmergencyVisible() === 2 && null === $activity->getEmergency()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('emergency'))
->addViolation();
}
if ($activity->getActivityType()->getSocialIssuesVisible() === 2 && $activity->getSocialIssues()->count() === 0) {
$this->context
->buildViolation($constraint->socialIssuesMessage)
->addViolation();
}
if ($activity->getActivityType()->getSocialActionsVisible() === 2 && $activity->getSocialActions()->count() === 0) {
// check if a social action may be added
$actions = [];
foreach ($activity->getSocialIssues() as $socialIssue) {
/** @var SocialIssue $socialIssue */
$actions = array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray());
}
if (0 < count($actions)) {
$this->context
->buildViolation($constraint->socialActionsMessage)
->addViolation();
}
}
}
}

View File

@@ -27,3 +27,8 @@ services:
Chill\ActivityBundle\Repository\:
resource: '../Repository/'
Chill\ActivityBundle\Validator\Constraints\:
autowire: true
autoconfigure: true
resource: '../Validator/Constraints/'

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -20,7 +22,7 @@ class Version20150701091248 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity DROP CONSTRAINT FK_55026B0C59BB1592');
$this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2');
@@ -38,7 +40,7 @@ class Version20150701091248 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1');

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -20,7 +22,7 @@ class Version20150702093317 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN name;');
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN label VARCHAR(255) NOT NULL;');
@@ -33,7 +35,7 @@ class Version20150702093317 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN label;');
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -20,7 +22,7 @@ class Version20150704091347 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark SET NOT NULL;');
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');
@@ -29,7 +31,7 @@ class Version20150704091347 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark DROP NOT NULL;');
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -23,7 +25,7 @@ class Version20160222103457 extends AbstractMigration
public function down(Schema $schema): void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
'Migration can only be executed safely on \'postgresql\'.'
);
@@ -35,7 +37,7 @@ class Version20160222103457 extends AbstractMigration
// try to keep at least on activity reason...
$this->addSql(
'UPDATE activity
'UPDATE activity
SET reason_id=rid
FROM (
SELECT activity_id AS aid, MIN(activityreason_id) AS rid
@@ -50,7 +52,7 @@ class Version20160222103457 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
'Migration can only be executed safely on \'postgresql\'.'
);

View File

@@ -7,6 +7,8 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;

View File

@@ -13,6 +13,7 @@ namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use function count;
/**
* Auto-generated Migration: Please modify to your needs!

Some files were not shown because too many files have changed in this diff Show More