예제 #1
0
 /**
  * @return ViewModel
  */
 public function listAction()
 {
     $this->createDirForm->build();
     $this->uploadFileForm->build();
     $this->deleteFileForm->build();
     $viewData = ['list' => $this->getFileManager()->getList(), 'currentDir' => $this->getCurrentPath(), 'createForm' => $this->createDirForm, 'uploadForm' => $this->uploadFileForm, 'deleteForm' => $this->deleteFileForm];
     $this->layout('layout/filemanager.phtml');
     return new ViewModel($viewData);
 }
 /**
  * @param CreateDirectoryForm $form
  *
  * @return bool
  */
 private function handleCreatePost(CreateDirectoryForm $form)
 {
     /** @var \Zend\Http\Request $request */
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         $form->getInputFilter()->init();
         if ($form->isValid()) {
             return $this->getFileManager()->create($form->getData()['directoryName']);
         }
     }
     return false;
 }
예제 #3
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return CreateDirectoryController
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if ($serviceLocator instanceof ControllerManager) {
         $serviceLocator = $serviceLocator->getServiceLocator();
     }
     $createDirForm = new CreateDirectoryForm();
     /** @var FileManagerService $fileManager */
     $fileManager = $serviceLocator->get('DmFileman\\Service\\FileManager');
     /** @var ThumbnailerService $thumbsConfig */
     $thumbsConfig = $serviceLocator->get('DmFileman\\Service\\Thumbnailer');
     /** @var UserText $userText */
     $userText = $serviceLocator->get('DmFileman\\View\\Helper\\UserText');
     $createDirForm->setInputFilter(new CreateDirectoryInputFilter());
     $controller = new CreateDirectoryController($fileManager, $createDirForm, $thumbsConfig, $userText);
     return $controller;
 }
예제 #4
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return ListController
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if ($serviceLocator instanceof ControllerManager) {
         $serviceLocator = $serviceLocator->getServiceLocator();
     }
     /** @var FileManagerService $fileManager */
     $fileManager = $serviceLocator->get('DmFileman\\Service\\FileManager');
     $createDirForm = new CreateDirectoryForm();
     $uploadFileForm = new UploadFileForm();
     $deleteFileForm = new DeleteFileForm();
     $createDirForm->setInputFilter(new CreateDirectoryInputFilter());
     /** @var UploadFileInputFilter $inputFileFilter */
     $inputFileFilter = $serviceLocator->get('DmFileman\\InputFilter\\UploadFile');
     $uploadFileForm->setInputFilter($inputFileFilter);
     $deleteFileForm->setInputFilter(new DeleteFileInputFilter());
     /** @var UploadFileInputFilter $uploadFileFilter */
     $uploadFileFilter = $uploadFileForm->getInputFilter();
     $uploadFileFilter->setFileInput(new FileInput());
     $controller = new ListController($fileManager, $createDirForm, $uploadFileForm, $deleteFileForm);
     return $controller;
 }
 /**
  * @covers DmFileman\Form\CreateDirectoryForm
  */
 public function testBuild()
 {
     $this->sut->build();
     $this->assertInstanceOf('Zend\\Form\\Element\\Text', $this->sut->get(Form::DIRECTORY));
     $this->assertInstanceOf('Zend\\Form\\Element\\Csrf', $this->sut->get(Form::SECURITY));
 }