Guest User

many-to-many image upload

a guest
Apr 18th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. namespace WL\Test\Domain\Model;
  2.  
  3. use TYPO3\Flow\Annotations as Flow;
  4. use Doctrine\ORM\Mapping as ORM;
  5.  
  6. /**
  7.  * A Master
  8.  *
  9.  * @Flow\Entity
  10.  */
  11. class Master {
  12.  
  13.     /**
  14.      * The name
  15.      * @var string
  16.      */
  17.     protected $name;
  18.  
  19.  
  20.     /**
  21.      * @var \WL\Test\Domain\Model\Image
  22.      * @ORM\ManyToMany
  23.      */
  24.     protected $image;
  25.     /**
  26.      * Get the Master's name
  27.      *
  28.      * @return string The Master's name
  29.      */
  30.     public function getName() {
  31.         return $this->name;
  32.     }
  33.  
  34.     /**
  35.      * Sets this Master's name
  36.      *
  37.      * @param string $name The Master's name
  38.      * @return void
  39.      */
  40.     public function setName($name) {
  41.         $this->name = $name;
  42.     }
  43.  
  44.  
  45.     /**
  46.      * @param return \WL\Test\Domain\Model\Image $image
  47.      * @return void
  48.      */
  49.     public function setImage(\WL\Test\Domain\Model\Image $image) {
  50.         $this->picture = $image;
  51.     }
  52.  
  53.     /**
  54.      * @return \WL\Test\Domain\Model\Image
  55.      */
  56.     public function getImage() {
  57.         return $this->image;
  58.     }
  59. }
  60. ?>
  61. ###########################################################################################
  62. <?php
  63. namespace WL\Test\Domain\Model;
  64.  
  65. use Doctrine\ORM\Mapping as ORM;
  66. use TYPO3\Flow\Annotations as Flow;
  67.  
  68. /**
  69.  * An image
  70.  *
  71.  * @Flow\Scope("prototype")
  72.  * @Flow\Entity
  73.  */
  74. class Image {
  75.  
  76.     /**
  77.      * @var string
  78.      */
  79.     protected $title;
  80.  
  81.     /**
  82.      * @var \TYPO3\Flow\Resource\Resource
  83.      * @ORM\ManyToOne
  84.      * @Flow\Validate(type="NotEmpty")
  85.      */
  86.     protected $originalResource;
  87.  
  88.     /**
  89.      * @param string $title
  90.      * @return void
  91.      */
  92.     public function setTitle($title) {
  93.         $this->title = $title;
  94.     }
  95.  
  96.     /**
  97.      * @return string The title
  98.      */
  99.     public function getTitle() {
  100.         return $this->title;
  101.     }
  102.  
  103.     /**
  104.      * @param \TYPO3\Flow\Resource\Resource $originalResource
  105.      * @return void
  106.      */
  107.     public function setOriginalResource(\TYPO3\Flow\Resource\Resource $originalResource) {
  108.         $this->originalResource = $originalResource;
  109.     }
  110.  
  111.     /**
  112.      * @return \TYPO3\Flow\Resource\Resource $originalResource
  113.      */
  114.     public function getOriginalResource() {
  115.         return $this->originalResource;
  116.     }
  117. }
  118.  
  119. #####################################FORM########################################
  120.     <f:form action="create"  name="newMaster" object="newMaster" enctype="multipart/form-data">
  121.         <label for="name">Name</label>
  122.         <f:form.textfield property="name" id="name" />
  123.         <f:form.hidden property="image.title" value="newpic"/>
  124.         <f:form.upload property="image.originalResource" />
  125.         <f:form.submit value="Create" />
  126.     </f:form>
Advertisement
Add Comment
Please, Sign In to add comment