Skip to content

Instantly share code, notes, and snippets.

@MichaelGooden
Forked from anonymous/gist:6249198
Last active December 21, 2015 04:28
Show Gist options
  • Save MichaelGooden/6249215 to your computer and use it in GitHub Desktop.
Save MichaelGooden/6249215 to your computer and use it in GitHub Desktop.
<?php
// Hostname route
'front-ent' => array(
'type' => 'Hostname',
'options' => array(
'route' => ':subdomain.' . BASE_DOMAIN,
'constrains' => [
'subdomain' => '[a-zA-Z0-9\-]+',
],
'defaults' => array(
'__NAMESPACE__' => 'FrontEnt\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'__NAMESPACE__' => 'FrontEnt\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
),
'about' => array(
'type' => 'Literal',
'options' => array(
'route' => '/about',
'defaults' => array(
'__NAMESPACE__' => 'FrontEnt\Controller',
'controller' => 'Index',
'action' => 'about',
),
),
),
),
),
// Some another routies
//////------
/// another module. There may be many.
'front-ent' => array(
'child_routes' => array(
'pr-stock' => array(
'type' => 'Literal',
'options' => array(
'route' => '/stock',
'defaults' => array(
'__NAMESPACE__' => 'PrStock\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]][/id/:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9a-zA-Z_-]*',
),
'defaults' => array(
'controller' => 'Index',
'action' => 'index',
'id' => 0,
),
),
),
),
),
),
),
?>
////////////////
In module.php onBootstrap of first route I add onDispatch listener and change some params of view and layout.
And fill some static propirties.
If I open http://subdomain.BASE_DOMAIN/ or http://subdomain.BASE_DOMAIN/about - all works
If I open http://subdomain.BASE_DOMAIN/stock - onDispatch in first module dont called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment