Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UrlRewrite.php
Go to the documentation of this file.
1 <?php
7 
9 {
13  const VERR_MANYSLASHES = 1;
14 
15  // Too many slashes in a row of request path, e.g. '///foo//'
16  const VERR_ANCHOR = 2;
17 
18  // Anchor is not supported in request path, e.g. 'foo#bar'
19 
29  protected function _validateRequestPath($requestPath)
30  {
31  if (strpos($requestPath, '//') !== false) {
32  throw new \Exception(
33  __('Do not use two or more consecutive slashes in the request path.'),
34  self::VERR_MANYSLASHES
35  );
36  }
37  if (strpos($requestPath, '#') !== false) {
38  throw new \Exception(__('Anchor symbol (#) is not supported in request path.'), self::VERR_ANCHOR);
39  }
40  return true;
41  }
42 
51  public function validateRequestPath($requestPath)
52  {
53  try {
54  $this->_validateRequestPath($requestPath);
55  } catch (\Exception $e) {
56  throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
57  }
58  return true;
59  }
60 
69  public function validateSuffix($suffix)
70  {
71  try {
72  // Suffix itself must be a valid request path
74  } catch (\Exception $e) {
75  // Make message saying about suffix, not request path
76  switch ($e->getCode()) {
78  throw new \Magento\Framework\Exception\LocalizedException(
79  __('Do not use two or more consecutive slashes in the url rewrite suffix.')
80  );
81  case self::VERR_ANCHOR:
82  throw new \Magento\Framework\Exception\LocalizedException(
83  __('Anchor symbol (#) is not supported in url rewrite suffix.')
84  );
85  }
86  }
87  return true;
88  }
89 }
$suffix
Definition: name.phtml:27
__()
Definition: __.php:13