Example #1
0
/**
 * Constructor for a Route
 * Add a regex condition on the lang param to be sure it matches the available langs
 *
 * @param string $template Template string with parameter placeholders
 * @param array $defaults Array of defaults for the route.
 * @param string $params Array of parameters and additional options for the Route
 * @return void
 */
	public function __construct($template, $defaults = array(), $options = array()) {
		if (strpos($template, ':lang') === false && empty($options['disableAutoNamedLang'])) {
			$template = '/:lang' . $template;
		}
		if (strpos($template, ':lang')) {
			if (defined('DEFAULT_LANGUAGE') && empty($options['disableDefaultConnect'])) {
				// Connects the default language without the :lang param
				Router::connect(
					str_replace('/:lang', '', $template),
					array_merge($defaults, array('lang' => DEFAULT_LANGUAGE)),
					array_merge($options, array('routeClass' => $this->name, 'disableAutoNamedLang' => true)));
			}
			$options = array_merge((array)$options, array(
				'lang' => join('|', Configure::read('Config.languages')),
			));

			$Router = Router::getInstance();
			$routesList = Configure::read('I18nRoute.routes');
			$routesList[] = count($Router->routes);
			Configure::write('I18nRoute.routes', $routesList);
		}
		unset($options['disableAutoNamedLang'], $options['disableDefaultConnect']);
		
		if ($template == '/:lang/') {
			$template = '/:lang';
		}
		parent::__construct($template, $defaults, $options);
	}
Example #2
0
 public function __construct($template, $defaults = array(), $options = array())
 {
     parent::__construct($template, $defaults, $options);
     /*$this->Postcard = new Postcard();
       $this->UserPostcard = new UserPostcard();
       $this->Category = new Category();
       $this->SitePage = new SitePage();*/
 }
 /**
  * Constructor for a Route.
  *
  * @param string $template Template string with parameter placeholders
  * @param array  $defaults Array of defaults for the route.
  * @param array  $options  Array of parameters and additional options for the Route
  *
  * @return \CakeRoute
  */
 public function __construct($template, $defaults = array(), $options = array())
 {
     if (strpos($template, ':current_tenant') === false && empty($options['disableAutoNamedLang'])) {
         Router::connect($template, $defaults + array('current_tenant' => Configure::read('Config.current_tenant')), array('routeClass' => $this->name) + $options);
         $options += array('__promote' => true);
         $template = '/:current_tenant' . $template;
     }
     $options = array_merge((array) $options, array('current_tenant' => '[a-z]{1,10}'));
     if ($template == '/:current_tenant/') {
         $template = '/:current_tenant';
     }
     parent::__construct($template, $defaults, $options);
 }
Example #4
0
 /**
  * Constructor for a Route
  * Add a regex condition on the lang param to be sure it matches the available langs
  *
  * @param string $template Template string with parameter placeholders
  * @param array  $defaults Array of defaults for the route.
  * @param array  $options Array of parameters and additional options for the Route
  * @return \I18nRoute
  */
 public function __construct($template, $defaults = array(), $options = array())
 {
     if (strpos($template, ':lang') === false && empty($options['disableAutoNamedLang'])) {
         Router::connect($template, $defaults + array('lang' => DEFAULT_LANGUAGE), array('disableAutoNamedLang' => true, 'routeClass' => $this->name) + $options);
         $options += array('__promote' => true);
         $template = '/:lang' . $template;
     }
     $options = array_merge((array) $options, array('lang' => join('|', Configure::read('Config.languages'))));
     unset($options['disableAutoNamedLang']);
     if ($template == '/:lang/') {
         $template = '/:lang';
     }
     parent::__construct($template, $defaults, $options);
 }
Example #5
0
 public function __construct($template, $defaults = array(), $options = array())
 {
     $options = Hash::merge(array('api' => Configure::read('Croogo.Api.path'), 'prefix' => 'v[0-9.]+'), $options);
     parent::__construct($template, $defaults, $options);
 }
 /**
  * Constructor
  *
  * @param string $template Template string with parameter placeholders
  * @param array $defaults Array of defaults for the route.
  * @param array $options Array of additional options for the Route
  */
 public function __construct($template, $defaults = array(), $options = array())
 {
     parent::__construct($template, $defaults, $options);
     $this->redirect = (array) $defaults;
 }
 public function __construct($template, $defaults = array(), $options = array())
 {
     parent::__construct($template, $defaults, $options);
     $this->Request = new CakeRequest();
     $this->options = array_merge(array('protocol' => 'http'), $options);
 }
 /**
  * Constructor for a Route
  *
  * @param string $template Template string with parameter placeholders
  * @param array $defaults Array of defaults for the route.
  * @param string $options Array of parameters and additional options for the Route
  * @return void
  */
 public function __construct($template, $defaults = array(), $options = array())
 {
     $options = array_merge($this->options, (array) $options);
     parent::__construct($template, $defaults, $options);
 }
 public function __construct($template, $defaults = array(), $options = array())
 {
     parent::__construct($template, $defaults, $options);
     $this->Request = new CakeRequest();
 }
Example #10
0
 /**
  * Sets up cache config and options
  *
  * @param string $template
  * @param array $defaults
  * @param array $options
  */
 public function __construct($template, $defaults = array(), $options = array())
 {
     parent::__construct($template, $defaults, $options);
     $this->config();
 }