mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
cs-fixes
This commit is contained in:
parent
c4e0b68ebe
commit
051ed19f97
@ -60,7 +60,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
|
|
||||||
$form = $this->createDeleteForm();
|
$form = $this->createDeleteForm();
|
||||||
|
|
||||||
if (null != $element->getPerson()) {
|
if (null !== $element->getPerson()) {
|
||||||
$entity = $element->getPerson();
|
$entity = $element->getPerson();
|
||||||
$indexPage = 'chill_budget_elements_index';
|
$indexPage = 'chill_budget_elements_index';
|
||||||
} else {
|
} else {
|
||||||
@ -107,7 +107,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted(BudgetElementVoter::UPDATE, $element);
|
$this->denyAccessUnlessGranted(BudgetElementVoter::UPDATE, $element);
|
||||||
|
|
||||||
if (null != $element->getPerson()) {
|
if (null !== $element->getPerson()) {
|
||||||
$entity = $element->getPerson();
|
$entity = $element->getPerson();
|
||||||
$entityStr = 'person';
|
$entityStr = 'person';
|
||||||
$indexPage = 'chill_budget_elements_index';
|
$indexPage = 'chill_budget_elements_index';
|
||||||
@ -117,7 +117,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
$indexPage = 'chill_budget_elements_household_index';
|
$indexPage = 'chill_budget_elements_household_index';
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = null != $element->getPerson() ? : $element->getHousehold();
|
$entity = null !== $element->getPerson() ?: $element->getHousehold();
|
||||||
|
|
||||||
$form = $this->createForm($this->getType(), $element);
|
$form = $this->createForm($this->getType(), $element);
|
||||||
$form->add('submit', SubmitType::class);
|
$form->add('submit', SubmitType::class);
|
||||||
@ -145,6 +145,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param mixed $template
|
* @param mixed $template
|
||||||
* @param mixed $flashMessageOnSuccess
|
* @param mixed $flashMessageOnSuccess
|
||||||
|
* @param mixed $entity
|
||||||
*/
|
*/
|
||||||
protected function _new($entity, Request $request, $template, $flashMessageOnSuccess)
|
protected function _new($entity, Request $request, $template, $flashMessageOnSuccess)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ class ResourceController extends AbstractElementController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new budget element for a person
|
* Create a new budget element for a person.
|
||||||
*
|
*
|
||||||
* @Route(
|
* @Route(
|
||||||
* "{_locale}/budget/resource/by-person/{id}/new",
|
* "{_locale}/budget/resource/by-person/{id}/new",
|
||||||
@ -72,7 +72,7 @@ class ResourceController extends AbstractElementController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new budget element for a household
|
* Create new budget element for a household.
|
||||||
*
|
*
|
||||||
* @Route(
|
* @Route(
|
||||||
* "{_locale}/budget/resource/by-household/{id}/new",
|
* "{_locale}/budget/resource/by-household/{id}/new",
|
||||||
|
@ -44,7 +44,6 @@ abstract class AbstractElement
|
|||||||
private ?string $comment;
|
private ?string $comment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
|
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
|
||||||
* @Assert\GreaterThan(
|
* @Assert\GreaterThan(
|
||||||
* propertyPath="startDate",
|
* propertyPath="startDate",
|
||||||
@ -53,13 +52,6 @@ abstract class AbstractElement
|
|||||||
*/
|
*/
|
||||||
private ?DateTimeImmutable $endDate;
|
private ?DateTimeImmutable $endDate;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(
|
|
||||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
private ?Person $person = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||||
@ -68,19 +60,24 @@ abstract class AbstractElement
|
|||||||
private ?Household $household = null;
|
private ?Household $household = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @ORM\ManyToOne(
|
||||||
|
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
private ?Person $person = null;
|
||||||
|
|
||||||
|
/**
|
||||||
* @ORM\Column(name="startDate", type="datetime_immutable")
|
* @ORM\Column(name="startDate", type="datetime_immutable")
|
||||||
* @Assert\Date
|
* @Assert\Date
|
||||||
*/
|
*/
|
||||||
private DateTimeImmutable $startDate;
|
private DateTimeImmutable $startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ORM\Column(name="type", type="string", length=255)
|
* @ORM\Column(name="type", type="string", length=255)
|
||||||
*/
|
*/
|
||||||
private string $type;
|
private string $type;
|
||||||
|
|
||||||
/**Getters and Setters */
|
/*Getters and Setters */
|
||||||
|
|
||||||
public function getAmount(): float
|
public function getAmount(): float
|
||||||
{
|
{
|
||||||
@ -97,16 +94,16 @@ abstract class AbstractElement
|
|||||||
return $this->endDate;
|
return $this->endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPerson(): ?Person
|
|
||||||
{
|
|
||||||
return $this->person;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHousehold(): ?Household
|
public function getHousehold(): ?Household
|
||||||
{
|
{
|
||||||
return $this->household;
|
return $this->household;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPerson(): ?Person
|
||||||
|
{
|
||||||
|
return $this->person;
|
||||||
|
}
|
||||||
|
|
||||||
public function getStartDate(): DateTimeImmutable
|
public function getStartDate(): DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->startDate;
|
return $this->startDate;
|
||||||
@ -153,16 +150,16 @@ abstract class AbstractElement
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPerson(Person $person): self
|
public function setHousehold(Household $household): self
|
||||||
{
|
{
|
||||||
$this->person = $person;
|
$this->household = $household;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHousehold(Household $household): self
|
public function setPerson(Person $person): self
|
||||||
{
|
{
|
||||||
$this->household = $household;
|
$this->person = $person;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
|||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Application\Migrations;
|
namespace Application\Migrations;
|
||||||
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
@ -20,6 +19,13 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
*/
|
*/
|
||||||
final class Version20180522080432 extends AbstractMigration
|
final class Version20180522080432 extends AbstractMigration
|
||||||
{
|
{
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('CREATE SCHEMA chill_budget CASCADE');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Creation of necessary tables for budget bundle';
|
return 'Creation of necessary tables for budget bundle';
|
||||||
@ -44,12 +50,4 @@ final class Version20180522080432 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E97217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E97217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE chill_budget.charge ADD CONSTRAINT FK_5C99D2C3217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE chill_budget.charge ADD CONSTRAINT FK_5C99D2C3217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
|
||||||
|
|
||||||
$this->addSql('CREATE SCHEMA chill_budget CASCADE');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\Budget;
|
namespace Chill\Migrations\Budget;
|
||||||
@ -12,6 +19,14 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
*/
|
*/
|
||||||
final class Version20220223123742 extends AbstractMigration
|
final class Version20220223123742 extends AbstractMigration
|
||||||
{
|
{
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('DROP SEQUENCE chill_budget.charge_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE chill_budget.resource_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP TABLE chill_budget.charge');
|
||||||
|
$this->addSql('DROP TABLE chill_budget.resource');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Creation of necessary tables for budget bundle';
|
return 'Creation of necessary tables for budget bundle';
|
||||||
@ -33,12 +48,4 @@ final class Version20220223123742 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE chill_budget.charge ADD CONSTRAINT FK_5C99D2C3217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE chill_budget.charge ADD CONSTRAINT FK_5C99D2C3217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E97217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E97217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('DROP SEQUENCE chill_budget.charge_id_seq CASCADE');
|
|
||||||
$this->addSql('DROP SEQUENCE chill_budget.resource_id_seq CASCADE');
|
|
||||||
$this->addSql('DROP TABLE chill_budget.charge');
|
|
||||||
$this->addSql('DROP TABLE chill_budget.resource');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\Budget;
|
namespace Chill\Migrations\Budget;
|
||||||
@ -12,6 +19,14 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
*/
|
*/
|
||||||
final class Version20220224090319 extends AbstractMigration
|
final class Version20220224090319 extends AbstractMigration
|
||||||
{
|
{
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_budget.charge DROP CONSTRAINT FK_5C99D2C3E79FF843');
|
||||||
|
$this->addSql('ALTER TABLE chill_budget.charge DROP household_id');
|
||||||
|
$this->addSql('ALTER TABLE chill_budget.resource DROP CONSTRAINT FK_5E0A5E97E79FF843');
|
||||||
|
$this->addSql('ALTER TABLE chill_budget.resource DROP household_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Add household to budget AbstractElement';
|
return 'Add household to budget AbstractElement';
|
||||||
@ -26,12 +41,4 @@ final class Version20220224090319 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E97E79FF843 FOREIGN KEY (household_id) REFERENCES chill_person_household (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E97E79FF843 FOREIGN KEY (household_id) REFERENCES chill_person_household (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('CREATE INDEX IDX_5E0A5E97E79FF843 ON chill_budget.resource (household_id)');
|
$this->addSql('CREATE INDEX IDX_5E0A5E97E79FF843 ON chill_budget.resource (household_id)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('ALTER TABLE chill_budget.charge DROP CONSTRAINT FK_5C99D2C3E79FF843');
|
|
||||||
$this->addSql('ALTER TABLE chill_budget.charge DROP household_id');
|
|
||||||
$this->addSql('ALTER TABLE chill_budget.resource DROP CONSTRAINT FK_5E0A5E97E79FF843');
|
|
||||||
$this->addSql('ALTER TABLE chill_budget.resource DROP household_id');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class ChargeRepository extends EntityRepository
|
|||||||
|
|
||||||
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||||
|
|
||||||
$qb->where("c.$entityStr = :$entityStr")
|
$qb->where("c.{$entityStr} = :{$entityStr}")
|
||||||
->andWhere('c.startDate < :date')
|
->andWhere('c.startDate < :date')
|
||||||
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\BudgetBundle\Repository;
|
namespace Chill\BudgetBundle\Repository;
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
@ -24,7 +23,6 @@ use Doctrine\ORM\EntityRepository;
|
|||||||
*/
|
*/
|
||||||
class ResourceRepository extends EntityRepository
|
class ResourceRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
// public function findByEntity($entity)
|
// public function findByEntity($entity)
|
||||||
// {
|
// {
|
||||||
|
|
||||||
@ -36,7 +34,7 @@ class ResourceRepository extends EntityRepository
|
|||||||
|
|
||||||
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||||
|
|
||||||
$qb->where("c.$entityStr = :$entityStr")
|
$qb->where("c.{$entityStr} = :{$entityStr}")
|
||||||
->andWhere('c.startDate < :date')
|
->andWhere('c.startDate < :date')
|
||||||
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
|
||||||
@ -51,5 +49,4 @@ class ResourceRepository extends EntityRepository
|
|||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\BudgetBundle\Security\Authorization;
|
namespace Chill\BudgetBundle\Security\Authorization;
|
||||||
|
|
||||||
use Chill\BudgetBundle\Entity\AbstractElement;
|
use Chill\BudgetBundle\Entity\AbstractElement;
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
|
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
|
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
|
||||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||||
@ -51,7 +49,6 @@ class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierar
|
|||||||
->addCheckFor(Person::class, [self::CREATE, self::SEE])
|
->addCheckFor(Person::class, [self::CREATE, self::SEE])
|
||||||
->addCheckFor(Household::class, [self::CREATE, self::SEE])
|
->addCheckFor(Household::class, [self::CREATE, self::SEE])
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoles(): array
|
public function getRoles(): array
|
||||||
@ -77,8 +74,6 @@ class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierar
|
|||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->voter->voteOnAttribute($attribute, $subject, $token);
|
return $this->voter->voteOnAttribute($attribute, $subject, $token);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user