This commit is contained in:
Julien Fastré 2022-10-05 15:30:55 +02:00
parent d95472ca9d
commit 642b1e43c8
22 changed files with 79 additions and 59 deletions

View File

@ -90,7 +90,6 @@ final class ActivityController extends AbstractController
SerializerInterface $serializer,
UserRepositoryInterface $userRepository,
CenterResolverManagerInterface $centerResolver
) {
$this->activityACLAwareRepository = $activityACLAwareRepository;
$this->activityTypeRepository = $activityTypeRepository;
@ -106,7 +105,6 @@ final class ActivityController extends AbstractController
$this->serializer = $serializer;
$this->userRepository = $userRepository;
$this->centerResolver = $centerResolver;
}
/**

View File

@ -409,16 +409,16 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
return $this->status;
}
public function getUrgent(): ?bool
{
return $this->urgent;
}
public function getThirdParties(): Collection
{
return $this->getProfessionals();
}
public function getUrgent(): ?bool
{
return $this->urgent;
}
/**
* @return Collection|User[]
* @Serializer\Groups({"calendar:read", "read"})
@ -599,13 +599,6 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setUrgent(bool $urgent): self
{
$this->urgent = $urgent;
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;
@ -623,4 +616,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setUrgent(bool $urgent): self
{
$this->urgent = $urgent;
return $this;
}
}

View File

@ -54,8 +54,8 @@ class MonthYearAggregator implements AggregatorInterface
return 'by month and year';
}
$month = (int)substr($value, 0, 2);
$year = (int)substr($value, 3, 4);
$month = (int) substr($value, 0, 2);
$year = (int) substr($value, 3, 4);
return strftime('%B %G', mktime(0, 0, 0, $month, 1, $year));
};

View File

@ -21,7 +21,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class UrgencyAggregator implements AggregatorInterface
{
private TranslatorInterface $translator;
public function __construct(
@ -88,4 +87,3 @@ class UrgencyAggregator implements AggregatorInterface
return 'Group calendars by urgency';
}
}

View File

@ -23,7 +23,6 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Exception\LogicException;
class CountCalendars implements ExportInterface, GroupedExportInterface
{
private CalendarRepository $calendarRepository;

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\Export\Filter;
use Chill\MainBundle\Export\FilterInterface;
use Chill\CalendarBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@ -23,7 +23,7 @@ class CalendarRangeFilter implements FilterInterface
{
private const CHOICES = [
'Not made within a calendar range' => true,
'Made within a calendar range' => false
'Made within a calendar range' => false,
];
private const DEFAULT_CHOICE = false;
@ -52,7 +52,6 @@ class CalendarRangeFilter implements FilterInterface
$clause = $qb->expr()->isNull('cal.calendarRange');
}
if ($where instanceof Andx) {
$where->add($clause);
} else {
@ -101,4 +100,3 @@ class CalendarRangeFilter implements FilterInterface
return 'Filter by calendar range';
}
}

View File

@ -143,7 +143,7 @@ class MapCalendarToUser
public function writeMetadata(User $user): User
{
if (null === $user->getEmail() OR '' === $user->getEmail()) {
if (null === $user->getEmail() || '' === $user->getEmail()) {
return $user;
}

View File

@ -40,11 +40,6 @@ class CalendarRepository implements ObjectRepository
return $this->repository->count(['accompanyingPeriod' => $period]);
}
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
{
return $this->repository->createQueryBuilder($alias, $indexBy);
}
public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int
{
return $this->buildQueryByUser($user, $from, $to)
@ -53,6 +48,11 @@ class CalendarRepository implements ObjectRepository
->getSingleScalarResult();
}
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
{
return $this->repository->createQueryBuilder($alias, $indexBy);
}
public function find($id): ?Calendar
{
return $this->repository->find($id);

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\AgentAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class AgentAggregatorTest extends AbstractAggregatorTest
{
private AgentAggregator $aggregator;
@ -51,8 +55,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
->join('cal.mainUser', 'caluser')
,
->join('cal.mainUser', 'caluser'),
];
}
}

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class CancelReasonAggregatorTest extends AbstractAggregatorTest
{
private CancelReasonAggregator $aggregator;
@ -51,8 +55,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
->join('cal.cancelReason', 'calcancel')
,
->join('cal.cancelReason', 'calcancel'),
];
}
}

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\JobAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class JobAggregatorTest extends AbstractAggregatorTest
{
private JobAggregator $aggregator;
@ -51,8 +55,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
->join('cal.user', 'caluser')
,
->join('cal.user', 'caluser'),
];
}
}

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\LocationAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class LocationAggregatorTest extends AbstractAggregatorTest
{
private LocationAggregator $aggregator;
@ -51,8 +55,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
->join('cal.location', 'calloc')
,
->join('cal.location', 'calloc'),
];
}
}

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class LocationTypeAggregatorTest extends AbstractAggregatorTest
{
private LocationTypeAggregator $aggregator;
@ -51,8 +55,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
->join('cal.location', 'calloc')
,
->join('cal.location', 'calloc'),
];
}
}

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class MonthYearAggregatorTest extends AbstractAggregatorTest
{
private MonthYearAggregator $aggregator;
@ -50,8 +54,7 @@ final class MonthYearAggregatorTest extends AbstractAggregatorTest
return [
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
,
->from(Calendar::class, 'cal'),
];
}
}

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\ScopeAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class ScopeAggregatorTest extends AbstractAggregatorTest
{
private ScopeAggregator $aggregator;
@ -51,8 +55,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(cal.id)')
->from(Calendar::class, 'cal')
->join('cal.user', 'caluser')
,
->join('cal.user', 'caluser'),
];
}
}

View File

@ -57,7 +57,7 @@ final class AgentFilterTest extends AbstractFilterTest
foreach ($array as $a) {
$data[] = [
'accepted_agents' => $a
'accepted_agents' => $a,
];
}

View File

@ -14,6 +14,7 @@ namespace Chill\CalendarBundle\Tests\Export\Filter;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Export\Filter\BetweenDatesFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
/**
@ -46,9 +47,9 @@ final class BetweenDatesFilterTest extends AbstractFilterTest
{
return [
[
'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'),
]
'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'),
],
];
}

View File

@ -57,7 +57,7 @@ final class JobFilterTest extends AbstractFilterTest
foreach ($array as $a) {
$data[] = [
'job' => $a
'job' => $a,
];
}

View File

@ -57,7 +57,7 @@ final class ScopeFilterTest extends AbstractFilterTest
foreach ($array as $a) {
$data[] = [
'scope' => $a
'scope' => $a,
];
}

View File

@ -1,5 +1,12 @@
<?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\Migrations\Calendar;
@ -12,6 +19,12 @@ use Doctrine\Migrations\AbstractMigration;
*/
final class Version20220921101643 extends AbstractMigration
{
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_calendar.calendar DROP urgent');
}
public function getDescription(): string
{
return 'Add urgent property to calendar entity';
@ -21,13 +34,5 @@ final class Version20220921101643 extends AbstractMigration
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_calendar.calendar ADD urgent BOOLEAN DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_calendar.calendar DROP urgent');
}
}