Neos\Neos\Routing\BackendModuleRoutePartHandler::matchValue PHP Method

matchValue() protected method

Iterate through the segments of the current request path find the corresponding module configuration and set controller & action accordingly
protected matchValue ( string $value ) : boolean | integer
$value string
return boolean | integer
    protected function matchValue($value)
    {
        $format = pathinfo($value, PATHINFO_EXTENSION);
        if ($format !== '') {
            $value = substr($value, 0, strlen($value) - strlen($format) - 1);
        }
        $segments = Arrays::trimExplode('/', $value);
        $currentModuleBase = $this->settings['modules'];
        if ($segments === array() || !isset($currentModuleBase[$segments[0]])) {
            return self::MATCHRESULT_NOSUCHMODULE;
        }
        $modulePath = array();
        $level = 0;
        $moduleConfiguration = null;
        $moduleController = null;
        $moduleAction = 'index';
        foreach ($segments as $segment) {
            if (isset($currentModuleBase[$segment])) {
                $modulePath[] = $segment;
                $moduleConfiguration = $currentModuleBase[$segment];
                if (isset($moduleConfiguration['controller'])) {
                    $moduleController = $moduleConfiguration['controller'];
                } else {
                    $moduleController = null;
                }
                if (isset($moduleConfiguration['submodules'])) {
                    $currentModuleBase = $moduleConfiguration['submodules'];
                } else {
                    $currentModuleBase = array();
                }
            } else {
                if ($level === count($segments) - 1) {
                    $moduleMethods = array_change_key_case(array_flip(get_class_methods($moduleController)), CASE_LOWER);
                    if (array_key_exists($segment . 'action', $moduleMethods)) {
                        $moduleAction = $segment;
                        break;
                    }
                }
                return self::MATCHRESULT_NOSUCHMODULE;
            }
            $level++;
        }
        if ($moduleController === null) {
            return self::MATCHRESULT_NOCONTROLLER;
        }
        $this->value = array('module' => implode('/', $modulePath), 'controller' => $moduleController, 'action' => $moduleAction);
        if ($format !== '') {
            $this->value['format'] = $format;
        }
        return self::MATCHRESULT_FOUND;
    }