Guest User

Untitled

a guest
Sep 9th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. Gallery Model:
  2.  
  3. <?php
  4. namespace Foo\Bar\Domain\Model;
  5.  
  6. use TYPO3\Flow\Annotations as Flow;
  7. use Doctrine\ORM\Mapping as ORM;
  8.  
  9. /**
  10.  * A gallery
  11.  *
  12.  * @Flow\Entity
  13.  */
  14. class Gallery {
  15.  
  16.     /**
  17.      * The images of this gallery
  18.      *
  19.      * @var \Doctrine\Common\Collections\Collection<\Foo\Bar\Domain\Model\Image>
  20.      * @ORM\OneToMany(mappedBy="gallery", cascade={"all"}, orphanRemoval=true)
  21.      */    
  22.     protected $images;
  23.    
  24.     public function __construct() {
  25.         $this->images = new \Doctrine\Common\Collections\ArrayCollection();
  26.     }
  27.  
  28.    ....
  29.  
  30. }
  31.  
  32. ?>
  33.  
  34. Image Model:
  35.  
  36. <?php
  37. namespace Foo\Bar\Domain\Model;
  38.  
  39. use TYPO3\Flow\Annotations as Flow;
  40. use Doctrine\ORM\Mapping as ORM;
  41.  
  42. /**
  43.  * @Flow\Entity
  44.  */
  45. class Image extends \TYPO3\Media\Domain\Model\Image {
  46.    
  47.     /**
  48.      * The gallery this image belongs to
  49.      *
  50.      * @var \Foo\Bar\Domain\Model\Gallery
  51.      * @ORM\ManyToOne(inversedBy="images")
  52.      * @ORM\Column(nullable=true)
  53.      */
  54.     protected $gallery;
  55.    
  56.     /**
  57.      * @return object
  58.      */
  59.     public function getGallery() {
  60.         return $this->gallery;
  61.     }
  62.    
  63.     /**
  64.      * @param $gallery
  65.      * @return void
  66.      */
  67.     public function setGallery($gallery) {
  68.         $this->gallery = $gallery;
  69.     }  
  70.    
  71.     ...
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment