Ejemplo n.º 1
0
 private function checkIsValidWidget($name, $method)
 {
     if (!Development::isEnabled()) {
         return;
     }
     if (empty($name)) {
         Development::error('No name is defined for added widget having method "' . $method . '" in ' . get_class($this));
     }
     if (Development::isCallableMethod($this, $method)) {
         return;
     }
     $controllerClass = 'Piwik\\Plugins\\' . $this->getModule() . '\\Controller';
     if (!Development::methodExists($this, $method) && !Development::methodExists($controllerClass, $method)) {
         Development::error('The added method "' . $method . '" neither exists in "' . get_class($this) . '" nor "' . $controllerClass . '". Make sure to define such a method.');
     }
     $definedInClass = get_class($this);
     if (Development::methodExists($controllerClass, $method)) {
         if (Development::isCallableMethod($controllerClass, $method)) {
             return;
         }
         $definedInClass = $controllerClass;
     }
     Development::error('The method "' . $method . '" is not callable on "' . $definedInClass . '". Make sure the method is public.');
 }
Ejemplo n.º 2
0
Archivo: Menu.php Proyecto: piwik/piwik
 private function checkisValidCallable($module, $action)
 {
     if (!Development::isEnabled()) {
         return;
     }
     $prefix = 'Menu item added in ' . get_class($this) . ' will fail when being selected. ';
     if (!is_string($action)) {
         Development::error($prefix . 'No valid action is specified. Make sure the defined action that should be executed is a string.');
     }
     $reportAction = lcfirst(substr($action, 4));
     if (ReportsProvider::factory($module, $reportAction)) {
         return;
     }
     $controllerClass = '\\Piwik\\Plugins\\' . $module . '\\Controller';
     if (!Development::methodExists($controllerClass, $action)) {
         Development::error($prefix . 'The defined action "' . $action . '" does not exist in ' . $controllerClass . '". Make sure to define such a method.');
     }
     if (!Development::isCallableMethod($controllerClass, $action)) {
         Development::error($prefix . 'The defined action "' . $action . '" is not callable on "' . $controllerClass . '". Make sure the method is public.');
     }
 }