protected function getChild($child, $args = array()) { Logger::info('child: ' . $child); $action = new Action($child, $args); if (file_exists($action->getFile())) { if (!class_exists($action->getClass())) { require_once $action->getFile(); } $class = $action->getClass(); $controller = new $class($this->registry); if (method_exists($class, $action->getMethod())) { $controller->{$action->getMethod()}($action->getArgs()); return $controller->output; } else { trigger_error('Warning: Method ' . $class . '->' . $action->getMethod() . '(' . $action->getArgs() . ') does not exist', E_USER_WARNING); return $this->output; } } else { if (isset($this->data['header'])) { $this->output .= $this->data['header']; } if (isset($this->data['footer'])) { $this->output .= $this->data['footer']; } trigger_error('Error: Could not load controller ' . $child . '! (File: ' . $action->getFile() . ')', E_USER_ERROR); return $this->output; } }
/** * * @return type */ public function index() { $action = new Action('payment/paysondirect'); if (file_exists($action->getFile())) { require_once $action->getFile(); $class = $action->getClass(); $controller = new $class($this->registry); $controller->setInvoice(); $controller->{$action->getMethod()}($action->getArgs()); $this->output = $controller->output; } }
protected function getChild($child, $args = array()) { $action = new Action($child, $args); if (file_exists($action->getFile())) { require_once $action->getFile(); $class = $action->getClass(); $controller = new $class($this->registry); $controller->{$action->getMethod()}($action->getArgs()); return $controller->output; } else { trigger_error('Error: Could not load controller ' . $child . '!'); exit; } }
protected function hasAction($child, $args = array()) { $action = new Action($child, $args); if (file_exists($action->getFile())) { require_once $action->getFile(); $class = $action->getClass(); $controller = new $class($this->registry); if (method_exists($controller, $action->getMethod())) { return true; } else { return false; } } else { return false; } }
protected function getChild($child, $args = array()) { $action = new Action($child, $args); $file = $action->getFile(); $class = $action->getClass(); $method = $action->getMethod(); //echo $file.'<br/>'; if (file_exists($file)) { require_once $file; $controller = new $class($this->registry); $controller->{$method}($args); return $controller->output; } else { exit('Error: Could not load controller ' . $child . '!'); } }
protected function hasAction($child, $args = array()) { $action = new Action($child, $args); if (file_exists($action->getFile())) { require_once VQMod::modCheck($action->getFile()); $class = $action->getClass(); $controller = new $class($this->registry); if (method_exists($controller, $action->getMethod())) { return true; } else { return false; } } else { trigger_error('Error: Could not load controller ' . $child . '!'); exit; } }
protected function getChild($child, $args = array()) { $action = new Action($child, $args); $file = $action->getFile(); $class = $action->getClass(); $method = $action->getMethod(); if (file_exists($file)) { require_once $file; $controller = new $class($this->registry); if (substr($child, 0, 6) == 'module' && isset($args['position'])) { $controller->data['module_position'] = $args['position']; } $controller->{$method}($args); return $controller->output; } else { trigger_error('Error: Could not load controller ' . $child . '!'); exit; } }
/** * @param Action $action * @return mixed */ private function execute($action) { $file = $action->getFile(); $class = $action->getClass(); $method = $action->getMethod(); $args = $action->getArgs(); if (file_exists($file)) { require_once $file; $controller = new $class($this->registry, $method); if (is_callable(array($controller, $method))) { $action = call_user_func_array(array($controller, $method), $args); } else { $action = $this->error; $this->error = ''; } } else { $action = $this->error; $this->error = ''; } return $action; }
protected function render($return = FALSE) { foreach ($this->children as $child) { $action = new Action($child); $file = $action->getFile(); $class = $action->getClass(); $method = $action->getMethod(); $args = $action->getArgs(); if (file_exists($file)) { require_once $file; $controller = new $class($this->registry); $controller->index(); $this->data[$controller->id] = $controller->output; } else { exit('Error: Could not load controller ' . $child . '!'); } } if ($return) { return $this->fetch($this->template); } else { $this->output = $this->fetch($this->template); } }
protected function render($return = false) { $cache = $this->registry->get('cache'); $user = $this->registry->get('user'); if (isset($this->cacheId) && !empty($this->cacheId) && isset($user) && !$user->islogged()) { $cached = $cache->get($this->cacheId); } if (!isset($cached)) { foreach ($this->children as $key => $child) { $action = new Action($child); $file = $action->getFile(); $class = $action->getClass(); $method = $action->getMethod(); $args = $action->getArgs(); if (file_exists($file)) { require_once $file; $controller = new $class($this->registry); $controller->index($this->widget[$key]); if (!is_numeric($key)) { $this->data[$key . "_hook"] = $key; $this->data[$key . "_code"] = $controller->output; } else { $this->data[$controller->id] = $controller->output; } } else { exit('Error: Could not load controller ' . $child . '!'); } } if ($return) { $r = $this->fetch($this->template); if (isset($this->cacheId) && !empty($this->cacheId)) { $cache->set($this->cacheId, $r); } return $r; } else { $this->output = $this->fetch($this->template); } } else { if ($return) { return $cached; } else { $this->output = $cached; } } }
public function getReplace() { if (is_numeric($this->_key)) { $depth = ControllerModuleHtmlBlock::getDepth(); $args = array('html_block_id' => (int) $this->_key, 'depth' => $depth + 1); $action = new Action('module/html_block', $args); $file = $action->getFile(); $class = $action->getClass(); if (file_exists($file)) { require_once $file; $controller = new $class(app::registry()->get()); $controller->index($args); $this->_replace = $controller->getOutput(); } } return $this->_replace; }
public function loadControllerByRoute($route) { $action = new Action($route); // copied from front controller to resolve the action controller and return it: if (file_exists($action->getFile())) { require_once $action->getFile(); $class = $action->getClass(); return new $class($this->registry); } throw new Exception("Controller doesn't exist!"); }