<commit_before><?php
namespace luya\components;

use Yii;

class UrlRule extends \luya\base\UrlRule
{
    public function init()
    {
        // override previous UrlRule initializer
    }

    public function createUrl($manager, $route, $params)
    {
        return false;
    }

    public function parseRequest($manager, $request)
    {
        $parts = explode("/", $request->getPathInfo());

        preg_match_all('/<(\w+):?([^>]+)?>/', yii::$app->getModule('luya')->urlPrefixComposition, $matches, PREG_SET_ORDER);

        $compositionKeys = [];

        foreach ($matches as $index => $match) {
            if (isset($parts[$index])) {
                $urlValue = $parts[$index];
                $rgx = $match[2];
                $param = $match[1];
                preg_match("/^$rgx$/", $urlValue, $res);

                if (count($res) == 1) {
                    $compositionKeys[$param] = $urlValue;
                    unset($parts[$index]);
                }
            }
        }

        $request->setPathInfo(implode("/", $parts));

        $composition = new \luya\collection\PrefixComposition();
        $composition->set($compositionKeys);

        yii::$app->collection->composition = $composition;

        // set the yii app language param based on the composition fullUrl
        yii::$app->language = $composition->getFull();

        $parts = explode("/", $request->getPathInfo()); // can be deleted after reshuffle array

        if (!empty($parts) && !array_key_exists($parts[0], yii::$app->modules)) {
            $class = yii::$app->defaultRoute.'\components\UrlRule';
            $manager->addRules([['class' => $class]], false);

            return $manager->parseRequest($request);
        }

        return false;
    }
}<commit_msg>fixed bug where module does not have url rule class.<commit_after><?php
namespace luya\components;

use Yii;

class UrlRule extends \luya\base\UrlRule
{
    public function init()
    {
        // override previous UrlRule initializer
    }

    public function createUrl($manager, $route, $params)
    {
        return false;
    }

    public function parseRequest($manager, $request)
    {
        $parts = explode("/", $request->getPathInfo());

        preg_match_all('/<(\w+):?([^>]+)?>/', yii::$app->getModule('luya')->urlPrefixComposition, $matches, PREG_SET_ORDER);

        $compositionKeys = [];

        foreach ($matches as $index => $match) {
            if (isset($parts[$index])) {
                $urlValue = $parts[$index];
                $rgx = $match[2];
                $param = $match[1];
                preg_match("/^$rgx$/", $urlValue, $res);

                if (count($res) == 1) {
                    $compositionKeys[$param] = $urlValue;
                    unset($parts[$index]);
                }
            }
        }

        $request->setPathInfo(implode("/", $parts));

        $composition = new \luya\collection\PrefixComposition();
        $composition->set($compositionKeys);

        yii::$app->collection->composition = $composition;

        // set the yii app language param based on the composition fullUrl
        yii::$app->language = $composition->getFull();

        $parts = explode("/", $request->getPathInfo()); // can be deleted after reshuffle array

        if (!empty($parts) && !array_key_exists($parts[0], yii::$app->modules)) {
            $class = yii::$app->defaultRoute.'\components\UrlRule';
            
            if (!class_exists($class)) {
                return false;
            }
            $manager->addRules([['class' => $class]], false);

            return $manager->parseRequest($request);
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.1628222523744912, 'fraction_numerical': 0.002170963364993216, 'mean_word_length': 2.1184433164128595, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857187', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1019, 'n_words': 213}