mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -23,7 +23,7 @@ class AsideActivityCategoryController extends CRUDController
|
||||
{
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
/** @var QueryBuilder $query */
|
||||
/* @var QueryBuilder $query */
|
||||
$query->addOrderBy('e.ordering', 'ASC');
|
||||
|
||||
return $query;
|
||||
|
@@ -16,7 +16,6 @@ use Chill\AsideActivityBundle\Repository\AsideActivityCategoryRepository;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
use DateTime;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class AsideActivityController extends CRUDController
|
||||
@@ -31,7 +30,7 @@ final class AsideActivityController extends CRUDController
|
||||
$asideActivity->setLocation($this->getUser()->getCurrentLocation());
|
||||
|
||||
$duration = $request->query->get('duration', '300');
|
||||
$duration = DateTime::createFromFormat('U', $duration);
|
||||
$duration = \DateTime::createFromFormat('U', $duration);
|
||||
$asideActivity->setDuration($duration);
|
||||
|
||||
$categoryId = $request->query->get('type', 7);
|
||||
@@ -48,7 +47,7 @@ final class AsideActivityController extends CRUDController
|
||||
return $asideActivity;
|
||||
}
|
||||
|
||||
protected function buildQueryEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null)
|
||||
protected function buildQueryEntities(string $action, Request $request, FilterOrderHelper $filterOrder = null)
|
||||
{
|
||||
$qb = parent::buildQueryEntities($action, $request);
|
||||
|
||||
|
@@ -14,14 +14,10 @@ namespace Chill\AsideActivityBundle\DataFixtures\ORM;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
use function random_int;
|
||||
|
||||
class LoadAsideActivity extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function __construct(private readonly UserRepository $userRepository) {}
|
||||
@@ -42,15 +38,15 @@ class LoadAsideActivity extends Fixture implements DependentFixtureInterface
|
||||
$activity = new AsideActivity();
|
||||
$activity
|
||||
->setAgent($user)
|
||||
->setCreatedAt(new DateTimeImmutable('now'))
|
||||
->setCreatedAt(new \DateTimeImmutable('now'))
|
||||
->setCreatedBy($user)
|
||||
->setUpdatedAt(new DateTimeImmutable('now'))
|
||||
->setUpdatedAt(new \DateTimeImmutable('now'))
|
||||
->setUpdatedBy($user)
|
||||
->setType(
|
||||
$this->getReference('aside_activity_category_0')
|
||||
)
|
||||
->setDate((new DateTimeImmutable('today'))
|
||||
->sub(new DateInterval('P' . random_int(1, 100) . 'D')));
|
||||
->setDate((new \DateTimeImmutable('today'))
|
||||
->sub(new \DateInterval('P'.\random_int(1, 100).'D')));
|
||||
|
||||
$manager->persist($activity);
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ class LoadAsideActivityCategory extends \Doctrine\Bundle\FixturesBundle\Fixture
|
||||
$category = new AsideActivityCategory();
|
||||
$category->setTitle(['fr' => $label]);
|
||||
$manager->persist($category);
|
||||
$this->setReference('aside_activity_category_' . $key, $category);
|
||||
$this->setReference('aside_activity_category_'.$key, $category);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
@@ -26,7 +26,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte
|
||||
|
||||
$container->setParameter('chill_aside_activity.form.time_duration', $config['form']['time_duration']);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('services/form.yaml');
|
||||
$loader->load('services/menu.yaml');
|
||||
@@ -100,7 +100,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte
|
||||
|
||||
protected function prependRoute(ContainerBuilder $container)
|
||||
{
|
||||
//declare routes for task bundle
|
||||
// declare routes for task bundle
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'routing' => [
|
||||
'resources' => [
|
||||
|
@@ -14,8 +14,6 @@ namespace Chill\AsideActivityBundle\DependencyInjection;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
use function is_int;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
@@ -132,7 +130,7 @@ class Configuration implements ConfigurationInterface
|
||||
->info('The number of seconds of this duration. Must be an integer.')
|
||||
->cannotBeEmpty()
|
||||
->validate()
|
||||
->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer')
|
||||
->ifTrue(static fn ($data) => !\is_int($data))->thenInvalid('The value %s is not a valid integer')
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('label')
|
||||
|
@@ -15,19 +15,21 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(schema="chill_asideactivity")
|
||||
*/
|
||||
class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private \Chill\MainBundle\Entity\User $agent;
|
||||
@@ -39,6 +41,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private \Chill\MainBundle\Entity\User $createdBy;
|
||||
@@ -51,17 +54,20 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* @ORM\Column(type="time", nullable=true)
|
||||
*/
|
||||
private ?DateTimeInterface $duration = null;
|
||||
private ?\DateTimeInterface $duration = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?Location $location = null;
|
||||
@@ -73,6 +79,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="asideActivities")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?\Chill\AsideActivityBundle\Entity\AsideActivityCategory $type = null;
|
||||
@@ -92,7 +99,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->agent;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeInterface
|
||||
public function getCreatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
@@ -102,12 +109,12 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getDate(): ?DateTimeInterface
|
||||
public function getDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function getDuration(): ?DateTimeInterface
|
||||
public function getDuration(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
@@ -132,7 +139,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
@@ -149,7 +156,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeInterface $createdAt): self
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
@@ -163,14 +170,14 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDate(DateTimeInterface $date): self
|
||||
public function setDate(\DateTimeInterface $date): self
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDuration(?DateTimeInterface $duration): self
|
||||
public function setDuration(?\DateTimeInterface $duration): self
|
||||
{
|
||||
$this->duration = $duration;
|
||||
|
||||
@@ -198,7 +205,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(DateTimeInterface $updatedAt): self
|
||||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
|
@@ -19,19 +19,23 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(schema="chill_asideactivity")
|
||||
*/
|
||||
class AsideActivityCategory
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent")
|
||||
*
|
||||
* @var Collection<AsideActivityCategory>
|
||||
*/
|
||||
private Collection $children;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private int $id;
|
||||
@@ -50,6 +54,7 @@ class AsideActivityCategory
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?AsideActivityCategory $parent = null;
|
||||
|
@@ -45,6 +45,7 @@ class ByActivityTypeAggregator implements AggregatorInterface
|
||||
{
|
||||
// No form needed
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
|
@@ -14,7 +14,6 @@ namespace Chill\AsideActivityBundle\Export\Aggregator;
|
||||
use Chill\AsideActivityBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\LocationRepository;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@@ -22,25 +21,16 @@ class ByLocationAggregator implements AggregatorInterface
|
||||
{
|
||||
public function __construct(private readonly LocationRepository $locationRepository) {}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
@@ -55,42 +45,27 @@ class ByLocationAggregator implements AggregatorInterface
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['by_aside_activity_location_aggregator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.aggregator.Group by aside activity location';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$qb->addSelect('IDENTITY(aside.location) AS by_aside_activity_location_aggregator')
|
||||
->addGroupBy('by_aside_activity_location_aggregator');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ASIDE_ACTIVITY_TYPE;
|
||||
|
@@ -39,7 +39,7 @@ class ByUserJobAggregator implements AggregatorInterface
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin("aside.agent", "{$p}_user")
|
||||
->leftJoin('aside.agent', "{$p}_user")
|
||||
->leftJoin(
|
||||
UserJobHistory::class,
|
||||
"{$p}_history",
|
||||
@@ -49,10 +49,10 @@ class ByUserJobAggregator implements AggregatorInterface
|
||||
// job_at based on aside.date
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "aside.date"),
|
||||
$qb->expr()->lte("{$p}_history.startDate", 'aside.date'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "aside.date")
|
||||
$qb->expr()->gt("{$p}_history.endDate", 'aside.date')
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -93,7 +93,7 @@ class ByUserJobAggregator implements AggregatorInterface
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [self::PREFIX . '_select'];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@@ -39,7 +39,7 @@ class ByUserScopeAggregator implements AggregatorInterface
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin("aside.agent", "{$p}_user")
|
||||
->leftJoin('aside.agent', "{$p}_user")
|
||||
->leftJoin(
|
||||
UserScopeHistory::class,
|
||||
"{$p}_history",
|
||||
@@ -48,10 +48,10 @@ class ByUserScopeAggregator implements AggregatorInterface
|
||||
)
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "aside.date"),
|
||||
$qb->expr()->lte("{$p}_history.startDate", 'aside.date'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "aside.date")
|
||||
$qb->expr()->gt("{$p}_history.endDate", 'aside.date')
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -92,7 +92,7 @@ class ByUserScopeAggregator implements AggregatorInterface
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [self::PREFIX . '_select'];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterface
|
||||
@@ -50,7 +49,7 @@ class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterfac
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ('export_avg_aside_activity_duration' !== $key) {
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
throw new \LogicException("the key {$key} is not used by this export");
|
||||
}
|
||||
|
||||
return static fn ($value) => '_header' === $value ? 'Average duration aside activities' : $value;
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class CountAsideActivity implements ExportInterface, GroupedExportInterface
|
||||
@@ -26,6 +25,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface
|
||||
public function __construct(private readonly AsideActivityRepository $repository) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
@@ -49,7 +49,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ('export_result' !== $key) {
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
throw new \LogicException("the key {$key} is not used by this export");
|
||||
}
|
||||
|
||||
$labels = array_combine($values, $values);
|
||||
|
@@ -26,11 +26,8 @@ use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\LocationRepository;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class ListAsideActivity implements ListInterface, GroupedExportInterface
|
||||
@@ -74,28 +71,28 @@ final readonly class ListAsideActivity implements ListInterface, GroupedExportIn
|
||||
return match ($key) {
|
||||
'id', 'note' => static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aside_activity.' . $key;
|
||||
return 'export.aside_activity.'.$key;
|
||||
}
|
||||
|
||||
return $value ?? '';
|
||||
},
|
||||
'duration' => static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aside_activity.' . $key;
|
||||
return 'export.aside_activity.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($value instanceof DateTimeInterface) {
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return $value->format('H:i:s');
|
||||
}
|
||||
|
||||
return $value;
|
||||
},
|
||||
'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.' . $key),
|
||||
'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key),
|
||||
'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.'.$key),
|
||||
'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.'.$key),
|
||||
'aside_activity_type' => function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aside_activity.aside_activity_type';
|
||||
@@ -135,13 +132,13 @@ final readonly class ListAsideActivity implements ListInterface, GroupedExportIn
|
||||
}
|
||||
|
||||
if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) {
|
||||
/** @var Center $c */
|
||||
/* @var Center $c */
|
||||
return '';
|
||||
}
|
||||
|
||||
return $c->getName();
|
||||
},
|
||||
default => throw new LogicException('this key is not supported : ' . $key),
|
||||
default => throw new \LogicException('this key is not supported : '.$key),
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class SumAsideActivityDuration implements ExportInterface, GroupedExportInterface
|
||||
@@ -26,6 +25,7 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac
|
||||
public function __construct(private readonly AsideActivityRepository $repository) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
@@ -49,7 +49,7 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ('export_sum_aside_activity_duration' !== $key) {
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
throw new \LogicException("the key {$key} is not used by this export");
|
||||
}
|
||||
|
||||
return static fn ($value) => '_header' === $value ? 'Sum duration aside activities' : $value;
|
||||
|
@@ -66,6 +66,7 @@ class ByActivityTypeFilter implements FilterInterface
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
|
@@ -82,14 +82,14 @@ class ByDateFilter implements FilterInterface
|
||||
if (null === $date_from) {
|
||||
$form->get('date_from')->addError(new FormError(
|
||||
$this->translator->trans('This field '
|
||||
. 'should not be empty')
|
||||
.'should not be empty')
|
||||
));
|
||||
}
|
||||
|
||||
if (null === $date_to) {
|
||||
$form->get('date_to')->addError(new FormError(
|
||||
$this->translator->trans('This field '
|
||||
. 'should not be empty')
|
||||
.'should not be empty')
|
||||
));
|
||||
}
|
||||
|
||||
@@ -100,13 +100,14 @@ class ByDateFilter implements FilterInterface
|
||||
) {
|
||||
$form->get('date_to')->addError(new FormError(
|
||||
$this->translator->trans('export.filter.This date should be after '
|
||||
. 'the date given in "Implied in an aside activity after '
|
||||
. 'this date" field')
|
||||
.'the date given in "Implied in an aside activity after '
|
||||
.'this date" field')
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];
|
||||
|
@@ -16,9 +16,7 @@ use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickUserLocationType;
|
||||
use Chill\MainBundle\Repository\LocationRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -28,26 +26,17 @@ final readonly class ByLocationFilter implements FilterInterface
|
||||
private Security $security
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.Filter by aside activity location';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder
|
||||
->add('locations', PickUserLocationType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
@@ -63,9 +52,6 @@ final readonly class ByLocationFilter implements FilterInterface
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
$locations = $data['locations']->map(fn (Location $l): string => $l->getName());
|
||||
@@ -75,17 +61,11 @@ final readonly class ByLocationFilter implements FilterInterface
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$clause = $qb->expr()->in('aside.location', ':locations');
|
||||
@@ -94,9 +74,6 @@ final readonly class ByLocationFilter implements FilterInterface
|
||||
$qb->setParameter('locations', $data['locations']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ASIDE_ACTIVITY_TYPE;
|
||||
|
@@ -48,6 +48,7 @@ class ByUserFilter implements FilterInterface
|
||||
'label' => 'Creators',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
|
@@ -41,19 +41,19 @@ class ByUserJobFilter implements FilterInterface
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
"SELECT 1 FROM " . AsideActivity::class . " {$p}_act "
|
||||
. "JOIN {$p}_act.agent {$p}_user "
|
||||
. "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||
. "WHERE {$p}_act = aside "
|
||||
'SELECT 1 FROM '.AsideActivity::class." {$p}_act "
|
||||
."JOIN {$p}_act.agent {$p}_user "
|
||||
.'JOIN '.UserJobHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||
."WHERE {$p}_act = aside "
|
||||
// job_at based on aside.date
|
||||
. "AND {$p}_history.startDate <= aside.date "
|
||||
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) "
|
||||
. "AND {$p}_history.job IN ( :{$p}_jobs )"
|
||||
."AND {$p}_history.startDate <= aside.date "
|
||||
."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) "
|
||||
."AND {$p}_history.job IN ( :{$p}_jobs )"
|
||||
)
|
||||
)
|
||||
->setParameter(
|
||||
"{$p}_jobs",
|
||||
$data["jobs"],
|
||||
$data['jobs'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -43,19 +43,19 @@ class ByUserScopeFilter implements FilterInterface
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
"SELECT 1 FROM " . AsideActivity::class . " {$p}_act "
|
||||
. "JOIN {$p}_act.agent {$p}_user "
|
||||
. "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||
. "WHERE {$p}_act = aside "
|
||||
'SELECT 1 FROM '.AsideActivity::class." {$p}_act "
|
||||
."JOIN {$p}_act.agent {$p}_user "
|
||||
.'JOIN '.UserScopeHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||
."WHERE {$p}_act = aside "
|
||||
// scope_at based on aside.date
|
||||
. "AND {$p}_history.startDate <= aside.date "
|
||||
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) "
|
||||
. "AND {$p}_history.scope IN ( :{$p}_scopes )"
|
||||
."AND {$p}_history.startDate <= aside.date "
|
||||
."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) "
|
||||
."AND {$p}_history.scope IN ( :{$p}_scopes )"
|
||||
)
|
||||
)
|
||||
->setParameter(
|
||||
"{$p}_scopes",
|
||||
$data["scopes"],
|
||||
$data['scopes'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -13,16 +13,10 @@ namespace Chill\AsideActivityBundle\Form;
|
||||
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||
use Chill\AsideActivityBundle\Form\Type\PickAsideActivityCategoryType;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Form\Type\PickUserLocationType;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||
@@ -32,8 +26,6 @@ use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use function in_array;
|
||||
|
||||
final class AsideActivityFormType extends AbstractType
|
||||
{
|
||||
private readonly array $timeChoices;
|
||||
@@ -68,7 +60,7 @@ final class AsideActivityFormType extends AbstractType
|
||||
ChillDateType::class,
|
||||
[
|
||||
'label' => 'date',
|
||||
'data' => new DateTime(),
|
||||
'data' => new \DateTime(),
|
||||
'required' => true,
|
||||
]
|
||||
)
|
||||
@@ -98,16 +90,16 @@ final class AsideActivityFormType 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 DateTimeImmutable $data */
|
||||
$data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300');
|
||||
$timezoneUTC = new \DateTimeZone('GMT');
|
||||
/** @var \DateTimeImmutable $data */
|
||||
$data = $formEvent->getData() ?? \DateTime::createFromFormat('U', '300');
|
||||
$seconds = $data->getTimezone()->getOffset($data);
|
||||
$data->setTimeZone($timezoneUTC);
|
||||
$data->add(new DateInterval('PT' . $seconds . 'S'));
|
||||
$data->add(new \DateInterval('PT'.$seconds.'S'));
|
||||
|
||||
// test if the timestamp is in the choices.
|
||||
// If not, recreate the field with the new timestamp
|
||||
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
|
||||
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, [...$durationTimeOptions, 'choices' => $timeChoices, 'auto_initialize' => false]);
|
||||
|
@@ -23,9 +23,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(protected TranslatorInterface $translator, public AuthorizationCheckerInterface $authorizationChecker) {}
|
||||
|
||||
/**
|
||||
* @param $menuId
|
||||
*/
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
if ($this->authorizationChecker->isGranted('ROLE_USER')) {
|
||||
|
@@ -49,7 +49,7 @@ class AsideActivityCategoryRepository implements ObjectRepository
|
||||
*
|
||||
* @return AsideActivityCategory[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -14,7 +14,6 @@ namespace Chill\AsideActivityBundle\Templating\Entity;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
* @implements ChillEntityRenderInterface<AsideActivityCategory>
|
||||
|
@@ -14,13 +14,11 @@ namespace Chill\AsideActivityBundle\Tests\Controller;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use function array_pop;
|
||||
use function shuffle;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AsideActivityControllerTest extends WebTestCase
|
||||
@@ -49,13 +47,13 @@ final class AsideActivityControllerTest extends WebTestCase
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
shuffle($asideActivityIds);
|
||||
\shuffle($asideActivityIds);
|
||||
|
||||
yield [array_pop($asideActivityIds)['id']];
|
||||
yield [\array_pop($asideActivityIds)['id']];
|
||||
|
||||
yield [array_pop($asideActivityIds)['id']];
|
||||
yield [\array_pop($asideActivityIds)['id']];
|
||||
|
||||
yield [array_pop($asideActivityIds)['id']];
|
||||
yield [\array_pop($asideActivityIds)['id']];
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
@@ -12,12 +12,12 @@ declare(strict_types=1);
|
||||
namespace Chill\AsideActivityBundle\Tests\Export\Export;
|
||||
|
||||
use Chill\AsideActivityBundle\Export\Export\ListAsideActivity;
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ListAsideActivityTest extends KernelTestCase
|
||||
@@ -38,6 +38,6 @@ class ListAsideActivityTest extends KernelTestCase
|
||||
|
||||
$results = $qb->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY);
|
||||
|
||||
self::assertIsArray($results, "smoke test: test that the result is an array");
|
||||
self::assertIsArray($results, 'smoke test: test that the result is an array');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user