public function mount($pattern, $mux, array $options = array())
    {
        // Save the mount path in options array
        $options['mount_path'] = $pattern;

        if ($mux instanceof Expandable) {

            $mux = $mux->expand($options);

        } else if ($mux instanceof Closure) {

            // we pass the newly created Mux object to the builder closure to initialize routes.
            if ($ret = $mux($mux = new Mux())) {
                if ($ret instanceof Mux) {
                    $mux = $ret;
                } else {
                    throw new LogicException('Invalid object returned from Closure.');
                }
            }
        } elseif ((!is_object($mux) || !($mux instanceof self)) && is_callable($mux)) {
            $mux($mux = new self());
        }

        // Save the constructed mux object in options array, so we can fetch
        // the expanded mux object in controller object later.
        $mux->setParent($this);
        $options['mux'] = $mux;


        if ($this->expand) {
            $pcre = strpos($pattern,':') !== false;

            // rewrite submux routes
            foreach ($mux->routes as $route) {
                // process for pcre
                if ($route[0] || $pcre) {
                    $newPattern = $pattern . ( $route[0] ? $route[3]['pattern'] : $route[1] );
                    $routeArgs = PatternCompiler::compile($newPattern, 
                        array_replace_recursive($options, $route[3]) );
                    $this->appendPCRERoute( $routeArgs, $route[2] );
                } else {
                    $this->routes[] = array(
                        false,
                        $pattern . $route[1],
                        $route[2],
                        isset($route[3]) ? array_replace_recursive($options, $route[3]) : $options,
                    );
                }
            }
        } else {

            $muxId = $mux->getId();
            $this->add($pattern, $muxId, $options);
            $this->submux[ $muxId ] = $mux;

        }
    }
public function mount($pattern, $mux, array $options = array())
    {
        // Save the mount path in options array
        $options['mount_path'] = $pattern;

        if ($mux instanceof Expandable) {

            $mux = $mux->expand($options);

        } else if ($mux instanceof Closure) {

            // we pass the newly created Mux object to the builder closure to initialize routes.
            if ($ret = $mux($mux = new Mux())) {
                if ($ret instanceof Mux) {
                    $mux = $ret;
                } else {
                    throw new LogicException('Invalid object returned from Closure.');
                }
            }
        } elseif ((!is_object($mux) || !($mux instanceof self)) && is_callable($mux)) {
            $mux($mux = new self());
        }

        // Save the constructed mux object in options array, so we can fetch
        // the expanded mux object in controller object later.
        $mux->setParent($this);
        $options['mux'] = $mux;


        if ($this->expand) {
            $pcre = strpos($pattern,':') !== false;

            // rewrite submux routes
            foreach ($mux->routes as $route) {
                // process for pcre
                if ($route[0] || $pcre) {
                    $newPattern = $pattern . ( $route[0] ? $route[3]['pattern'] : $route[1] );
                    $routeArgs = PatternCompiler::compile($newPattern, 
                        array_replace_recursive($options, $route[3]) );
                    $this->appendPCRERoute( $routeArgs, $route[2] );
                } else {
                    $this->routes[] = array(
                        false,
                        $pattern . $route[1],
                        $route[2],
                        isset($route[3]) ? array_replace_recursive($options, $route[3]) : $options,
                    );
                }
            }
        } else {

            $muxId = $mux->getId();
            $this->add($pattern, $muxId, $options);
            $this->submux[ $muxId ] = $mux;

        }
    }
public function mount ( $ pattern , $ mux , array $ options = array ( ) ) { // Save the mount path in options array $ options [ 'mount_path' ] = $ pattern ; if ( $ mux instanceof Expandable ) { $ mux = $ mux -> expand ( $ options ) ; } else if ( $ mux instanceof Closure ) { // we pass the newly created Mux object to the builder closure to initialize routes. if ( $ ret = $ mux ( $ mux = new Mux ( ) ) ) { if ( $ ret instanceof Mux ) { $ mux = $ ret ; } else { throw new LogicException ( 'Invalid object returned from Closure.' ) ; } } } elseif ( ( ! is_object ( $ mux ) || ! ( $ mux instanceof self ) ) && is_callable ( $ mux ) ) { $ mux ( $ mux = new self ( ) ) ; } // Save the constructed mux object in options array, so we can fetch // the expanded mux object in controller object later. $ mux -> setParent ( $ this ) ; $ options [ 'mux' ] = $ mux ; if ( $ this -> expand ) { $ pcre = strpos ( $ pattern , ':' ) !== false ; // rewrite submux routes foreach ( $ mux -> routes as $ route ) { // process for pcre if ( $ route [ 0 ] || $ pcre ) { $ newPattern = $ pattern . ( $ route [ 0 ] ? $ route [ 3 ] [ 'pattern' ] : $ route [ 1 ] ) ; $ routeArgs = PatternCompiler :: compile ( $ newPattern , array_replace_recursive ( $ options , $ route [ 3 ] ) ) ; $ this -> appendPCRERoute ( $ routeArgs , $ route [ 2 ] ) ; } else { $ this -> routes [ ] = array ( false , $ pattern . $ route [ 1 ] , $ route [ 2 ] , isset ( $ route [ 3 ] ) ? array_replace_recursive ( $ options , $ route [ 3 ] ) : $ options , ) ; } } } else { $ muxId = $ mux -> getId ( ) ; $ this -> add ( $ pattern , $ muxId , $ options ) ; $ this -> submux [ $ muxId ] = $ mux ; } }
Mount a Mux or a Controller object on a specific path.

@param string         $pattern
@param Mux|Controller $mux
@param array          $options
Mount a Mux or a Controller object on a specific path .