/**
  * Wordpress callback that attemps to register additional
  * administration links in Wordpress's backend based on the
  * attached model.
  */
 public function action_addAdminMenus()
 {
     // Default to the model's likely controller.
     $defaultController = Controller::generateClassName($this->model->getShortName());
     $parentSlug = 'edit.php?post_type=' . $this->model->getWordpressKey();
     foreach ($this->getConfiguration() as $func => $config) {
         $config += array('title' => ucfirst($func), 'menu-title' => ucfirst($func), 'capability' => "manage_options", 'icon' => null, 'route' => array($defaultController, $func), 'position' => null);
         // This is to circumvent how Wordpress doesn't let you pass arguments to
         // callbacks so we can send the controller and function to the router.
         // We dont want people to have to specify that odd function name.
         // Allow them to send the controller string name and take care of the rest.
         if (is_string($config['route'])) {
             $route = Router::callback($config['route'], $func);
         } else {
             $route = Router::callback($config['route'][0], $config['route'][1]);
         }
         $uniquePage = $this->model->getWordpressKey() . "_" . $func;
         add_submenu_page($parentSlug, $config['title'], $config['menu-title'], $config['capability'], $uniquePage, $route, $config['icon'], $config['position']);
     }
 }
Example #2
0
 /**
  * @expectedException        Exception
  */
 public function testInvalidCallbackDestination()
 {
     $invalidCallback = Router::callback("InvalidController", "invalid");
     call_user_func($invalidCallback);
 }