protected function _parseAco($aco, $string = true)
    {
        $aco = preg_replace('/\/{2,}/', '/', trim($aco, '/'));
        $parts = explode('/', $aco);

        if (empty($parts)) {
            return false;
        }

        if (count($parts) === 1) {
            $controller = Inflector::camelize($parts[0]);

            return [
                'prefix' => '',
                'controller' => $controller,
                'action' => 'index',
            ];
        }

        $prefixes = $this->_routerPrefixes();
        $prefix = Inflector::camelize($parts[0]);
        if (!in_array($prefix, $prefixes)) {
            $prefix = '';
        } else {
            array_shift($parts);
        }

        if (count($parts) == 2) {
            list($controller, $action) = $parts;
        } else {
            $controller = array_shift($parts);
            $action = 'index';
        }

        $plugin = $this->_pluginName;
        $result = compact('plugin', 'prefix', 'controller', 'action');

        if ($string) {
            $result = implode('/', array_values($result));
            $result = str_replace('//', '/', $result);
        }

        return $result;
    }
protected function _parseAco($aco, $string = true)
    {
        $aco = preg_replace('/\/{2,}/', '/', trim($aco, '/'));
        $parts = explode('/', $aco);

        if (empty($parts)) {
            return false;
        }

        if (count($parts) === 1) {
            $controller = Inflector::camelize($parts[0]);

            return [
                'prefix' => '',
                'controller' => $controller,
                'action' => 'index',
            ];
        }

        $prefixes = $this->_routerPrefixes();
        $prefix = Inflector::camelize($parts[0]);
        if (!in_array($prefix, $prefixes)) {
            $prefix = '';
        } else {
            array_shift($parts);
        }

        if (count($parts) == 2) {
            list($controller, $action) = $parts;
        } else {
            $controller = array_shift($parts);
            $action = 'index';
        }

        $plugin = $this->_pluginName;
        $result = compact('plugin', 'prefix', 'controller', 'action');

        if ($string) {
            $result = implode('/', array_values($result));
            $result = str_replace('//', '/', $result);
        }

        return $result;
    }
protected function _parseAco ( $ aco , $ string = true ) { $ aco = preg_replace ( '/\/{2,}/' , '/' , trim ( $ aco , '/' ) ) ; $ parts = explode ( '/' , $ aco ) ; if ( empty ( $ parts ) ) { return false ; } if ( count ( $ parts ) === 1 ) { $ controller = Inflector :: camelize ( $ parts [ 0 ] ) ; return [ 'prefix' => '' , 'controller' => $ controller , 'action' => 'index' , ] ; } $ prefixes = $ this -> _routerPrefixes ( ) ; $ prefix = Inflector :: camelize ( $ parts [ 0 ] ) ; if ( ! in_array ( $ prefix , $ prefixes ) ) { $ prefix = '' ; } else { array_shift ( $ parts ) ; } if ( count ( $ parts ) == 2 ) { list ( $ controller , $ action ) = $ parts ; } else { $ controller = array_shift ( $ parts ) ; $ action = 'index' ; } $ plugin = $ this -> _pluginName ; $ result = compact ( 'plugin' , 'prefix' , 'controller' , 'action' ) ; if ( $ string ) { $ result = implode ( '/' , array_values ( $ result ) ) ; $ result = str_replace ( '//' , '/' , $ result ) ; } return $ result ; }
Sanitizes the given ACO path.

This methods can return an array with the following keys if `$string` option
is set to false:

- `plugin`: The name of the plugin being managed by this class.
- `prefix`: ACO prefix, for example `Admin` for controller within /Controller/Admin/
it may be empty, if not prefix is found.
- `controller`: Controller name. e.g.: `MySuperController`
- `action`: Controller's action. e.g.: `mini_action`, `index` by default

For example:

`Admin/Users/`

Returns:

- plugin: YourPlugin
- prefix: Admin
- controller: Users
- action: index

Where "YourPlugin" is the plugin name passed to this class's constructor.

@param string $aco An ACO path to parse
@param bool $string Indicates if it should return a string format path (/Controller/action)
@return bool|array|string An array as described above or false if an invalid $aco was given
Sanitizes the given ACO path .