Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6.  
  7. /**
  8. * @ORMEntity(repositoryClass="AppRepositoryExceptionRepository")
  9. */
  10. class Exception
  11. {
  12. /**
  13. * @ORMId()
  14. * @ORMGeneratedValue()
  15. * @ORMColumn(type="integer")
  16. */
  17. private $id;
  18.  
  19. /**
  20. * @ORMColumn(type="string", length=200, nullable=true)
  21. */
  22. private $nom;
  23.  
  24. /**
  25. * @ORMColumn(type="date", nullable=true)
  26. */
  27. private $datedebut;
  28.  
  29. /**
  30. * @ORMColumn(type="date", nullable=true)
  31. */
  32. private $datefin;
  33.  
  34. /**
  35. * @ORMColumn(type="time", nullable=true)
  36. */
  37. private $tempsdebut;
  38.  
  39. /**
  40. * @ORMColumn(type="time", nullable=true)
  41. */
  42. private $tempsfin;
  43.  
  44. /**
  45. * @ORMManyToOne(targetEntity="AppEntityTypeParking", inversedBy="exceptions")
  46. * @ORMJoinColumn(nullable=false)
  47. */
  48. private $type;
  49.  
  50. public function getId(): ?int
  51. {
  52. return $this->id;
  53. }
  54.  
  55. public function getNom(): ?string
  56. {
  57. return $this->nom;
  58. }
  59.  
  60. public function setNom(?string $nom): self
  61. {
  62. $this->nom = $nom;
  63.  
  64. return $this;
  65. }
  66.  
  67. public function getDatedebut(): ?DateTimeInterface
  68. {
  69. return $this->datedebut;
  70. }
  71.  
  72. public function setDatedebut(?DateTimeInterface $datedebut): self
  73. {
  74. $this->datedebut = $datedebut;
  75.  
  76. return $this;
  77. }
  78.  
  79. public function getDatefin(): ?DateTimeInterface
  80. {
  81. return $this->datefin;
  82. }
  83.  
  84. public function setDatefin(?DateTimeInterface $datefin): self
  85. {
  86. $this->datefin = $datefin;
  87.  
  88. return $this;
  89. }
  90.  
  91. public function getTempsdebut(): ?DateTimeInterface
  92. {
  93. return $this->tempsdebut;
  94. }
  95.  
  96. public function setTempsdebut(?DateTimeInterface $tempsdebut): self
  97. {
  98. $this->tempsdebut = $tempsdebut;
  99.  
  100. return $this;
  101. }
  102.  
  103. public function getTempsfin(): ?DateTimeInterface
  104. {
  105. return $this->tempsfin;
  106. }
  107.  
  108. public function setTempsfin(?DateTimeInterface $tempsfin): self
  109. {
  110. $this->tempsfin = $tempsfin;
  111.  
  112. return $this;
  113. }
  114.  
  115. public function getType(): ?TypeParking
  116. {
  117. return $this->type;
  118. }
  119.  
  120. public function setType(?TypeParking $type): self
  121. {
  122. $this->type = $type;
  123.  
  124. return $this;
  125. }
  126. }
  127.  
  128. <?php
  129.  
  130. namespace AppEntity;
  131.  
  132. /**
  133. * @ORMEntity(repositoryClass="AppRepositoryTypeParkingRepository")
  134. */
  135. class TypeParking
  136. {
  137. /**
  138. * @ORMId()
  139. * @ORMGeneratedValue()
  140. * @ORMColumn(type="integer")
  141. */
  142. private $id;
  143.  
  144. /**
  145. * @ORMColumn(type="string", length=55)
  146. */
  147. private $libelle;
  148.  
  149. /**
  150. * @ORMColumn(type="time", nullable=true)
  151. */
  152. private $tempsmax;
  153.  
  154. /**
  155. * @ORMColumn(type="date", nullable=true)
  156. */
  157. private $jourdebut;
  158.  
  159. /**
  160. * @ORMColumn(type="date", nullable=true)
  161. */
  162. private $jourfin;
  163.  
  164.  
  165.  
  166. /**
  167. * @ORMOneToMany(targetEntity="AppEntityException", mappedBy="type", cascade={"persist"})
  168. */
  169. private $exceptions;
  170.  
  171. public function __construct()
  172. {
  173. $this->exceptions = new ArrayCollection();
  174. }
  175. public function getId(): ?int
  176. {
  177. return $this->id;
  178. }
  179.  
  180. public function getTempsmax(): ?DateTimeInterface
  181. {
  182. return $this->tempsmax;
  183. }
  184.  
  185. public function setTempsmax(DateTimeInterface $tempsmax): self
  186. {
  187. $this->tempsmax = $tempsmax;
  188.  
  189. return $this;
  190. }
  191.  
  192. public function getJourdebut(): ?DateTimeInterface
  193. {
  194. return $this->jourdebut;
  195. }
  196.  
  197. public function setJourdebut(DateTimeInterface $jourdebut): self
  198. {
  199. $this->jourdebut = $jourdebut;
  200.  
  201. return $this;
  202. }
  203.  
  204. public function getJourfin(): ?DateTimeInterface
  205. {
  206. return $this->jourfin;
  207. }
  208.  
  209. public function setJourfin(DateTimeInterface $jourfin): self
  210. {
  211. $this->jourfin = $jourfin;
  212.  
  213. return $this;
  214. }
  215.  
  216.  
  217.  
  218. public function getLibelle(): ?string
  219. {
  220. return $this->libelle;
  221. }
  222.  
  223. public function setLibelle(string $libelle): self
  224. {
  225. $this->libelle = $libelle;
  226.  
  227. return $this;
  228. }
  229.  
  230. /**
  231. * @return Collection|Exception[]
  232. */
  233. public function getExceptions(): Collection
  234. {
  235. return $this->exceptions;
  236. }
  237.  
  238. public function removeException(Exception $exception): self
  239. {
  240. if ($this->exceptions->contains($exception)) {
  241. $this->exceptions->removeElement($exception);
  242. // set the owning side to null (unless already changed)
  243. if ($exception->getType() === $this) {
  244. $exception->setType(null);
  245. }
  246. }
  247.  
  248. return $this;
  249. }
  250. public function addException(Exception $exception)
  251. {
  252. $this->exceptions->add($exception);
  253. }
  254.  
  255. }
  256.  
  257. <?php
  258.  
  259.  
  260. class TypeParkingType extends AbstractType
  261. {
  262. public function buildForm(FormBuilderInterface $builder, array $options)
  263. {
  264. $builder
  265. ->add('libelle')
  266. ->add('tempsmax')
  267. ->add('jourdebut')
  268. ->add('jourfin')
  269.  
  270.  
  271.  
  272.  
  273.  
  274. ->add('exceptions', CollectionType::class, [
  275. 'label' => 'Exception',
  276. 'entry_type' => Exception1Type::class,
  277. 'allow_add' => true,
  278. 'allow_delete' => true,
  279. 'prototype' => true,
  280. 'required' => false,
  281. 'by_reference' => true,
  282. 'delete_empty' => true,
  283. 'attr' => [
  284. 'class' => 'collection',
  285. ],
  286. ])
  287.  
  288.  
  289. ;
  290. $builder->add('save', SubmitType::class, [
  291. 'label' => 'See my addresses',
  292. ]);
  293. }
  294.  
  295. public function configureOptions(OptionsResolver $resolver)
  296. {
  297. $resolver->setDefaults([
  298. 'data_class' => TypeParking::class,
  299. ]);
  300. }
  301. }
  302.  
  303. class ExceptionType extends AbstractType
  304. {
  305. public function buildForm(FormBuilderInterface $builder, array $options)
  306. {
  307. $builder
  308.  
  309. ->add('nom')
  310. ->add('datedebut')
  311. ->add('datefin')
  312. ->add('tempsdebut')
  313. ->add('tempsfin')
  314. ->add('type',EntityType::class, [
  315. 'class' => TypeParking::class,
  316. 'choice_label' => 'libelle',
  317. ])
  318.  
  319. ;
  320. }
  321.  
  322. public function configureOptions(OptionsResolver $resolver)
  323. {
  324. $resolver->setDefaults([
  325. 'data_class' => Exception::class,
  326. ]);
  327. }
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement