Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppEntity;
- use DoctrineORMMapping as ORM;
- /**
- * @ORMEntity(repositoryClass="AppRepositoryExceptionRepository")
- */
- class Exception
- {
- /**
- * @ORMId()
- * @ORMGeneratedValue()
- * @ORMColumn(type="integer")
- */
- private $id;
- /**
- * @ORMColumn(type="string", length=200, nullable=true)
- */
- private $nom;
- /**
- * @ORMColumn(type="date", nullable=true)
- */
- private $datedebut;
- /**
- * @ORMColumn(type="date", nullable=true)
- */
- private $datefin;
- /**
- * @ORMColumn(type="time", nullable=true)
- */
- private $tempsdebut;
- /**
- * @ORMColumn(type="time", nullable=true)
- */
- private $tempsfin;
- /**
- * @ORMManyToOne(targetEntity="AppEntityTypeParking", inversedBy="exceptions")
- * @ORMJoinColumn(nullable=false)
- */
- private $type;
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getNom(): ?string
- {
- return $this->nom;
- }
- public function setNom(?string $nom): self
- {
- $this->nom = $nom;
- return $this;
- }
- public function getDatedebut(): ?DateTimeInterface
- {
- return $this->datedebut;
- }
- public function setDatedebut(?DateTimeInterface $datedebut): self
- {
- $this->datedebut = $datedebut;
- return $this;
- }
- public function getDatefin(): ?DateTimeInterface
- {
- return $this->datefin;
- }
- public function setDatefin(?DateTimeInterface $datefin): self
- {
- $this->datefin = $datefin;
- return $this;
- }
- public function getTempsdebut(): ?DateTimeInterface
- {
- return $this->tempsdebut;
- }
- public function setTempsdebut(?DateTimeInterface $tempsdebut): self
- {
- $this->tempsdebut = $tempsdebut;
- return $this;
- }
- public function getTempsfin(): ?DateTimeInterface
- {
- return $this->tempsfin;
- }
- public function setTempsfin(?DateTimeInterface $tempsfin): self
- {
- $this->tempsfin = $tempsfin;
- return $this;
- }
- public function getType(): ?TypeParking
- {
- return $this->type;
- }
- public function setType(?TypeParking $type): self
- {
- $this->type = $type;
- return $this;
- }
- }
- <?php
- namespace AppEntity;
- /**
- * @ORMEntity(repositoryClass="AppRepositoryTypeParkingRepository")
- */
- class TypeParking
- {
- /**
- * @ORMId()
- * @ORMGeneratedValue()
- * @ORMColumn(type="integer")
- */
- private $id;
- /**
- * @ORMColumn(type="string", length=55)
- */
- private $libelle;
- /**
- * @ORMColumn(type="time", nullable=true)
- */
- private $tempsmax;
- /**
- * @ORMColumn(type="date", nullable=true)
- */
- private $jourdebut;
- /**
- * @ORMColumn(type="date", nullable=true)
- */
- private $jourfin;
- /**
- * @ORMOneToMany(targetEntity="AppEntityException", mappedBy="type", cascade={"persist"})
- */
- private $exceptions;
- public function __construct()
- {
- $this->exceptions = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getTempsmax(): ?DateTimeInterface
- {
- return $this->tempsmax;
- }
- public function setTempsmax(DateTimeInterface $tempsmax): self
- {
- $this->tempsmax = $tempsmax;
- return $this;
- }
- public function getJourdebut(): ?DateTimeInterface
- {
- return $this->jourdebut;
- }
- public function setJourdebut(DateTimeInterface $jourdebut): self
- {
- $this->jourdebut = $jourdebut;
- return $this;
- }
- public function getJourfin(): ?DateTimeInterface
- {
- return $this->jourfin;
- }
- public function setJourfin(DateTimeInterface $jourfin): self
- {
- $this->jourfin = $jourfin;
- return $this;
- }
- public function getLibelle(): ?string
- {
- return $this->libelle;
- }
- public function setLibelle(string $libelle): self
- {
- $this->libelle = $libelle;
- return $this;
- }
- /**
- * @return Collection|Exception[]
- */
- public function getExceptions(): Collection
- {
- return $this->exceptions;
- }
- public function removeException(Exception $exception): self
- {
- if ($this->exceptions->contains($exception)) {
- $this->exceptions->removeElement($exception);
- // set the owning side to null (unless already changed)
- if ($exception->getType() === $this) {
- $exception->setType(null);
- }
- }
- return $this;
- }
- public function addException(Exception $exception)
- {
- $this->exceptions->add($exception);
- }
- }
- <?php
- class TypeParkingType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('libelle')
- ->add('tempsmax')
- ->add('jourdebut')
- ->add('jourfin')
- ->add('exceptions', CollectionType::class, [
- 'label' => 'Exception',
- 'entry_type' => Exception1Type::class,
- 'allow_add' => true,
- 'allow_delete' => true,
- 'prototype' => true,
- 'required' => false,
- 'by_reference' => true,
- 'delete_empty' => true,
- 'attr' => [
- 'class' => 'collection',
- ],
- ])
- ;
- $builder->add('save', SubmitType::class, [
- 'label' => 'See my addresses',
- ]);
- }
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'data_class' => TypeParking::class,
- ]);
- }
- }
- class ExceptionType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('nom')
- ->add('datedebut')
- ->add('datefin')
- ->add('tempsdebut')
- ->add('tempsfin')
- ->add('type',EntityType::class, [
- 'class' => TypeParking::class,
- 'choice_label' => 'libelle',
- ])
- ;
- }
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'data_class' => Exception::class,
- ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement