/**
  * @param AjaxFileUploaderControl $control
  * @param FileUpload $file
  */
 public function handleFileUpload(AjaxFileUploaderControl $control, $fileName)
 {
     /** @var FileEntity $fileEntity */
     $fileEntity = $this->fileRepository->createNew();
     $fileEntity->setFile(new \SplFileInfo($this->ajaxDir . '/' . $fileName));
     $this->fileRepository->save($fileEntity);
     $this->categoryEntity->items[] = $photoEntity = new ItemEntity($this->categoryEntity->extendedPage);
     $photoEntity->route->setPhoto($fileEntity);
     $photoEntity->route->setParent($this->categoryEntity->route);
     $photoEntity->setCategory($this->categoryEntity);
     $this->itemRepository->save($photoEntity);
 }
Ejemplo n.º 2
0
 public function handleSave(Form $form)
 {
     /** @var $entity CategoryEntity */
     $entity = $form->data;
     $data = $form->getValues();
     foreach ($data['_photos'] as $fileEntity) {
         if ($fileEntity) {
             $entity->items[] = $photoEntity = new ItemEntity($form->data->extendedPage);
             $photoEntity->route->setPhoto($fileEntity);
             $photoEntity->route->setParent($entity->route);
             $photoEntity->setCategory($entity);
         }
     }
     parent::handleSave($form);
 }