function test_should_parse_urls_with_format() { $controller = new Trails_Controller($this->dispatcher); $extractions = array('wiki/show/group' => array('wiki', array('show', 'group'), NULL), 'wiki/show/group.html' => array('wiki', array('show', 'group'), 'html'), '' => array('index', array(), NULL), 'wiki.json' => array('wiki', array(), 'json'), 'wiki' => array('wiki', array(), NULL), 'wiki/' => array('wiki', array(''), NULL), 'wiki///' => array('wiki', array('', '', ''), NULL), 'show/id-with-hyphen' => array('show', array('id-with-hyphen'), NULL), 'show/id-with-hyphen.html' => array('show', array('id-with-hyphen'), 'html')); foreach ($extractions as $url => $extraction) { $this->assertEqual($extraction, $controller->extract_action_and_args($url)); } }
function __construct($dispatcher) { parent::__construct($dispatcher); $this->plugin = $this->dispatcher->current_plugin; }
/** * **/ public function before_filter(&$action, &$args) { parent::before_filter($action, $args); $this->set_layout(null); }
/** * Relocate the user to another location. This is a specialized version * of redirect that differs in two points: * * - relocate() will force the browser to leave the current dialog while * redirect would refresh the dialog's contents * - relocate() accepts all the parameters that url_for() accepts so it's * no longer neccessary to chain url_for() and redirect() * * @param String $to Location to redirect to */ public function relocate($to) { $from_dialog = Request::isDialog(); if (func_num_args() > 1 || $from_dialog) { $to = call_user_func_array(array($this, 'url_for'), func_get_args()); } if ($from_dialog) { $this->response->add_header('X-Location', $to); $this->render_nothing(); } else { parent::redirect($to); } }
function test_should_render_template_decorated_with_explicit_layout() { $dispatcher = new Trails_Dispatcher('var://app', 'trails_uri', 'default'); $controller = new Trails_Controller($dispatcher); $controller->render_template('foo/index', 'layout'); $this->assertEqual($controller->get_response(), new Trails_Response('[foo/index]')); }