Beispiel #1
0
 /**
  * Dispatch a module view request.
  *
  * @return mixed
  */
 public function dispatch()
 {
     if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     // Get input.
     $moduleName = $this->request->getGet()->filter('_module', null, FILTER_SANITIZE_STRING);
     $pluginName = $this->request->getGet()->filter('_plugin', null, FILTER_SANITIZE_STRING);
     $action = $this->request->getGet()->filter('_action', null, FILTER_SANITIZE_STRING);
     // Load plugins.
     if (!$moduleName) {
         $type = 'SystemPlugin';
         PluginUtil::loadAllSystemPlugins();
     } else {
         $type = 'ModulePlugin';
         PluginUtil::loadAllModulePlugins();
     }
     if ($moduleName) {
         $serviceId = PluginUtil::getServiceId("{$type}_{$moduleName}_{$pluginName}_Plugin");
     } else {
         $serviceId = PluginUtil::getServiceId("{$type}_{$pluginName}_Plugin");
     }
     $this->throwNotFoundUnless($this->serviceManager->hasService($serviceId));
     $this->plugin = $this->serviceManager->getService($serviceId);
     // Sanity checks.
     $this->throwNotFoundUnless($this->plugin->isInstalled(), __f('Plugin "%s" is not installed', $this->plugin->getMetaDisplayName()));
     $this->throwForbiddenUnless($this->plugin instanceof Zikula_Plugin_ConfigurableInterface, __f('Plugin "%s" is not configurable', $this->plugin->getMetaDisplayName()));
     $this->pluginController = $this->plugin->getConfigurationController();
     $this->throwNotFoundUnless($this->pluginController->getReflection()->hasMethod($action));
     return $this->pluginController->{$action}();
 }
Beispiel #2
0
 /**
  * Set view property.
  *
  * @param Zikula_View $view Default null means new Render instance for this module name.
  *
  * @return Zikula_Controller_AbstractPlugin
  */
 protected function setView(Zikula_View $view = null)
 {
     // please note the docblock param signature is deliberately different to the method signature - drak
     if (is_null($view)) {
         if ($this->plugin->getPluginType() == Zikula_AbstractPlugin::TYPE_MODULE) {
             $view = Zikula_View_Plugin::getModulePluginInstance($this->moduleName, $this->pluginName);
         } else {
             $view = Zikula_View_Plugin::getSystemPluginInstance($this->pluginName);
         }
     } else {
         if (!$view instanceof Zikula_View_Plugin) {
             $name = is_object($view) ? get_class($view) : '$view';
             throw new InvalidArgumentException(sprintf('%s must be an instance of Zikula_View_Plugin', $name));
         }
     }
     $this->view = $view;
     return $this;
 }
 /**
  * @Route("/dispatch")
  *
  * Dispatch a module view request.
  *
  * @return mixed
  * 
  * @throws AccessDeniedException Thrown if the user doesn't have admin access to the module or
  *                                          if the plugin isn't configurable
  * @throws NotFoundHttpException Thrown if the plugin doesn't have the requested service or action methods
  */
 public function dispatchAction()
 {
     if (!SecurityUtil::checkPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
         throw new AccessDeniedException();
     }
     // Get input.
     $moduleName = $this->request->query->filter('_module', null, FILTER_SANITIZE_STRING);
     $pluginName = $this->request->query->filter('_plugin', null, FILTER_SANITIZE_STRING);
     $action = $this->request->query->filter('_action', null, FILTER_SANITIZE_STRING);
     // Load plugins.
     if (!$moduleName) {
         $type = 'SystemPlugin';
         PluginUtil::loadAllSystemPlugins();
     } else {
         $type = 'ModulePlugin';
         PluginUtil::loadAllModulePlugins();
     }
     if ($moduleName) {
         $serviceId = PluginUtil::getServiceId("{$type}_{$moduleName}_{$pluginName}_Plugin");
     } else {
         $serviceId = PluginUtil::getServiceId("{$type}_{$pluginName}_Plugin");
     }
     if (!$this->getContainer()->has($serviceId)) {
         throw new NotFoundHttpException();
     }
     $this->plugin = $this->getContainer()->get($serviceId);
     // Sanity checks.
     if (!$this->plugin instanceof Zikula_Plugin_ConfigurableInterface) {
         throw new AccessDeniedException(__f('Plugin "%s" is not configurable', $this->plugin->getMetaDisplayName()));
     }
     $this->pluginController = $this->plugin->getConfigurationController();
     if (!$this->pluginController->getReflection()->hasMethod($action)) {
         throw new NotFoundHttpException();
     }
     return $this->response($this->pluginController->{$action}());
 }