Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PathPattern.php
Go to the documentation of this file.
1 <?php
7 
12 {
20  {
21  $pattern = str_replace(['\\?', '\\*'], ['[^/]', '[^/]*'], preg_quote($path));
24  return $pattern;
25  }
26 
39  protected function translateGroupsFromGlob($pattern)
40  {
41  preg_match_all('~\\\\\\{[^,\\}]+(?:,[^,\\}]*)*\\\\\\}~', $pattern, $matches, PREG_OFFSET_CAPTURE);
42  for ($index = count($matches[0]) - 1; $index >= 0; $index -= 1) {
43  list($match, $offset) = $matches[0][$index];
44  $replacement = substr_replace($match, '(?:', 0, 2);
45  $replacement = substr_replace($replacement, ')', -2);
46  $replacement = str_replace(',', '|', $replacement);
47  $pattern = substr_replace($pattern, $replacement, $offset, strlen($match));
48  }
49  return $pattern;
50  }
51 
66  {
67  preg_match_all('~\\\\\\[(\\\\\\!)?[^\\]]+\\\\\\]~i', $pattern, $matches, PREG_OFFSET_CAPTURE);
68  for ($index = count($matches[0]) - 1; $index >= 0; $index -= 1) {
69  list($match, $offset) = $matches[0][$index];
70  $exclude = !empty($matches[1][$index]);
71  $replacement = substr_replace($match, '[' . ($exclude ? '^' : ''), 0, $exclude ? 4 : 2);
72  $replacement = substr_replace($replacement, ']', -2);
73  $replacement = str_replace('\\-', '-', $replacement);
74  $pattern = substr_replace($pattern, $replacement, $offset, strlen($match));
75  }
76  return $pattern;
77  }
78 }
$pattern
Definition: website.php:22
$replacement
Definition: website.php:23
$index
Definition: list.phtml:44