Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.35 KB | None | 0 0
  1. <?php
  2.  
  3. namespace ApwBlackbullBundleForm;
  4.  
  5. use ApwBlackbullBundleEntityProductsDescription;
  6. use SymfonyComponentFormAbstractType;
  7. use SymfonyComponentFormFormBuilderInterface;
  8. use SymfonyComponentOptionsResolverOptionsResolverInterface;
  9.  
  10. class ProductsType extends AbstractType
  11. {
  12. /**
  13. * @param FormBuilderInterface $builder
  14. * @param array $options
  15. */
  16. public function buildForm(FormBuilderInterface $builder, array $options)
  17. {
  18. $builder
  19. ->add('productsDescription', 'collection',
  20. array(
  21. 'type' => new ProductsDescriptionType(),
  22. 'options' => array('data_class' => 'ApwBlackbullBundleEntityProductsDescription'),
  23. 'label' => 'Nome prodotto:'
  24. ))
  25. ->add('productsQuantity')
  26. ->add('productsModel')
  27. ->add('productsImage')
  28. ->add('productsPrice')
  29. ->add('productsDateAvailable', 'date', array(
  30. 'input' => 'datetime',
  31. 'widget' => 'single_text',))
  32. ->add('productsWeight')
  33. ->add('productsStatus')
  34. ->add('categories', 'entity', array(
  35. 'class' => 'ApwBlackbullBundle:CategoriesDescription',
  36. 'property' => 'categoriesName',
  37. 'empty_value' => 'Scegliere una categoria',
  38. 'required' => false,
  39. 'label' => 'Crea in:'))
  40. ->add('productsDescription', 'collection', array(
  41. 'type' => new ProductsDescriptionType(),
  42. 'options' => array('data_class' => 'ApwBlackbullBundleEntityProductsDescription'),
  43. 'label' => 'Descrizione prodotto:'))
  44. ->add('salva','submit')
  45. ->add('azzera','reset')
  46. ;
  47. }
  48.  
  49. /**
  50. * @param OptionsResolverInterface $resolver
  51. */
  52. public function setDefaultOptions(OptionsResolverInterface $resolver)
  53. {
  54. $resolver->setDefaults(array(
  55. 'data_class' => 'ApwBlackbullBundleEntityProducts'
  56. ));
  57. }
  58.  
  59. /**
  60. * @return string
  61. */
  62. public function getName()
  63. {
  64. return 'apw_blackbullbundle_products';
  65. }
  66. }
  67.  
  68. <?php
  69.  
  70. namespace ApwBlackbullBundleForm;
  71.  
  72. use DoctrineORMEntityRepository;
  73. use SymfonyComponentFormAbstractType;
  74. use SymfonyComponentFormFormBuilderInterface;
  75. use SymfonyComponentOptionsResolverOptionsResolverInterface;
  76.  
  77. class CategoriesType extends AbstractType
  78. {
  79. /**
  80. * @param FormBuilderInterface $builder
  81. * @param array $options
  82. */
  83. public function buildForm(FormBuilderInterface $builder, array $options)
  84. {
  85. $builder
  86. ->add('categoryDescription', 'collection',
  87. array(
  88. 'type' => new CategoriesDescriptionType(),
  89. 'allow_add' => true,
  90. 'options' => array('data_class' => 'ApwBlackbullBundleEntityCategoriesDescription'),
  91. 'by_reference' => false,
  92. ))
  93. //->add('categoriesImage', null, array('label'=>'Foto:'))
  94. ->add('categoriesStatus', null, array('label'=>'Stato:'))
  95. ->add('parentId', 'entity', array(
  96. 'class' => 'ApwBlackbullBundle:CategoriesDescription',
  97. 'property' => 'categoriesName',
  98. 'empty_value' => 'Scegliere una categoria',
  99. 'required' => false,
  100. 'label' => 'Crea in:'))
  101. ->add('salva','submit')
  102. ->add('azzera','reset')
  103. ;
  104. }
  105.  
  106. /**
  107. * @param OptionsResolverInterface $resolver
  108. */
  109. public function setDefaultOptions(OptionsResolverInterface $resolver)
  110. {
  111. $resolver->setDefaults(array(
  112. 'data_class' => 'ApwBlackbullBundleEntityCategories',
  113. ));
  114. }
  115.  
  116. /**
  117. * @return string
  118. */
  119. public function getName()
  120. {
  121. return 'categories';
  122. }
  123. }
  124.  
  125. <?php
  126.  
  127. namespace ApwBlackbullBundleEntity;
  128.  
  129. use DoctrineCommonCollectionsArrayCollection;
  130. use DoctrineORMMapping as ORM;
  131.  
  132. /**
  133. * Products
  134. *
  135. * @ORMTable()
  136. * @ORMEntity(repositoryClass="ApwBlackbullBundleEntityProductsRepository")
  137. * @ORMHasLifecycleCallbacks()
  138. */
  139.  
  140. class Products
  141. {
  142. /**
  143. * @var integer
  144. *
  145. * @ORMColumn(name="id", type="integer")
  146. * @ORMId
  147. * @ORMGeneratedValue(strategy="AUTO")
  148. */
  149. private $id;
  150.  
  151. /**
  152. * @var integer
  153. *
  154. * @ORMColumn(name="products_quantity", type="integer", nullable = true)
  155. */
  156. private $productsQuantity;
  157.  
  158. /**
  159. * @var string
  160. *
  161. * @ORMColumn(name="products_model", type="string", length=12, nullable = true)
  162. */
  163. private $productsModel;
  164.  
  165. /**
  166. * @var string
  167. *
  168. * @ORMColumn(name="products_image", type="string", length=64, nullable = true)
  169. */
  170. private $productsImage;
  171.  
  172. /**
  173. * @var string
  174. *
  175. * @ORMColumn(name="products_price", type="decimal", nullable = true)
  176. */
  177. private $productsPrice;
  178.  
  179. /**
  180. * @var DateTime
  181. *
  182. * @ORMColumn(name="products_date_added", type="datetime", nullable = true)
  183. */
  184. private $productsDateAdded;
  185.  
  186. /**
  187. * @var DateTime
  188. *
  189. * @ORMColumn(name="products_last_modified", type="datetime", nullable = true)
  190. */
  191. private $productsLastModified;
  192.  
  193. /**
  194. * @var DateTime
  195. *
  196. * @ORMColumn(name="products_date_available", type="datetime", nullable = true)
  197. */
  198. private $productsDateAvailable;
  199.  
  200. /**
  201. * @var string
  202. *
  203. * @ORMColumn(name="products_weight", type="decimal", nullable = true)
  204. */
  205. private $productsWeight;
  206.  
  207. /**
  208. * @var boolean
  209. *
  210. * @ORMColumn(name="products_status", type="boolean", nullable = true)
  211. */
  212. private $productsStatus;
  213.  
  214. /**
  215. * @var integer
  216. *
  217. * @ORMColumn(name="products_ordered", type="integer", nullable = true)
  218. */
  219. private $productsOrdered;
  220.  
  221. /**
  222. * @ORMOneToMany(targetEntity="ProductsDescription", mappedBy="product")
  223. */
  224. private $productsDescription;
  225.  
  226. /**
  227. * @ORMManyToMany(targetEntity="Categories", inversedBy="products")
  228. * @ORMJoinTable(name="productstocategories")
  229. */
  230. private $categories;
  231.  
  232. /**
  233. * @ORMOneToOne(targetEntity="Manufacturers", inversedBy="products")
  234. * @ORMJoinColumn(name="manufacturers_id", referencedColumnName="id")
  235. **/
  236. private $manufacturers;
  237.  
  238. /**
  239. * @ORMOneToMany(targetEntity="ProductsImages", mappedBy="products")
  240. */
  241. private $productsImages;
  242.  
  243.  
  244. /**
  245. * Get id
  246. *
  247. * @return integer
  248. */
  249. public function getId()
  250. {
  251. return $this->id;
  252. }
  253.  
  254. /**
  255. * Set productsQuantity
  256. *
  257. * @param integer $productsQuantity
  258. * @return Products
  259. */
  260. public function setProductsQuantity($productsQuantity)
  261. {
  262. $this->productsQuantity = $productsQuantity;
  263.  
  264. return $this;
  265. }
  266.  
  267. /**
  268. * Get productsQuantity
  269. *
  270. * @return integer
  271. */
  272. public function getProductsQuantity()
  273. {
  274. return $this->productsQuantity;
  275. }
  276.  
  277. /**
  278. * Set productsModel
  279. *
  280. * @param string $productsModel
  281. * @return Products
  282. */
  283. public function setProductsModel($productsModel)
  284. {
  285. $this->productsModel = $productsModel;
  286.  
  287. return $this;
  288. }
  289.  
  290. /**
  291. * Get productsModel
  292. *
  293. * @return string
  294. */
  295. public function getProductsModel()
  296. {
  297. return $this->productsModel;
  298. }
  299.  
  300. /**
  301. * Set productsImage
  302. *
  303. * @param string $productsImage
  304. * @return Products
  305. */
  306. public function setProductsImage($productsImage)
  307. {
  308. $this->productsImage = $productsImage;
  309.  
  310. return $this;
  311. }
  312.  
  313. /**
  314. * Get productsImage
  315. *
  316. * @return string
  317. */
  318. public function getProductsImage()
  319. {
  320. return $this->productsImage;
  321. }
  322.  
  323. /**
  324. * Set productsPrice
  325. *
  326. * @param string $productsPrice
  327. * @return Products
  328. */
  329. public function setProductsPrice($productsPrice)
  330. {
  331. $this->productsPrice = $productsPrice;
  332.  
  333. return $this;
  334. }
  335.  
  336. /**
  337. * Get productsPrice
  338. *
  339. * @return string
  340. */
  341. public function getProductsPrice()
  342. {
  343. return $this->productsPrice;
  344. }
  345.  
  346. /**
  347. * Set productsDateAdded
  348. *
  349. * @param DateTime $productsDateAdded
  350. * @return Products
  351. */
  352. public function setProductsDateAdded($productsDateAdded)
  353. {
  354. $this->productsDateAdded = $productsDateAdded;
  355.  
  356. return $this;
  357. }
  358.  
  359. /**
  360. * Get productsDateAdded
  361. *
  362. * @return DateTime
  363. */
  364. public function getProductsDateAdded()
  365. {
  366. return $this->productsDateAdded;
  367. }
  368.  
  369. /**
  370. * Set productsLastModified
  371. *
  372. * @param DateTime $productsLastModified
  373. * @return Products
  374. */
  375. public function setProductsLastModified($productsLastModified)
  376. {
  377. $this->productsLastModified = $productsLastModified;
  378.  
  379. return $this;
  380. }
  381.  
  382. /**
  383. * Get productsLastModified
  384. *
  385. * @return DateTime
  386. */
  387. public function getProductsLastModified()
  388. {
  389. return $this->productsLastModified;
  390. }
  391.  
  392. /**
  393. * Set productsDateAvailable
  394. *
  395. * @param DateTime $productsDateAvailable
  396. * @return Products
  397. */
  398. public function setProductsDateAvailable($productsDateAvailable)
  399. {
  400. $this->productsDateAvailable = $productsDateAvailable;
  401.  
  402. return $this;
  403. }
  404.  
  405. /**
  406. * Get productsDateAvailable
  407. *
  408. * @return DateTime
  409. */
  410. public function getProductsDateAvailable()
  411. {
  412. return $this->productsDateAvailable;
  413. }
  414.  
  415. /**
  416. * Set productsWeight
  417. *
  418. * @param string $productsWeight
  419. * @return Products
  420. */
  421. public function setProductsWeight($productsWeight)
  422. {
  423. $this->productsWeight = $productsWeight;
  424.  
  425. return $this;
  426. }
  427.  
  428. /**
  429. * Get productsWeight
  430. *
  431. * @return string
  432. */
  433. public function getProductsWeight()
  434. {
  435. return $this->productsWeight;
  436. }
  437.  
  438. /**
  439. * Set productsStatus
  440. *
  441. * @param boolean $productsStatus
  442. * @return Products
  443. */
  444. public function setProductsStatus($productsStatus)
  445. {
  446. $this->productsStatus = $productsStatus;
  447.  
  448. return $this;
  449. }
  450.  
  451. /**
  452. * Get productsStatus
  453. *
  454. * @return boolean
  455. */
  456. public function getProductsStatus()
  457. {
  458. return $this->productsStatus;
  459. }
  460.  
  461. /**
  462. * Set productsOrdered
  463. *
  464. * @param integer $productsOrdered
  465. * @return Products
  466. */
  467. public function setProductsOrdered($productsOrdered)
  468. {
  469. $this->productsOrdered = $productsOrdered;
  470.  
  471. return $this;
  472. }
  473.  
  474. /**
  475. * Get productsOrdered
  476. *
  477. * @return integer
  478. */
  479. public function getProductsOrdered()
  480. {
  481. return $this->productsOrdered;
  482. }
  483.  
  484.  
  485. /**
  486. * Set manufacturers
  487. *
  488. * @param ApwBlackbullBundleEntityManufacturers $manufacturers
  489. * @return Products
  490. */
  491. public function setManufacturers(ApwBlackbullBundleEntityManufacturers $manufacturers = null)
  492. {
  493. $this->manufacturers = $manufacturers;
  494.  
  495. return $this;
  496. }
  497.  
  498. /**
  499. * Get manufacturers
  500. *
  501. * @return ApwBlackbullBundleEntityManufacturers
  502. */
  503. public function getManufacturers()
  504. {
  505. return $this->manufacturers;
  506. }
  507.  
  508. /**
  509. * @ORMPrePersist
  510. */
  511. public function setCreatedAtValue()
  512. {
  513. $date = new DateTime();
  514. $this->productsDateAdded = new DateTime($date->format('d-m-Y H:i:s'));
  515. }
  516.  
  517. /**
  518. * Add productsImages
  519. *
  520. * @param ApwBlackbullBundleEntityProductsImages $productsImages
  521. * @return Products
  522. */
  523. public function addProductsImage(ApwBlackbullBundleEntityProductsImages $productsImages)
  524. {
  525. $this->productsImages[] = $productsImages;
  526.  
  527. return $this;
  528. }
  529.  
  530. /**
  531. * Remove productsImages
  532. *
  533. * @param ApwBlackbullBundleEntityProductsImages $productsImages
  534. */
  535. public function removeProductsImage(ApwBlackbullBundleEntityProductsImages $productsImages)
  536. {
  537. $this->productsImages->removeElement($productsImages);
  538. }
  539.  
  540. /**
  541. * Get productsImages
  542. *
  543. * @return DoctrineCommonCollectionsCollection
  544. */
  545. public function getProductsImages()
  546. {
  547. return $this->productsImages;
  548. }
  549.  
  550. /**
  551. * Constructor
  552. */
  553. public function __construct()
  554. {
  555. $this->categories = new ArrayCollection();
  556. $this->productsImages = new ArrayCollection();
  557. $this->productsDescription = new ArrayCollection();
  558. }
  559.  
  560. /**
  561. * Add categories
  562. *
  563. * @param ApwBlackbullBundleEntityCategories $categories
  564. * @return Products
  565. */
  566. public function addCategory(ApwBlackbullBundleEntityCategories $categories)
  567. {
  568. $this->categories[] = $categories;
  569.  
  570. return $this;
  571. }
  572.  
  573. /**
  574. * Remove categories
  575. *
  576. * @param ApwBlackbullBundleEntityCategories $categories
  577. */
  578. public function removeCategory(ApwBlackbullBundleEntityCategories $categories)
  579. {
  580. $this->categories->removeElement($categories);
  581. }
  582.  
  583. /**
  584. * Get categories
  585. *
  586. * @return DoctrineCommonCollectionsCollection
  587. */
  588. public function getCategories()
  589. {
  590. return $this->categories;
  591. }
  592.  
  593. /**
  594. * Add productsDescription
  595. *
  596. * @param ApwBlackbullBundleEntityProductsDescription $productsDescription
  597. * @return Products
  598. */
  599. public function addProductsDescription(ApwBlackbullBundleEntityProductsDescription $productsDescription)
  600. {
  601. $this->productsDescription[] = $productsDescription;
  602.  
  603. return $this;
  604. }
  605.  
  606. /**
  607. * Remove productsDescription
  608. *
  609. * @param ApwBlackbullBundleEntityProductsDescription $productsDescription
  610. */
  611. public function removeProductsDescription(ApwBlackbullBundleEntityProductsDescription $productsDescription)
  612. {
  613. $this->productsDescription->removeElement($productsDescription);
  614. }
  615.  
  616. /**
  617. * Get productsDescription
  618. *
  619. * @return DoctrineCommonCollectionsCollection
  620. */
  621. public function getProductsDescription()
  622. {
  623. return $this->productsDescription;
  624. }
  625. }
  626.  
  627. <?php
  628.  
  629. namespace ApwBlackbullBundleEntity;
  630.  
  631. use DoctrineCommonCollectionsArrayCollection;
  632. use DoctrineORMMapping as ORM;
  633.  
  634. /**
  635. * Categories
  636. *
  637. * @ORMTable()
  638. * @ORMEntity(repositoryClass="ApwBlackbullBundleEntityCategoriesRepository")
  639. */
  640. class Categories
  641. {
  642. /**
  643. * @var integer
  644. *
  645. * @ORMColumn(name="id", type="integer")
  646. * @ORMId
  647. * @ORMGeneratedValue(strategy="AUTO")
  648. */
  649. private $id;
  650.  
  651. /**
  652. * @var string
  653. *
  654. * @ORMColumn(name="categories_image", type="string", length=64, nullable = true)
  655. */
  656. private $categoriesImage;
  657.  
  658. /**
  659. * @var integer
  660. *
  661. * @ORMColumn(name="parent_id", type="integer", nullable = true, options={"default":0})
  662. */
  663. private $parentId;
  664.  
  665. /**
  666. * @var integer
  667. *
  668. * @ORMColumn(name="sort_order", type="integer", nullable = true, options={"default":0})
  669. */
  670. private $sortOrder;
  671.  
  672. /**
  673. * @var DateTime
  674. *
  675. * @ORMColumn(name="date_added", type="datetime", nullable = true)
  676. */
  677. private $dateAdded;
  678.  
  679. /**
  680. * @var DateTime
  681. *
  682. * @ORMColumn(name="last_modified", type="datetime", nullable = true)
  683. */
  684. private $lastModified;
  685.  
  686. /**
  687. * @var boolean
  688. *
  689. * @ORMColumn(name="categories_status", type="boolean", nullable = true, options={"default" = 1})
  690. */
  691. private $categoriesStatus;
  692.  
  693. /**
  694. * @ORMOneToMany(targetEntity="CategoriesDescription", mappedBy="category")
  695. */
  696. private $categoryDescription;
  697.  
  698. /**
  699. * @ORMManyToMany(targetEntity="Products", mappedBy="categories")
  700. **/
  701. private $products;
  702.  
  703. /**
  704. * Get id
  705. *
  706. * @return integer
  707. */
  708. public function getId()
  709. {
  710. return $this->id;
  711. }
  712.  
  713. /**
  714. * Set categoriesImage
  715. *
  716. * @param string $categoriesImage
  717. * @return Categories
  718. */
  719. public function setCategoriesImage($categoriesImage)
  720. {
  721. $this->categoriesImage = $categoriesImage;
  722.  
  723. return $this;
  724. }
  725.  
  726. /**
  727. * Get categoriesImage
  728. *
  729. * @return string
  730. */
  731. public function getCategoriesImage()
  732. {
  733. return $this->categoriesImage;
  734. }
  735.  
  736. /**
  737. * Set parentId
  738. *
  739. * @param integer $parentId
  740. * @return Categories
  741. */
  742. public function setParentId($parentId)
  743. {
  744. $this->parentId = $parentId;
  745.  
  746. return $this;
  747. }
  748.  
  749. /**
  750. * Get parentId
  751. *
  752. * @return integer
  753. */
  754. public function getParentId()
  755. {
  756. return $this->parentId;
  757. }
  758.  
  759. /**
  760. * Set sortOrder
  761. *
  762. * @param string $sortOrder
  763. * @return Categories
  764. */
  765. public function setSortOrder($sortOrder)
  766. {
  767. $this->sortOrder = $sortOrder;
  768.  
  769. return $this;
  770. }
  771.  
  772. /**
  773. * Get sortOrder
  774. *
  775. * @return string
  776. */
  777. public function getSortOrder()
  778. {
  779. return $this->sortOrder;
  780. }
  781.  
  782. /**
  783. * Set dateAdded
  784. *
  785. * @param DateTime $dateAdded
  786. * @return Categories
  787. */
  788. public function setDateAdded($dateAdded)
  789. {
  790. $this->dateAdded = $dateAdded;
  791.  
  792. return $this;
  793. }
  794.  
  795. /**
  796. * Get dateAdded
  797. *
  798. * @return DateTime
  799. */
  800. public function getDateAdded()
  801. {
  802. return $this->dateAdded;
  803. }
  804.  
  805. /**
  806. * Set lastModified
  807. *
  808. * @param DateTime $lastModified
  809. * @return Categories
  810. */
  811. public function setLastModified($lastModified)
  812. {
  813. $this->lastModified = $lastModified;
  814.  
  815. return $this;
  816. }
  817.  
  818. /**
  819. * Get lastModified
  820. *
  821. * @return DateTime
  822. */
  823. public function getLastModified()
  824. {
  825. return $this->lastModified;
  826. }
  827.  
  828. /**
  829. * Constructor
  830. */
  831. public function __construct()
  832. {
  833. $this->categoryDescription = new DoctrineCommonCollectionsArrayCollection();
  834. $this->products = new DoctrineCommonCollectionsArrayCollection();
  835. }
  836.  
  837. /**
  838. * Add categoryDescription
  839. *
  840. * @param ApwBlackbullBundleEntityCategoriesDescription $categoryDescription
  841. * @return Categories
  842. */
  843. public function addCategoryDescription(ApwBlackbullBundleEntityCategoriesDescription $categoryDescription)
  844. {
  845. $this->categoryDescription[] = $categoryDescription;
  846.  
  847. return $this;
  848. }
  849.  
  850. /**
  851. * Remove categoryDescription
  852. *
  853. * @param ApwBlackbullBundleEntityCategoriesDescription $categoryDescription
  854. */
  855. public function removeCategoryDescription(ApwBlackbullBundleEntityCategoriesDescription $categoryDescription)
  856. {
  857. $this->categoryDescription->removeElement($categoryDescription);
  858. }
  859.  
  860. /**
  861. * Get categoryDescription
  862. *
  863. * @return DoctrineCommonCollectionsCollection
  864. */
  865. public function getCategoryDescription()
  866. {
  867. return $this->categoryDescription;
  868. }
  869.  
  870. /**
  871. * Add products
  872. *
  873. * @param ApwBlackbullBundleEntityProducts $products
  874. * @return Categories
  875. */
  876. public function addProduct(ApwBlackbullBundleEntityProducts $products)
  877. {
  878. $products->addCategory($this);
  879. $this->products[] = $products;
  880.  
  881. return $this;
  882. }
  883.  
  884. /**
  885. * Remove products
  886. *
  887. * @param ApwBlackbullBundleEntityProducts $products
  888. */
  889. public function removeProduct(ApwBlackbullBundleEntityProducts $products)
  890. {
  891. $this->products->removeElement($products);
  892. }
  893.  
  894. /**
  895. * Get products
  896. *
  897. * @return DoctrineCommonCollectionsCollection
  898. */
  899. public function getProducts()
  900. {
  901. return $this->products;
  902. }
  903.  
  904. /**
  905. * Set categoriesStatus
  906. *
  907. * @param boolean $categoriesStatus
  908. * @return Categories
  909. */
  910. public function setCategoriesStatus($categoriesStatus)
  911. {
  912. $this->categoriesStatus = $categoriesStatus;
  913.  
  914. return $this;
  915. }
  916.  
  917. /**
  918. * Get categoriesStatus
  919. *
  920. * @return boolean
  921. */
  922. public function getCategoriesStatus()
  923. {
  924. return $this->categoriesStatus;
  925. }
  926. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement