protected function getController() { if (array_key_exists("controller", $this->model->routed)) { $controllerName = $this->model->routed['controller']; return new $controllerName(); } $controllerClass = Controller::generateClassPath($this->model->getShortName()); return new $controllerClass(); }
/** * 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']); } }
/** * Gets a Controller instance form the dynamic information * @param array $match An AltoRouter answer * @return Controller A controller object */ private function getControllerFromDynamicMatch($match = array()) { try { if (array_key_exists("controller", $match["params"])) { return Controller::factory($match["params"]["controller"]); } } catch (Exception $e) { // The controller did not exist, we don't care at this point. // We'll just ignore the route. } return Controller::factory("App"); }
public function redirect($controllerName, $action = "index", $arguments = array()) { $router = Strata::router(); if (is_null($router)) { return; } $router->abandonCurrent(); $route = new UrlRoute(); $route->action = $action; $route->arguments = $arguments; if ($controllerName !== $this->getShortName()) { $route->controller = Controller::factory($controllerName); $route->controller->request = $this->request; $route->controller->view = $this->view; } else { $route->controller = $this; $route->setDirectExecution(); } return $route->attemptCompletion(); }
/** * {@inheritdoc} */ public function addPossibilities(array $route) { $this->controller = Controller::factory($route[0]); $this->action = $route[1]; }
public function init() { parent::init(); $this->stackorder = array(); }
/** * {@inheritdoc} */ public function applyOptions(array $args) { $this->keyword = $args[0]; $this->classname = Controller::generateClassName($this->keyword); }