@@ -56,7 +56,7 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public function render($uri, array $context = []) |
| 58 | 58 | { |
| 59 | - if (! is_readable($uri)) { |
|
| 59 | + if ( ! is_readable($uri)) { |
|
| 60 | 60 | throw new FailedToLoadViewException( |
| 61 | 61 | sprintf( |
| 62 | 62 | _('The View URI "%1$s" is not accessible or readable.'), |
@@ -25,73 +25,73 @@ |
||
| 25 | 25 | class PHPEngine extends AbstractEngine |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - const PHP_EXTENSION = '.php'; |
|
| 28 | + const PHP_EXTENSION = '.php'; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Check whether the Findable can handle an individual criterion. |
|
| 32 | - * |
|
| 33 | - * @since 0.1.0 |
|
| 34 | - * |
|
| 35 | - * @param mixed $criterion Criterion to check. |
|
| 36 | - * |
|
| 37 | - * @return bool Whether the Findable can handle the criterion. |
|
| 38 | - */ |
|
| 39 | - public function canHandle($criterion) |
|
| 40 | - { |
|
| 41 | - return $this->hasExtension($criterion, static::PHP_EXTENSION) |
|
| 42 | - && is_readable($criterion); |
|
| 43 | - } |
|
| 30 | + /** |
|
| 31 | + * Check whether the Findable can handle an individual criterion. |
|
| 32 | + * |
|
| 33 | + * @since 0.1.0 |
|
| 34 | + * |
|
| 35 | + * @param mixed $criterion Criterion to check. |
|
| 36 | + * |
|
| 37 | + * @return bool Whether the Findable can handle the criterion. |
|
| 38 | + */ |
|
| 39 | + public function canHandle($criterion) |
|
| 40 | + { |
|
| 41 | + return $this->hasExtension($criterion, static::PHP_EXTENSION) |
|
| 42 | + && is_readable($criterion); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Render a given URI. |
|
| 47 | - * |
|
| 48 | - * @since 0.1.0 |
|
| 49 | - * |
|
| 50 | - * @param string $uri URI to render. |
|
| 51 | - * @param array $context Context in which to render. |
|
| 52 | - * |
|
| 53 | - * @return string Rendered HTML. |
|
| 54 | - * @throws FailedToLoadViewException If the View URI is not accessible or readable. |
|
| 55 | - * @throws FailedToLoadViewException If the View URI could not be loaded. |
|
| 56 | - */ |
|
| 57 | - public function render($uri, array $context = []) |
|
| 58 | - { |
|
| 59 | - if (! is_readable($uri)) { |
|
| 60 | - throw new FailedToLoadViewException( |
|
| 61 | - sprintf( |
|
| 62 | - _('The View URI "%1$s" is not accessible or readable.'), |
|
| 63 | - $uri |
|
| 64 | - ) |
|
| 65 | - ); |
|
| 66 | - } |
|
| 45 | + /** |
|
| 46 | + * Render a given URI. |
|
| 47 | + * |
|
| 48 | + * @since 0.1.0 |
|
| 49 | + * |
|
| 50 | + * @param string $uri URI to render. |
|
| 51 | + * @param array $context Context in which to render. |
|
| 52 | + * |
|
| 53 | + * @return string Rendered HTML. |
|
| 54 | + * @throws FailedToLoadViewException If the View URI is not accessible or readable. |
|
| 55 | + * @throws FailedToLoadViewException If the View URI could not be loaded. |
|
| 56 | + */ |
|
| 57 | + public function render($uri, array $context = []) |
|
| 58 | + { |
|
| 59 | + if (! is_readable($uri)) { |
|
| 60 | + throw new FailedToLoadViewException( |
|
| 61 | + sprintf( |
|
| 62 | + _('The View URI "%1$s" is not accessible or readable.'), |
|
| 63 | + $uri |
|
| 64 | + ) |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - extract($context, EXTR_SKIP); |
|
| 68 | + extract($context, EXTR_SKIP); |
|
| 69 | 69 | |
| 70 | - // Save current buffering level so we can backtrack in case of an error. |
|
| 71 | - // This is needed because the view itself might also add an unknown number of output buffering levels. |
|
| 72 | - $bufferLevel = ob_get_level(); |
|
| 73 | - ob_start(); |
|
| 70 | + // Save current buffering level so we can backtrack in case of an error. |
|
| 71 | + // This is needed because the view itself might also add an unknown number of output buffering levels. |
|
| 72 | + $bufferLevel = ob_get_level(); |
|
| 73 | + ob_start(); |
|
| 74 | 74 | |
| 75 | - try { |
|
| 76 | - include($uri); |
|
| 77 | - } catch (Exception $exception) { |
|
| 75 | + try { |
|
| 76 | + include($uri); |
|
| 77 | + } catch (Exception $exception) { |
|
| 78 | 78 | |
| 79 | - // Remove whatever levels were added up until now. |
|
| 80 | - while (ob_get_level() > $bufferLevel) { |
|
| 81 | - ob_end_clean(); |
|
| 82 | - } |
|
| 79 | + // Remove whatever levels were added up until now. |
|
| 80 | + while (ob_get_level() > $bufferLevel) { |
|
| 81 | + ob_end_clean(); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - throw new FailedToLoadViewException( |
|
| 85 | - sprintf( |
|
| 86 | - _('Could not load the View URI "%1$s". Reason: "%2$s".'), |
|
| 87 | - $uri, |
|
| 88 | - $exception->getMessage() |
|
| 89 | - ), |
|
| 90 | - $exception->getCode(), |
|
| 91 | - $exception |
|
| 92 | - ); |
|
| 93 | - } |
|
| 84 | + throw new FailedToLoadViewException( |
|
| 85 | + sprintf( |
|
| 86 | + _('Could not load the View URI "%1$s". Reason: "%2$s".'), |
|
| 87 | + $uri, |
|
| 88 | + $exception->getMessage() |
|
| 89 | + ), |
|
| 90 | + $exception->getCode(), |
|
| 91 | + $exception |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - return ob_get_clean(); |
|
| 96 | - } |
|
| 95 | + return ob_get_clean(); |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | interface LocationInterface |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Get an URI that matches the given criteria. |
|
| 27 | - * |
|
| 28 | - * @since 0.1.0 |
|
| 29 | - * |
|
| 30 | - * @param array $criteria Criteria to match. |
|
| 31 | - * |
|
| 32 | - * @return string|false URI that matches the criteria or false if none found. |
|
| 33 | - */ |
|
| 34 | - public function getURI(array $criteria); |
|
| 25 | + /** |
|
| 26 | + * Get an URI that matches the given criteria. |
|
| 27 | + * |
|
| 28 | + * @since 0.1.0 |
|
| 29 | + * |
|
| 30 | + * @param array $criteria Criteria to match. |
|
| 31 | + * |
|
| 32 | + * @return string|false URI that matches the criteria or false if none found. |
|
| 33 | + */ |
|
| 34 | + public function getURI(array $criteria); |
|
| 35 | 35 | } |
@@ -226,7 +226,7 @@ |
||
| 226 | 226 | $type = $type($uri, $engine); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if (! $type instanceof ViewInterface) { |
|
| 229 | + if ( ! $type instanceof ViewInterface) { |
|
| 230 | 230 | throw new FailedToInstantiateViewException( |
| 231 | 231 | sprintf( |
| 232 | 232 | _('Could not instantiate view "%s".'), |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param string $uri URI to get a view for. |
| 126 | 126 | * @param EngineInterface $engine Engine to use for the view. |
| 127 | - * @param mixed $type Type of view to get. |
|
| 127 | + * @param string|null $type Type of view to get. |
|
| 128 | 128 | * |
| 129 | 129 | * @return ViewInterface View that matches the given requirements. |
| 130 | 130 | */ |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @since 0.1.0 |
| 190 | 190 | * |
| 191 | - * @param array $criteria Criteria to match. |
|
| 191 | + * @param string[] $criteria Criteria to match. |
|
| 192 | 192 | * |
| 193 | - * @return string|bool URI of the requested view, or false if not found. |
|
| 193 | + * @return string|false URI of the requested view, or false if not found. |
|
| 194 | 194 | */ |
| 195 | 195 | public function scanLocations(array $criteria) |
| 196 | 196 | { |
@@ -32,209 +32,209 @@ |
||
| 32 | 32 | class ViewBuilder |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - use ConfigTrait; |
|
| 36 | - |
|
| 37 | - const ENGINE_FINDER_KEY = 'EngineFinder'; |
|
| 38 | - const VIEW_FINDER_KEY = 'ViewFinder'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * ViewFinder instance. |
|
| 42 | - * |
|
| 43 | - * @since 0.1.0 |
|
| 44 | - * |
|
| 45 | - * @var ViewFinderInterface |
|
| 46 | - */ |
|
| 47 | - protected $viewFinder; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * EngineFinder instance. |
|
| 51 | - * |
|
| 52 | - * @since 0.1.0 |
|
| 53 | - * |
|
| 54 | - * @var EngineFinderInterface |
|
| 55 | - */ |
|
| 56 | - protected $engineFinder; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Locations to scan for views. |
|
| 60 | - * |
|
| 61 | - * @since 0.1.0 |
|
| 62 | - * |
|
| 63 | - * @var LocationInterface[] |
|
| 64 | - */ |
|
| 65 | - protected $locations; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Instantiate a ViewBuilder object. |
|
| 69 | - * |
|
| 70 | - * @since 0.1.0 |
|
| 71 | - * |
|
| 72 | - * @param ConfigInterface $config Configuration settings. |
|
| 73 | - * @param ViewFinderInterface|null $viewFinder ViewFinder instance. |
|
| 74 | - * @param EngineFinderInterface|null $engineFinder EngineFinder instance. |
|
| 75 | - * |
|
| 76 | - * @throws FailedToProcessConfigException If the config could not be processed. |
|
| 77 | - */ |
|
| 78 | - public function __construct( |
|
| 79 | - ConfigInterface $config, |
|
| 80 | - ViewFinderInterface $viewFinder = null, |
|
| 81 | - EngineFinderInterface $engineFinder = null |
|
| 82 | - ) { |
|
| 83 | - $this->processConfig($config); |
|
| 84 | - $this->viewFinder = $viewFinder; |
|
| 85 | - $this->engineFinder = $engineFinder; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Create a new view for a given URI. |
|
| 90 | - * |
|
| 91 | - * @since 0.1.0 |
|
| 92 | - * |
|
| 93 | - * @param string $view View identifier to create a view for. |
|
| 94 | - * @param string|null $type Type of view to create. |
|
| 95 | - * |
|
| 96 | - * @return ViewInterface Instance of the requested view. |
|
| 97 | - */ |
|
| 98 | - public function create($view, $type = null) |
|
| 99 | - { |
|
| 100 | - $uri = $this->scanLocations([$view]); |
|
| 101 | - $engine = $this->getEngine($uri); |
|
| 102 | - |
|
| 103 | - return $this->getView($uri, $engine, $type); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Get an Engine that can deal with the given URI. |
|
| 108 | - * |
|
| 109 | - * @since 0.1.0 |
|
| 110 | - * |
|
| 111 | - * @param string|false $uri URI to get an engine for. |
|
| 112 | - * |
|
| 113 | - * @return EngineInterface Instance of an engine that can deal with the given URI. |
|
| 114 | - */ |
|
| 115 | - public function getEngine($uri) |
|
| 116 | - { |
|
| 117 | - return $this->getEngineFinder()->find([$uri]); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Get a view for a given URI, engine and type. |
|
| 122 | - * |
|
| 123 | - * @since 0.1.0 |
|
| 124 | - * |
|
| 125 | - * @param string $uri URI to get a view for. |
|
| 126 | - * @param EngineInterface $engine Engine to use for the view. |
|
| 127 | - * @param mixed $type Type of view to get. |
|
| 128 | - * |
|
| 129 | - * @return ViewInterface View that matches the given requirements. |
|
| 130 | - */ |
|
| 131 | - public function getView($uri, EngineInterface $engine, $type = null) |
|
| 132 | - { |
|
| 133 | - if (null === $type) { |
|
| 134 | - return $this->getViewFinder()->find([$uri], $engine); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $this->resolveType($type, $uri, $engine); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Get the ViewFinder instance. |
|
| 142 | - * |
|
| 143 | - * @since 0.1.0 |
|
| 144 | - * |
|
| 145 | - * @return ViewFinderInterface Instance of a ViewFinder. |
|
| 146 | - */ |
|
| 147 | - public function getViewFinder() |
|
| 148 | - { |
|
| 149 | - if (null === $this->viewFinder) { |
|
| 150 | - $viewFinderClass = $this->config->getKey(static::VIEW_FINDER_KEY, 'ClassName'); |
|
| 151 | - $this->viewFinder = new $viewFinderClass($this->config->getSubConfig(static::VIEW_FINDER_KEY)); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $this->viewFinder; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Get the EngineFinder instance. |
|
| 159 | - * |
|
| 160 | - * @since 0.1.0 |
|
| 161 | - * |
|
| 162 | - * @return EngineFinderInterface Instance of a EngineFinder. |
|
| 163 | - */ |
|
| 164 | - public function getEngineFinder() |
|
| 165 | - { |
|
| 166 | - if (null === $this->engineFinder) { |
|
| 167 | - $engineFinderClass = $this->config->getKey(static::ENGINE_FINDER_KEY, 'ClassName'); |
|
| 168 | - $this->engineFinder = new $engineFinderClass($this->config->getSubConfig(static::ENGINE_FINDER_KEY)); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - return $this->engineFinder; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Add a location to scan with the ViewFinder. |
|
| 176 | - * |
|
| 177 | - * @since 0.1.0 |
|
| 178 | - * |
|
| 179 | - * @param LocationInterface $location Location to scan with the ViewFinder. |
|
| 180 | - */ |
|
| 181 | - public function addLocation(LocationInterface $location) |
|
| 182 | - { |
|
| 183 | - $this->locations[] = $location; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Scan Locations for an URI that matches the specified criteria. |
|
| 188 | - * |
|
| 189 | - * @since 0.1.0 |
|
| 190 | - * |
|
| 191 | - * @param array $criteria Criteria to match. |
|
| 192 | - * |
|
| 193 | - * @return string|bool URI of the requested view, or false if not found. |
|
| 194 | - */ |
|
| 195 | - public function scanLocations(array $criteria) |
|
| 196 | - { |
|
| 197 | - /** @var LocationInterface $location */ |
|
| 198 | - foreach ($this->locations as $location) { |
|
| 199 | - if ($uri = $location->getURI($criteria)) { |
|
| 200 | - return $uri; |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - return false; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Resolve the view type. |
|
| 209 | - * |
|
| 210 | - * @since 0.1.0 |
|
| 211 | - * |
|
| 212 | - * @param mixed $type Type of view that was requested. |
|
| 213 | - * @param string $uri URI to get a view for. |
|
| 214 | - * @param EngineInterface $engine Engine to use for the view. |
|
| 215 | - * |
|
| 216 | - * @return ViewInterface Resolved View object. |
|
| 217 | - * @throws FailedToInstantiateViewException If the view type could not be resolved. |
|
| 218 | - */ |
|
| 219 | - protected function resolveType($type, $uri, EngineInterface $engine = null) |
|
| 220 | - { |
|
| 221 | - if (is_string($type) && $this->config->hasKey(static::VIEW_FINDER_KEY)) { |
|
| 222 | - $type = new $type($uri, $engine); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if (is_callable($type)) { |
|
| 226 | - $type = $type($uri, $engine); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if (! $type instanceof ViewInterface) { |
|
| 230 | - throw new FailedToInstantiateViewException( |
|
| 231 | - sprintf( |
|
| 232 | - _('Could not instantiate view "%s".'), |
|
| 233 | - serialize($type) |
|
| 234 | - ) |
|
| 235 | - ); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - return $type; |
|
| 239 | - } |
|
| 35 | + use ConfigTrait; |
|
| 36 | + |
|
| 37 | + const ENGINE_FINDER_KEY = 'EngineFinder'; |
|
| 38 | + const VIEW_FINDER_KEY = 'ViewFinder'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * ViewFinder instance. |
|
| 42 | + * |
|
| 43 | + * @since 0.1.0 |
|
| 44 | + * |
|
| 45 | + * @var ViewFinderInterface |
|
| 46 | + */ |
|
| 47 | + protected $viewFinder; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * EngineFinder instance. |
|
| 51 | + * |
|
| 52 | + * @since 0.1.0 |
|
| 53 | + * |
|
| 54 | + * @var EngineFinderInterface |
|
| 55 | + */ |
|
| 56 | + protected $engineFinder; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Locations to scan for views. |
|
| 60 | + * |
|
| 61 | + * @since 0.1.0 |
|
| 62 | + * |
|
| 63 | + * @var LocationInterface[] |
|
| 64 | + */ |
|
| 65 | + protected $locations; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Instantiate a ViewBuilder object. |
|
| 69 | + * |
|
| 70 | + * @since 0.1.0 |
|
| 71 | + * |
|
| 72 | + * @param ConfigInterface $config Configuration settings. |
|
| 73 | + * @param ViewFinderInterface|null $viewFinder ViewFinder instance. |
|
| 74 | + * @param EngineFinderInterface|null $engineFinder EngineFinder instance. |
|
| 75 | + * |
|
| 76 | + * @throws FailedToProcessConfigException If the config could not be processed. |
|
| 77 | + */ |
|
| 78 | + public function __construct( |
|
| 79 | + ConfigInterface $config, |
|
| 80 | + ViewFinderInterface $viewFinder = null, |
|
| 81 | + EngineFinderInterface $engineFinder = null |
|
| 82 | + ) { |
|
| 83 | + $this->processConfig($config); |
|
| 84 | + $this->viewFinder = $viewFinder; |
|
| 85 | + $this->engineFinder = $engineFinder; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Create a new view for a given URI. |
|
| 90 | + * |
|
| 91 | + * @since 0.1.0 |
|
| 92 | + * |
|
| 93 | + * @param string $view View identifier to create a view for. |
|
| 94 | + * @param string|null $type Type of view to create. |
|
| 95 | + * |
|
| 96 | + * @return ViewInterface Instance of the requested view. |
|
| 97 | + */ |
|
| 98 | + public function create($view, $type = null) |
|
| 99 | + { |
|
| 100 | + $uri = $this->scanLocations([$view]); |
|
| 101 | + $engine = $this->getEngine($uri); |
|
| 102 | + |
|
| 103 | + return $this->getView($uri, $engine, $type); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Get an Engine that can deal with the given URI. |
|
| 108 | + * |
|
| 109 | + * @since 0.1.0 |
|
| 110 | + * |
|
| 111 | + * @param string|false $uri URI to get an engine for. |
|
| 112 | + * |
|
| 113 | + * @return EngineInterface Instance of an engine that can deal with the given URI. |
|
| 114 | + */ |
|
| 115 | + public function getEngine($uri) |
|
| 116 | + { |
|
| 117 | + return $this->getEngineFinder()->find([$uri]); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Get a view for a given URI, engine and type. |
|
| 122 | + * |
|
| 123 | + * @since 0.1.0 |
|
| 124 | + * |
|
| 125 | + * @param string $uri URI to get a view for. |
|
| 126 | + * @param EngineInterface $engine Engine to use for the view. |
|
| 127 | + * @param mixed $type Type of view to get. |
|
| 128 | + * |
|
| 129 | + * @return ViewInterface View that matches the given requirements. |
|
| 130 | + */ |
|
| 131 | + public function getView($uri, EngineInterface $engine, $type = null) |
|
| 132 | + { |
|
| 133 | + if (null === $type) { |
|
| 134 | + return $this->getViewFinder()->find([$uri], $engine); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + return $this->resolveType($type, $uri, $engine); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Get the ViewFinder instance. |
|
| 142 | + * |
|
| 143 | + * @since 0.1.0 |
|
| 144 | + * |
|
| 145 | + * @return ViewFinderInterface Instance of a ViewFinder. |
|
| 146 | + */ |
|
| 147 | + public function getViewFinder() |
|
| 148 | + { |
|
| 149 | + if (null === $this->viewFinder) { |
|
| 150 | + $viewFinderClass = $this->config->getKey(static::VIEW_FINDER_KEY, 'ClassName'); |
|
| 151 | + $this->viewFinder = new $viewFinderClass($this->config->getSubConfig(static::VIEW_FINDER_KEY)); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $this->viewFinder; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Get the EngineFinder instance. |
|
| 159 | + * |
|
| 160 | + * @since 0.1.0 |
|
| 161 | + * |
|
| 162 | + * @return EngineFinderInterface Instance of a EngineFinder. |
|
| 163 | + */ |
|
| 164 | + public function getEngineFinder() |
|
| 165 | + { |
|
| 166 | + if (null === $this->engineFinder) { |
|
| 167 | + $engineFinderClass = $this->config->getKey(static::ENGINE_FINDER_KEY, 'ClassName'); |
|
| 168 | + $this->engineFinder = new $engineFinderClass($this->config->getSubConfig(static::ENGINE_FINDER_KEY)); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + return $this->engineFinder; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Add a location to scan with the ViewFinder. |
|
| 176 | + * |
|
| 177 | + * @since 0.1.0 |
|
| 178 | + * |
|
| 179 | + * @param LocationInterface $location Location to scan with the ViewFinder. |
|
| 180 | + */ |
|
| 181 | + public function addLocation(LocationInterface $location) |
|
| 182 | + { |
|
| 183 | + $this->locations[] = $location; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Scan Locations for an URI that matches the specified criteria. |
|
| 188 | + * |
|
| 189 | + * @since 0.1.0 |
|
| 190 | + * |
|
| 191 | + * @param array $criteria Criteria to match. |
|
| 192 | + * |
|
| 193 | + * @return string|bool URI of the requested view, or false if not found. |
|
| 194 | + */ |
|
| 195 | + public function scanLocations(array $criteria) |
|
| 196 | + { |
|
| 197 | + /** @var LocationInterface $location */ |
|
| 198 | + foreach ($this->locations as $location) { |
|
| 199 | + if ($uri = $location->getURI($criteria)) { |
|
| 200 | + return $uri; |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + return false; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Resolve the view type. |
|
| 209 | + * |
|
| 210 | + * @since 0.1.0 |
|
| 211 | + * |
|
| 212 | + * @param mixed $type Type of view that was requested. |
|
| 213 | + * @param string $uri URI to get a view for. |
|
| 214 | + * @param EngineInterface $engine Engine to use for the view. |
|
| 215 | + * |
|
| 216 | + * @return ViewInterface Resolved View object. |
|
| 217 | + * @throws FailedToInstantiateViewException If the view type could not be resolved. |
|
| 218 | + */ |
|
| 219 | + protected function resolveType($type, $uri, EngineInterface $engine = null) |
|
| 220 | + { |
|
| 221 | + if (is_string($type) && $this->config->hasKey(static::VIEW_FINDER_KEY)) { |
|
| 222 | + $type = new $type($uri, $engine); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if (is_callable($type)) { |
|
| 226 | + $type = $type($uri, $engine); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if (! $type instanceof ViewInterface) { |
|
| 230 | + throw new FailedToInstantiateViewException( |
|
| 231 | + sprintf( |
|
| 232 | + _('Could not instantiate view "%s".'), |
|
| 233 | + serialize($type) |
|
| 234 | + ) |
|
| 235 | + ); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + return $type; |
|
| 239 | + } |
|
| 240 | 240 | } |
@@ -22,15 +22,15 @@ |
||
| 22 | 22 | interface EngineInterface |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Render a given URI. |
|
| 27 | - * |
|
| 28 | - * @since 0.1.0 |
|
| 29 | - * |
|
| 30 | - * @param string $uri URI to render. |
|
| 31 | - * @param array $context Context in which to render. |
|
| 32 | - * |
|
| 33 | - * @return string Rendered HTML. |
|
| 34 | - */ |
|
| 35 | - public function render($uri, array $context = []); |
|
| 25 | + /** |
|
| 26 | + * Render a given URI. |
|
| 27 | + * |
|
| 28 | + * @since 0.1.0 |
|
| 29 | + * |
|
| 30 | + * @param string $uri URI to render. |
|
| 31 | + * @param array $context Context in which to render. |
|
| 32 | + * |
|
| 33 | + * @return string Rendered HTML. |
|
| 34 | + */ |
|
| 35 | + public function render($uri, array $context = []); |
|
| 36 | 36 | } |
@@ -22,17 +22,17 @@ |
||
| 22 | 22 | class BaseView extends AbstractView |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Check whether the Findable can handle an individual criterion. |
|
| 27 | - * |
|
| 28 | - * @since 0.1.0 |
|
| 29 | - * |
|
| 30 | - * @param mixed $criterion Criterion to check. |
|
| 31 | - * |
|
| 32 | - * @return bool Whether the Findable can handle the criterion. |
|
| 33 | - */ |
|
| 34 | - public function canHandle($criterion) |
|
| 35 | - { |
|
| 36 | - return true; |
|
| 37 | - } |
|
| 25 | + /** |
|
| 26 | + * Check whether the Findable can handle an individual criterion. |
|
| 27 | + * |
|
| 28 | + * @since 0.1.0 |
|
| 29 | + * |
|
| 30 | + * @param mixed $criterion Criterion to check. |
|
| 31 | + * |
|
| 32 | + * @return bool Whether the Findable can handle the criterion. |
|
| 33 | + */ |
|
| 34 | + public function canHandle($criterion) |
|
| 35 | + { |
|
| 36 | + return true; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | interface Findable |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Check whether the Findable can handle an individual criterion. |
|
| 27 | - * |
|
| 28 | - * @since 0.1.0 |
|
| 29 | - * |
|
| 30 | - * @param mixed $criterion Criterion to check. |
|
| 31 | - * |
|
| 32 | - * @return bool Whether the Findable can handle the criterion. |
|
| 33 | - */ |
|
| 34 | - public function canHandle($criterion); |
|
| 25 | + /** |
|
| 26 | + * Check whether the Findable can handle an individual criterion. |
|
| 27 | + * |
|
| 28 | + * @since 0.1.0 |
|
| 29 | + * |
|
| 30 | + * @param mixed $criterion Criterion to check. |
|
| 31 | + * |
|
| 32 | + * @return bool Whether the Findable can handle the criterion. |
|
| 33 | + */ |
|
| 34 | + public function canHandle($criterion); |
|
| 35 | 35 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @since 0.1.0 |
| 73 | 73 | * |
| 74 | - * @param mixed $engine Engine to instantiate. |
|
| 74 | + * @param \BrightNucleus\View\Support\Findable $engine Engine to instantiate. |
|
| 75 | 75 | * |
| 76 | 76 | * @return EngineInterface Instantiated engine. |
| 77 | 77 | * @throws FailedToInstantiateEngineException If the engine could not be instantiated. |
@@ -25,88 +25,88 @@ |
||
| 25 | 25 | class EngineFinder extends AbstractFinder |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Find a result based on a specific criteria. |
|
| 30 | - * |
|
| 31 | - * @since 0.1.0 |
|
| 32 | - * |
|
| 33 | - * @param array $criteria Criteria to search for. |
|
| 34 | - * |
|
| 35 | - * @return mixed Result of the search. |
|
| 36 | - */ |
|
| 37 | - public function find(array $criteria) |
|
| 38 | - { |
|
| 39 | - $this->initializeEngines(); |
|
| 28 | + /** |
|
| 29 | + * Find a result based on a specific criteria. |
|
| 30 | + * |
|
| 31 | + * @since 0.1.0 |
|
| 32 | + * |
|
| 33 | + * @param array $criteria Criteria to search for. |
|
| 34 | + * |
|
| 35 | + * @return mixed Result of the search. |
|
| 36 | + */ |
|
| 37 | + public function find(array $criteria) |
|
| 38 | + { |
|
| 39 | + $this->initializeEngines(); |
|
| 40 | 40 | |
| 41 | - foreach ($criteria as $entry) { |
|
| 42 | - foreach ($this->findables as $engine) { |
|
| 43 | - if ($engine->canHandle($entry)) { |
|
| 44 | - return $engine; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 41 | + foreach ($criteria as $entry) { |
|
| 42 | + foreach ($this->findables as $engine) { |
|
| 43 | + if ($engine->canHandle($entry)) { |
|
| 44 | + return $engine; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $this->nullObject; |
|
| 50 | - } |
|
| 49 | + return $this->nullObject; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Initialize the engines that can be iterated. |
|
| 54 | - * |
|
| 55 | - * @since 0.1.0 |
|
| 56 | - * |
|
| 57 | - */ |
|
| 58 | - protected function initializeEngines() |
|
| 59 | - { |
|
| 60 | - foreach ($this->findables as &$engine) { |
|
| 61 | - $engine = $this->initializeEngine($engine); |
|
| 62 | - } |
|
| 52 | + /** |
|
| 53 | + * Initialize the engines that can be iterated. |
|
| 54 | + * |
|
| 55 | + * @since 0.1.0 |
|
| 56 | + * |
|
| 57 | + */ |
|
| 58 | + protected function initializeEngines() |
|
| 59 | + { |
|
| 60 | + foreach ($this->findables as &$engine) { |
|
| 61 | + $engine = $this->initializeEngine($engine); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if (! is_object($this->nullObject)) { |
|
| 65 | - $this->nullObject = new $this->nullObject(); |
|
| 66 | - } |
|
| 67 | - } |
|
| 64 | + if (! is_object($this->nullObject)) { |
|
| 65 | + $this->nullObject = new $this->nullObject(); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Initialize a single engine by instantiating class name strings and calling closures. |
|
| 71 | - * |
|
| 72 | - * @since 0.1.0 |
|
| 73 | - * |
|
| 74 | - * @param mixed $engine Engine to instantiate. |
|
| 75 | - * |
|
| 76 | - * @return EngineInterface Instantiated engine. |
|
| 77 | - * @throws FailedToInstantiateEngineException If the engine could not be instantiated. |
|
| 78 | - */ |
|
| 79 | - protected function initializeEngine($engine) |
|
| 80 | - { |
|
| 81 | - if (is_string($engine)) { |
|
| 82 | - $engine = new $engine(); |
|
| 83 | - } |
|
| 69 | + /** |
|
| 70 | + * Initialize a single engine by instantiating class name strings and calling closures. |
|
| 71 | + * |
|
| 72 | + * @since 0.1.0 |
|
| 73 | + * |
|
| 74 | + * @param mixed $engine Engine to instantiate. |
|
| 75 | + * |
|
| 76 | + * @return EngineInterface Instantiated engine. |
|
| 77 | + * @throws FailedToInstantiateEngineException If the engine could not be instantiated. |
|
| 78 | + */ |
|
| 79 | + protected function initializeEngine($engine) |
|
| 80 | + { |
|
| 81 | + if (is_string($engine)) { |
|
| 82 | + $engine = new $engine(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if (is_callable($engine)) { |
|
| 86 | - $engine = $engine(); |
|
| 87 | - } |
|
| 85 | + if (is_callable($engine)) { |
|
| 86 | + $engine = $engine(); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - if (! $engine instanceof EngineInterface) { |
|
| 90 | - throw new FailedToInstantiateEngineException( |
|
| 91 | - sprintf( |
|
| 92 | - _('Could not instantiate engine "%s".'), |
|
| 93 | - serialize($engine) |
|
| 94 | - ) |
|
| 95 | - ); |
|
| 96 | - } |
|
| 89 | + if (! $engine instanceof EngineInterface) { |
|
| 90 | + throw new FailedToInstantiateEngineException( |
|
| 91 | + sprintf( |
|
| 92 | + _('Could not instantiate engine "%s".'), |
|
| 93 | + serialize($engine) |
|
| 94 | + ) |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return $engine; |
|
| 99 | - } |
|
| 98 | + return $engine; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Get the config key for the Findables definitions. |
|
| 103 | - * |
|
| 104 | - * @since 0.1.0 |
|
| 105 | - * |
|
| 106 | - * @return string Config key use to define the Findables. |
|
| 107 | - */ |
|
| 108 | - protected function getFindablesConfigKey() |
|
| 109 | - { |
|
| 110 | - return 'Engines'; |
|
| 111 | - } |
|
| 101 | + /** |
|
| 102 | + * Get the config key for the Findables definitions. |
|
| 103 | + * |
|
| 104 | + * @since 0.1.0 |
|
| 105 | + * |
|
| 106 | + * @return string Config key use to define the Findables. |
|
| 107 | + */ |
|
| 108 | + protected function getFindablesConfigKey() |
|
| 109 | + { |
|
| 110 | + return 'Engines'; |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $engine = $this->initializeEngine($engine); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if (! is_object($this->nullObject)) { |
|
| 64 | + if ( ! is_object($this->nullObject)) { |
|
| 65 | 65 | $this->nullObject = new $this->nullObject(); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $engine = $engine(); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (! $engine instanceof EngineInterface) { |
|
| 89 | + if ( ! $engine instanceof EngineInterface) { |
|
| 90 | 90 | throw new FailedToInstantiateEngineException( |
| 91 | 91 | sprintf( |
| 92 | 92 | _('Could not instantiate engine "%s".'), |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | * |
| 78 | 78 | * @since 0.1.0 |
| 79 | 79 | * |
| 80 | - * @param mixed $view View to instantiate. |
|
| 80 | + * @param \BrightNucleus\View\Support\Findable $view View to instantiate. |
|
| 81 | 81 | * @param string $uri URI to use for the view. |
| 82 | 82 | * @param EngineInterface $engine Optional. Engine to use with the view. |
| 83 | 83 | * |
@@ -26,95 +26,95 @@ |
||
| 26 | 26 | class ViewFinder extends AbstractFinder |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Find a result based on a specific criteria. |
|
| 31 | - * |
|
| 32 | - * @since 0.1.0 |
|
| 33 | - * |
|
| 34 | - * @param array $criteria Criteria to search for. |
|
| 35 | - * @param EngineInterface $engine Optional. Engine to use with the view. |
|
| 36 | - * |
|
| 37 | - * @return ViewInterface View that was found. |
|
| 38 | - */ |
|
| 39 | - public function find(array $criteria, EngineInterface $engine = null) |
|
| 40 | - { |
|
| 41 | - $uri = $criteria[0]; |
|
| 29 | + /** |
|
| 30 | + * Find a result based on a specific criteria. |
|
| 31 | + * |
|
| 32 | + * @since 0.1.0 |
|
| 33 | + * |
|
| 34 | + * @param array $criteria Criteria to search for. |
|
| 35 | + * @param EngineInterface $engine Optional. Engine to use with the view. |
|
| 36 | + * |
|
| 37 | + * @return ViewInterface View that was found. |
|
| 38 | + */ |
|
| 39 | + public function find(array $criteria, EngineInterface $engine = null) |
|
| 40 | + { |
|
| 41 | + $uri = $criteria[0]; |
|
| 42 | 42 | |
| 43 | - $this->initializeViews($uri, $engine); |
|
| 43 | + $this->initializeViews($uri, $engine); |
|
| 44 | 44 | |
| 45 | - foreach ($criteria as $entry) { |
|
| 46 | - foreach ($this->findables as $viewObject) { |
|
| 47 | - if ($viewObject->canHandle($entry)) { |
|
| 48 | - return $viewObject; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - } |
|
| 45 | + foreach ($criteria as $entry) { |
|
| 46 | + foreach ($this->findables as $viewObject) { |
|
| 47 | + if ($viewObject->canHandle($entry)) { |
|
| 48 | + return $viewObject; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $this->nullObject; |
|
| 54 | - } |
|
| 53 | + return $this->nullObject; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Initialize the views that can be iterated. |
|
| 58 | - * |
|
| 59 | - * @since 0.1.0 |
|
| 60 | - * |
|
| 61 | - * @param string $uri URI to use for the view. |
|
| 62 | - * @param EngineInterface $engine Optional. Engine to use with the view. |
|
| 63 | - */ |
|
| 64 | - protected function initializeViews($uri, EngineInterface $engine = null) |
|
| 65 | - { |
|
| 66 | - foreach ($this->findables as &$view) { |
|
| 67 | - $view = $this->initializeView($view, $uri, $engine); |
|
| 68 | - } |
|
| 56 | + /** |
|
| 57 | + * Initialize the views that can be iterated. |
|
| 58 | + * |
|
| 59 | + * @since 0.1.0 |
|
| 60 | + * |
|
| 61 | + * @param string $uri URI to use for the view. |
|
| 62 | + * @param EngineInterface $engine Optional. Engine to use with the view. |
|
| 63 | + */ |
|
| 64 | + protected function initializeViews($uri, EngineInterface $engine = null) |
|
| 65 | + { |
|
| 66 | + foreach ($this->findables as &$view) { |
|
| 67 | + $view = $this->initializeView($view, $uri, $engine); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if (! is_object($this->nullObject)) { |
|
| 71 | - $this->nullObject = new $this->nullObject(); |
|
| 72 | - } |
|
| 73 | - } |
|
| 70 | + if (! is_object($this->nullObject)) { |
|
| 71 | + $this->nullObject = new $this->nullObject(); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Initialize a single view by instantiating class name strings and calling closures. |
|
| 77 | - * |
|
| 78 | - * @since 0.1.0 |
|
| 79 | - * |
|
| 80 | - * @param mixed $view View to instantiate. |
|
| 81 | - * @param string $uri URI to use for the view. |
|
| 82 | - * @param EngineInterface $engine Optional. Engine to use with the view. |
|
| 83 | - * |
|
| 84 | - * @return ViewInterface Instantiated view. |
|
| 85 | - * @throws FailedToInstantiateViewException If the view could not be instantiated. |
|
| 86 | - */ |
|
| 87 | - protected function initializeView($view, $uri, EngineInterface $engine = null) |
|
| 88 | - { |
|
| 89 | - if (is_string($view)) { |
|
| 90 | - $view = new $view($uri, $engine); |
|
| 91 | - } |
|
| 75 | + /** |
|
| 76 | + * Initialize a single view by instantiating class name strings and calling closures. |
|
| 77 | + * |
|
| 78 | + * @since 0.1.0 |
|
| 79 | + * |
|
| 80 | + * @param mixed $view View to instantiate. |
|
| 81 | + * @param string $uri URI to use for the view. |
|
| 82 | + * @param EngineInterface $engine Optional. Engine to use with the view. |
|
| 83 | + * |
|
| 84 | + * @return ViewInterface Instantiated view. |
|
| 85 | + * @throws FailedToInstantiateViewException If the view could not be instantiated. |
|
| 86 | + */ |
|
| 87 | + protected function initializeView($view, $uri, EngineInterface $engine = null) |
|
| 88 | + { |
|
| 89 | + if (is_string($view)) { |
|
| 90 | + $view = new $view($uri, $engine); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if (is_callable($view)) { |
|
| 94 | - $view = $view($uri, $engine); |
|
| 95 | - } |
|
| 93 | + if (is_callable($view)) { |
|
| 94 | + $view = $view($uri, $engine); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - if (! $view instanceof ViewInterface) { |
|
| 98 | - throw new FailedToInstantiateViewException( |
|
| 99 | - sprintf( |
|
| 100 | - _('Could not instantiate view "%s".'), |
|
| 101 | - serialize($view) |
|
| 102 | - ) |
|
| 103 | - ); |
|
| 104 | - } |
|
| 97 | + if (! $view instanceof ViewInterface) { |
|
| 98 | + throw new FailedToInstantiateViewException( |
|
| 99 | + sprintf( |
|
| 100 | + _('Could not instantiate view "%s".'), |
|
| 101 | + serialize($view) |
|
| 102 | + ) |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - return $view; |
|
| 107 | - } |
|
| 106 | + return $view; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Get the config key for the Findables definitions. |
|
| 111 | - * |
|
| 112 | - * @since 0.1.0 |
|
| 113 | - * |
|
| 114 | - * @return string Config key use to define the Findables. |
|
| 115 | - */ |
|
| 116 | - protected function getFindablesConfigKey() |
|
| 117 | - { |
|
| 118 | - return 'Views'; |
|
| 119 | - } |
|
| 109 | + /** |
|
| 110 | + * Get the config key for the Findables definitions. |
|
| 111 | + * |
|
| 112 | + * @since 0.1.0 |
|
| 113 | + * |
|
| 114 | + * @return string Config key use to define the Findables. |
|
| 115 | + */ |
|
| 116 | + protected function getFindablesConfigKey() |
|
| 117 | + { |
|
| 118 | + return 'Views'; |
|
| 119 | + } |
|
| 120 | 120 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $view = $this->initializeView($view, $uri, $engine); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (! is_object($this->nullObject)) { |
|
| 70 | + if ( ! is_object($this->nullObject)) { |
|
| 71 | 71 | $this->nullObject = new $this->nullObject(); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $view = $view($uri, $engine); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if (! $view instanceof ViewInterface) { |
|
| 97 | + if ( ! $view instanceof ViewInterface) { |
|
| 98 | 98 | throw new FailedToInstantiateViewException( |
| 99 | 99 | sprintf( |
| 100 | 100 | _('Could not instantiate view "%s".'), |
@@ -24,32 +24,32 @@ |
||
| 24 | 24 | class NullEngine implements EngineInterface, NullObject |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Check whether the Findable can handle an individual criterion. |
|
| 29 | - * |
|
| 30 | - * @since 0.1.0 |
|
| 31 | - * |
|
| 32 | - * @param mixed $criterion Criterion to check. |
|
| 33 | - * |
|
| 34 | - * @return bool Whether the Findable can handle the criterion. |
|
| 35 | - */ |
|
| 36 | - public function canHandle($criterion) |
|
| 37 | - { |
|
| 38 | - return true; |
|
| 39 | - } |
|
| 27 | + /** |
|
| 28 | + * Check whether the Findable can handle an individual criterion. |
|
| 29 | + * |
|
| 30 | + * @since 0.1.0 |
|
| 31 | + * |
|
| 32 | + * @param mixed $criterion Criterion to check. |
|
| 33 | + * |
|
| 34 | + * @return bool Whether the Findable can handle the criterion. |
|
| 35 | + */ |
|
| 36 | + public function canHandle($criterion) |
|
| 37 | + { |
|
| 38 | + return true; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Render a given URI. |
|
| 43 | - * |
|
| 44 | - * @since 0.1.0 |
|
| 45 | - * |
|
| 46 | - * @param string $uri URI to render. |
|
| 47 | - * @param array $context Context in which to render. |
|
| 48 | - * |
|
| 49 | - * @return string Rendered HTML. |
|
| 50 | - */ |
|
| 51 | - public function render($uri, array $context = []) |
|
| 52 | - { |
|
| 53 | - return ''; |
|
| 54 | - } |
|
| 41 | + /** |
|
| 42 | + * Render a given URI. |
|
| 43 | + * |
|
| 44 | + * @since 0.1.0 |
|
| 45 | + * |
|
| 46 | + * @param string $uri URI to render. |
|
| 47 | + * @param array $context Context in which to render. |
|
| 48 | + * |
|
| 49 | + * @return string Rendered HTML. |
|
| 50 | + */ |
|
| 51 | + public function render($uri, array $context = []) |
|
| 52 | + { |
|
| 53 | + return ''; |
|
| 54 | + } |
|
| 55 | 55 | } |