7

In Magento 2 routing, the system parses the URL segments into three sections

module-or-front/segment2/segment3

Which specific class file does this happen in?

Put another way, the request object has a getModuleName method that looks like this

public function getModuleName()
{
    return $this->module;
}

Where does Magento 2 get the string that ultimately sets the module property?

2
  • 1
    @AmitBera Not sure you understood the question -- how would an interface do anything? Commented Sep 21, 2015 at 20:02
  • sorry... @alam Storm.... misunderstood your question
    – Amit Bera
    Commented Sep 22, 2015 at 3:26

1 Answer 1

7

I think everything is set up in Magento\Framework\App\Router\Base::matchAction
The line you are looking for is $request->setModuleName($moduleFrontName); but I guess you wanted the full method.
This matchAction method is called by the match method from the same class that is called by Magento\Framework\App\FrontController::dispatch() ....and so on.

[EDIT]
not 100% sure, but I think the actuall splitting of the url is done in Zend\Uri\Uri::makeRelative()

$pathParts = preg_split('|(/)|', $this->getPath(), null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
1
  • I'm looking for the the spot the string in $moduleFrontName gets pulled from [probably $_GET]. Commented Sep 21, 2015 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.