PathInfoProcessor.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Prevents path info processing for admin store
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Backend\App\Request;
  9. /**
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface
  14. {
  15. /**
  16. * @var \Magento\Backend\Helper\Data
  17. */
  18. private $_helper;
  19. /**
  20. * @var \Magento\Store\App\Request\PathInfoProcessor
  21. */
  22. private $_subject;
  23. /**
  24. * @param \Magento\Store\App\Request\PathInfoProcessor $subject
  25. * @param \Magento\Backend\Helper\Data $helper
  26. */
  27. public function __construct(
  28. \Magento\Store\App\Request\PathInfoProcessor $subject,
  29. \Magento\Backend\Helper\Data $helper
  30. ) {
  31. $this->_helper = $helper;
  32. $this->_subject = $subject;
  33. }
  34. /**
  35. * Process path info
  36. *
  37. * @param \Magento\Framework\App\RequestInterface $request
  38. * @param string $pathInfo
  39. * @return string
  40. */
  41. public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
  42. {
  43. $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
  44. $firstPart = $pathParts[0];
  45. if ($firstPart != $this->_helper->getAreaFrontName()) {
  46. return $this->_subject->process($request, $pathInfo);
  47. }
  48. return $pathInfo;
  49. }
  50. }