private function mapResourceRoutes(AkRouter $Map, $Resource, $action, $route_path, $route_name = null, $method = null, $resource_options = array()) { if ($Resource->hasAction($action)) { $action_options = $this->actionOptionsFor($action, $Resource, $method, $resource_options); $formatted_route_path = $route_path . '.:format'; $requirements = Ak::deleteAndGetValue($action_options, array('requirements')); $conditions = Ak::deleteAndGetValue($action_options, array('conditions')); if ($route_name && !in_array($route_name, $Map->getNamedRouteNames())) { $Map->connectNamed($route_name, $formatted_route_path, $action_options, (array) $requirements, (array) $conditions); } else { $Map->connectNamed(null, $formatted_route_path, $action_options, (array) $requirements, (array) $conditions); } } }
public function assertSingletonNamedRoutesFor($singleton_name, $options = array()) { $options['options'] = empty($options['options']) ? array() : $options['options']; $options['options']['controller'] = !empty($options['controller']) ? Ak::deleteAndGetValue($options, 'controller') : AkInflector::pluralize($singleton_name); $controller_class_name = AkInflector::camelize($options['options']['controller']) . 'Controller'; $this->recognizeRouteForPath($singleton_name); $this->Controller = new $controller_class_name(); $this->Request = new AkTestRequest(); $this->Response = new AkTestResponse(); Ak::deleteAndGetValue($options['options'], 'action'); $path = isset($options['as']) ? $options['as'] : $singleton_name; $name_prefix = @$options['path_prefix']; $full_path = '/' . $name_prefix . $path; $this->assertNamedRoute($full_path, $name_prefix . $singleton_name . '_path', $options['options']); $this->assertNamedRoute($full_path . '.xml', $name_prefix . $singleton_name . '_path', array_merge($options['options'], array('format' => 'xml'))); $this->assertNamedRoute($full_path . '/add', 'add_' . $name_prefix . $singleton_name . '_path', $options['options']); $this->assertNamedRoute($full_path . '/add.xml', 'add_' . $name_prefix . $singleton_name . '_path', array_merge($options['options'], array('format' => 'xml'))); $this->assertNamedRoute($full_path . '/edit', 'edit_' . $name_prefix . $singleton_name . '_path', $options['options']); $this->assertNamedRoute($full_path . '/edit.xml', 'edit_' . $name_prefix . $singleton_name . '_path', array_merge($options['options'], array('format' => 'xml'))); }
public function to_label_tag($text = null, $options = array()) { $tag_value = Ak::deleteAndGetValue($options, 'value'); $name_and_id = $options; $this->add_default_name_and_id_for_value($tag_value, $name_and_id); Ak::deleteAndGetValue($options, 'index'); $options['for'] = !empty($options['for']) ? $options['for'] : @$name_and_id['id']; return AkFormTagHelper::label_tag(@$name_and_id['id'], $text, $options); }
public function _handleFlashAttribute(&$new_attributes = array()) { $flash = Ak::deleteAndGetValue($new_attributes, array('notice', 'error', 'message')); if (!empty($flash)) { foreach ($flash as $k => $v) { $this->flash[$k] = $v; } } if (!$this->_flash_handled) { $this->_flash_handled = true; $next_flash = empty($this->flash) ? false : $this->flash; $this->flash = array(); if (isset($_SESSION['__flash'])) { $this->flash = $_SESSION['__flash']; } $_SESSION['__flash'] = $next_flash; if (!empty($this->flash_now)) { $this->flash = array_merge((array) $this->flash, (array) $this->flash_now); } $this->_handleFlashOptions(); } // remove empty values $_SESSION = array_diff($_SESSION, array('')); }
/** * Renders the template present at <tt>template_path</tt> (relative to the template_root). * The array in <tt>local_assigns</tt> is made available as local variables. */ public function render($options = array()) { if (is_string($options)) { $result = $this->renderFile($options, true); } elseif (is_array($options)) { $options['locals'] = empty($options['locals']) ? array() : $options['locals']; $options['use_full_path'] = empty($options['use_full_path']) ? true : false; if (!empty($options['file'])) { $result = $this->renderFile($options['file'], $options['use_full_path'], $options['locals']); } elseif (!empty($options['partial']) && (isset($options['collection']) && is_array($options['collection']))) { $result = $this->renderPartialCollection($options['partial'], $options['collection'], @$options['spacer_template'], @$options['locals']); } elseif (!empty($options['partial'])) { $result = $this->renderPartial($options['partial'], @$options['object'], @$options['locals']); } elseif ($options['inline']) { $result = $this->renderTemplate(empty($options['type']) ? 'tpl' : $options['type'], $options['inline'], null, empty($options['locals']) ? array() : $options['locals']); } } if (!empty($options['layout'])) { $layout = Ak::deleteAndGetValue($options, 'layout'); list($template_extension, $template_file_name) = $this->_getTemplateExtenssionAndFileName($layout); return $this->renderTemplate('tpl', null, $template_file_name, array_merge($options['locals'], array('content_for_layout' => $result))); } return $result; }