| @@ 34-82 (lines=49) @@ | ||
| 31 | * |
|
| 32 | * @author MageTest team (https://github.com/MageTest/MageSpec/contributors) |
|
| 33 | */ |
|
| 34 | class BlockLocator extends AbstractResourceLocator implements ResourceLocatorInterface |
|
| 35 | { |
|
| 36 | /** |
|
| 37 | * @return int |
|
| 38 | */ |
|
| 39 | public function getPriority() |
|
| 40 | { |
|
| 41 | return 30; |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @param string $file |
|
| 46 | * @return bool |
|
| 47 | */ |
|
| 48 | protected function isSupported($file) |
|
| 49 | { |
|
| 50 | return strpos($file, 'Block') > 0; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @param array $parts |
|
| 55 | * @param ResourceLocatorInterface $locator |
|
| 56 | * @return BlockResource |
|
| 57 | * @throws \InvalidArgumentException |
|
| 58 | */ |
|
| 59 | protected function getResource(array $parts, ResourceLocatorInterface $locator) |
|
| 60 | { |
|
| 61 | if (!$locator instanceof BlockLocator) { |
|
| 62 | throw new \InvalidArgumentException('Block resource requires a block locator'); |
|
| 63 | } |
|
| 64 | return new BlockResource($parts, $locator); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @return string |
|
| 69 | */ |
|
| 70 | protected function getClassType() |
|
| 71 | { |
|
| 72 | return 'Block'; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return string |
|
| 77 | */ |
|
| 78 | protected function getValidator() |
|
| 79 | { |
|
| 80 | return '/^(block):([a-zA-Z0-9]+)_([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)(_[\w]+)?$/'; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| @@ 34-82 (lines=49) @@ | ||
| 31 | * |
|
| 32 | * @author MageTest team (https://github.com/MageTest/MageSpec/contributors) |
|
| 33 | */ |
|
| 34 | class HelperLocator extends AbstractResourceLocator implements ResourceLocatorInterface |
|
| 35 | { |
|
| 36 | /** |
|
| 37 | * @return int |
|
| 38 | */ |
|
| 39 | public function getPriority() |
|
| 40 | { |
|
| 41 | return 20; |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @param string $file |
|
| 46 | * @return bool |
|
| 47 | */ |
|
| 48 | protected function isSupported($file) |
|
| 49 | { |
|
| 50 | return strpos($file, 'Helper') > 0; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @param array $parts |
|
| 55 | * @param ResourceLocatorInterface $locator |
|
| 56 | * @return HelperResource |
|
| 57 | * @throws \InvalidArgumentException |
|
| 58 | */ |
|
| 59 | protected function getResource(array $parts, ResourceLocatorInterface $locator) |
|
| 60 | { |
|
| 61 | if (!$locator instanceof HelperLocator) { |
|
| 62 | throw new \InvalidArgumentException('Helper resource requires a helper locator'); |
|
| 63 | } |
|
| 64 | return new HelperResource($parts, $locator); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @return string |
|
| 69 | */ |
|
| 70 | protected function getClassType() |
|
| 71 | { |
|
| 72 | return 'Helper'; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return string |
|
| 77 | */ |
|
| 78 | protected function getValidator() |
|
| 79 | { |
|
| 80 | return '/^(helper):([a-zA-Z0-9]+)_([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)(_[\w]+)?$/'; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| @@ 36-84 (lines=49) @@ | ||
| 33 | * |
|
| 34 | * @author MageTest team (https://github.com/MageTest/MageSpec/contributors) |
|
| 35 | */ |
|
| 36 | class ModelLocator extends AbstractResourceLocator implements ResourceLocatorInterface |
|
| 37 | { |
|
| 38 | /** |
|
| 39 | * @return int |
|
| 40 | */ |
|
| 41 | public function getPriority() |
|
| 42 | { |
|
| 43 | return 40; |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @param string $file |
|
| 48 | * @return bool |
|
| 49 | */ |
|
| 50 | protected function isSupported($file) |
|
| 51 | { |
|
| 52 | return strpos($file, 'Model') > 0; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @param array $parts |
|
| 57 | * @param ResourceLocatorInterface $locator |
|
| 58 | * @return ModelResource |
|
| 59 | * @throws \InvalidArgumentException |
|
| 60 | */ |
|
| 61 | protected function getResource(array $parts, ResourceLocatorInterface $locator) |
|
| 62 | { |
|
| 63 | if (!$locator instanceof ModelLocator) { |
|
| 64 | throw new \InvalidArgumentException('Model resource requires a model locator'); |
|
| 65 | } |
|
| 66 | return new ModelResource($parts, $locator); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @return string |
|
| 71 | */ |
|
| 72 | protected function getClassType() |
|
| 73 | { |
|
| 74 | return 'Model'; |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * @return string |
|
| 79 | */ |
|
| 80 | protected function getValidator() |
|
| 81 | { |
|
| 82 | return '/^(model):([a-zA-Z0-9]+)_([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)(_[\w]+)?$/'; |
|
| 83 | } |
|
| 84 | } |
|
| 85 | ||