Ejemplo n.º 1
0
 /**
  * @param UploaderModelInterface $model
  * @param null $values
  * @return string
  * @throws InvalidArgumentException
  */
 public function render($model, $values = null)
 {
     if (!$model instanceof UploaderModelInterface) {
         throw new InvalidArgumentException("Unsupportable type of model, required type UploaderModelInterface");
     }
     $resources = $model->getResourcePaths();
     $url = array_pop($resources);
     $funcNum = $this->params->get('CKEditorFuncNum', 0);
     return "<script type='text/javascript'>\n                    window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . $url . "', '');\n                </script>";
 }
 /**
  * Dispatch a request
  *
  * @events dispatch.pre, dispatch.post
  * @param  Request $request
  * @param  null|Response $response
  * @return Response|mixed
  */
 public function dispatch(Request $request, Response $response = null)
 {
     $this->request = $request;
     $this->getDataResourceCreator()->setData(array_merge_recursive($this->params()->fromPost(), $request->getFiles()->toArray()));
     if (!$this->getDataResourceCreator()->isValid()) {
         if ($this->disableDefaultErrorHandler) {
             $response = $response ?: new HttpResponse();
             $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
             $this->getEvent()->setResult(false);
             $response->setStatusCode(400);
         } else {
             $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
             $this->uploaderModel->setMessages($this->getDataResourceCreator());
             $this->getEvent()->setResult($this->uploaderModel);
         }
     }
     parent::dispatch($request, $response);
 }