@@ -12,26 +12,26 @@ |
||
| 12 | 12 | namespace BrightNucleus\View; |
| 13 | 13 | |
| 14 | 14 | $engineFinder = [ |
| 15 | - 'ClassName' => 'BrightNucleus\View\Engine\EngineFinder', |
|
| 16 | - 'Engines' => [ |
|
| 17 | - 'PHPEngine' => 'BrightNucleus\View\Engine\PHPEngine', |
|
| 18 | - ], |
|
| 19 | - 'NullObject' => 'BrightNucleus\View\Engine\NullEngine', |
|
| 15 | + 'ClassName' => 'BrightNucleus\View\Engine\EngineFinder', |
|
| 16 | + 'Engines' => [ |
|
| 17 | + 'PHPEngine' => 'BrightNucleus\View\Engine\PHPEngine', |
|
| 18 | + ], |
|
| 19 | + 'NullObject' => 'BrightNucleus\View\Engine\NullEngine', |
|
| 20 | 20 | ]; |
| 21 | 21 | |
| 22 | 22 | $viewFinder = [ |
| 23 | - 'ClassName' => 'BrightNucleus\View\View\ViewFinder', |
|
| 24 | - 'Views' => [ |
|
| 25 | - 'BaseView' => 'BrightNucleus\View\View\BaseView', |
|
| 26 | - ], |
|
| 27 | - 'NullObject' => 'BrightNucleus\View\View\NullView', |
|
| 23 | + 'ClassName' => 'BrightNucleus\View\View\ViewFinder', |
|
| 24 | + 'Views' => [ |
|
| 25 | + 'BaseView' => 'BrightNucleus\View\View\BaseView', |
|
| 26 | + ], |
|
| 27 | + 'NullObject' => 'BrightNucleus\View\View\NullView', |
|
| 28 | 28 | ]; |
| 29 | 29 | |
| 30 | 30 | return [ |
| 31 | - 'BrightNucleus' => [ |
|
| 32 | - 'View' => [ |
|
| 33 | - 'EngineFinder' => $engineFinder, |
|
| 34 | - 'ViewFinder' => $viewFinder, |
|
| 35 | - ], |
|
| 36 | - ], |
|
| 31 | + 'BrightNucleus' => [ |
|
| 32 | + 'View' => [ |
|
| 33 | + 'EngineFinder' => $engineFinder, |
|
| 34 | + 'ViewFinder' => $viewFinder, |
|
| 35 | + ], |
|
| 36 | + ], |
|
| 37 | 37 | ]; |
@@ -25,55 +25,55 @@ |
||
| 25 | 25 | abstract class AbstractView implements ViewInterface, Findable |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * URI of the view. |
|
| 30 | - * |
|
| 31 | - * @since 0.1.0 |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - protected $uri; |
|
| 28 | + /** |
|
| 29 | + * URI of the view. |
|
| 30 | + * |
|
| 31 | + * @since 0.1.0 |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + protected $uri; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Engine to use for the view. |
|
| 39 | - * |
|
| 40 | - * @since 0.1.0 |
|
| 41 | - * |
|
| 42 | - * @var EngineInterface |
|
| 43 | - */ |
|
| 44 | - protected $engine; |
|
| 37 | + /** |
|
| 38 | + * Engine to use for the view. |
|
| 39 | + * |
|
| 40 | + * @since 0.1.0 |
|
| 41 | + * |
|
| 42 | + * @var EngineInterface |
|
| 43 | + */ |
|
| 44 | + protected $engine; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Instantiate an AbstractView object. |
|
| 48 | - * |
|
| 49 | - * @since 0.1.0 |
|
| 50 | - * |
|
| 51 | - * @param string $uri URI for the view. |
|
| 52 | - * @param EngineInterface $engine Engine to use for the view. |
|
| 53 | - */ |
|
| 54 | - public function __construct($uri, EngineInterface $engine) |
|
| 55 | - { |
|
| 56 | - $this->uri = $uri; |
|
| 57 | - $this->engine = $engine; |
|
| 58 | - } |
|
| 46 | + /** |
|
| 47 | + * Instantiate an AbstractView object. |
|
| 48 | + * |
|
| 49 | + * @since 0.1.0 |
|
| 50 | + * |
|
| 51 | + * @param string $uri URI for the view. |
|
| 52 | + * @param EngineInterface $engine Engine to use for the view. |
|
| 53 | + */ |
|
| 54 | + public function __construct($uri, EngineInterface $engine) |
|
| 55 | + { |
|
| 56 | + $this->uri = $uri; |
|
| 57 | + $this->engine = $engine; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Render the view. |
|
| 62 | - * |
|
| 63 | - * @since 0.1.0 |
|
| 64 | - * |
|
| 65 | - * @param array $context Optional. The context in which to render the view. |
|
| 66 | - * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
| 67 | - * |
|
| 68 | - * @return string|void Rendered HTML or nothing, depending on $echo argument. |
|
| 69 | - */ |
|
| 70 | - public function render(array $context = [], $echo = false) |
|
| 71 | - { |
|
| 72 | - $output = $this->engine->render($this->uri, $context); |
|
| 73 | - if ($echo) { |
|
| 74 | - echo $output; |
|
| 75 | - } else { |
|
| 76 | - return $output; |
|
| 77 | - } |
|
| 78 | - } |
|
| 60 | + /** |
|
| 61 | + * Render the view. |
|
| 62 | + * |
|
| 63 | + * @since 0.1.0 |
|
| 64 | + * |
|
| 65 | + * @param array $context Optional. The context in which to render the view. |
|
| 66 | + * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
| 67 | + * |
|
| 68 | + * @return string|void Rendered HTML or nothing, depending on $echo argument. |
|
| 69 | + */ |
|
| 70 | + public function render(array $context = [], $echo = false) |
|
| 71 | + { |
|
| 72 | + $output = $this->engine->render($this->uri, $context); |
|
| 73 | + if ($echo) { |
|
| 74 | + echo $output; |
|
| 75 | + } else { |
|
| 76 | + return $output; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | interface ViewInterface |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Render the view. |
|
| 27 | - * |
|
| 28 | - * @since 0.1.0 |
|
| 29 | - * |
|
| 30 | - * @param array $context Optional. The context in which to render the view. |
|
| 31 | - * |
|
| 32 | - * @return string Rendered HTML. |
|
| 33 | - */ |
|
| 34 | - public function render(array $context = []); |
|
| 25 | + /** |
|
| 26 | + * Render the view. |
|
| 27 | + * |
|
| 28 | + * @since 0.1.0 |
|
| 29 | + * |
|
| 30 | + * @param array $context Optional. The context in which to render the view. |
|
| 31 | + * |
|
| 32 | + * @return string Rendered HTML. |
|
| 33 | + */ |
|
| 34 | + public function render(array $context = []); |
|
| 35 | 35 | } |
@@ -24,24 +24,24 @@ |
||
| 24 | 24 | abstract class AbstractEngine implements EngineInterface, Findable |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Check whether a given URI has a specific extension. |
|
| 29 | - * |
|
| 30 | - * @since 0.1.0 |
|
| 31 | - * |
|
| 32 | - * @param string $uri URI to check the extension of. |
|
| 33 | - * @param string $extension Extension to check for. |
|
| 34 | - * |
|
| 35 | - * @return bool |
|
| 36 | - */ |
|
| 37 | - protected function hasExtension($uri, $extension) |
|
| 38 | - { |
|
| 39 | - $uriLength = mb_strlen($uri); |
|
| 40 | - $extensionLength = mb_strlen($extension); |
|
| 41 | - if ($extensionLength > $uriLength) { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 27 | + /** |
|
| 28 | + * Check whether a given URI has a specific extension. |
|
| 29 | + * |
|
| 30 | + * @since 0.1.0 |
|
| 31 | + * |
|
| 32 | + * @param string $uri URI to check the extension of. |
|
| 33 | + * @param string $extension Extension to check for. |
|
| 34 | + * |
|
| 35 | + * @return bool |
|
| 36 | + */ |
|
| 37 | + protected function hasExtension($uri, $extension) |
|
| 38 | + { |
|
| 39 | + $uriLength = mb_strlen($uri); |
|
| 40 | + $extensionLength = mb_strlen($extension); |
|
| 41 | + if ($extensionLength > $uriLength) { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0; |
|
| 46 | - } |
|
| 45 | + return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0; |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -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 | } |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | */ |
| 90 | 90 | public static function getDefaultConfig() |
| 91 | 91 | { |
| 92 | - return ConfigFactory::create(__DIR__ . '/../config/defaults.php') |
|
| 92 | + return ConfigFactory::create(__DIR__.'/../config/defaults.php') |
|
| 93 | 93 | ->getSubConfig('BrightNucleus\View'); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -28,104 +28,104 @@ |
||
| 28 | 28 | class View |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * ViewBuilder Instance. |
|
| 33 | - * |
|
| 34 | - * @since 0.1.0 |
|
| 35 | - * |
|
| 36 | - * @var ViewBuilder |
|
| 37 | - */ |
|
| 38 | - protected static $viewBuilder; |
|
| 31 | + /** |
|
| 32 | + * ViewBuilder Instance. |
|
| 33 | + * |
|
| 34 | + * @since 0.1.0 |
|
| 35 | + * |
|
| 36 | + * @var ViewBuilder |
|
| 37 | + */ |
|
| 38 | + protected static $viewBuilder; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Add a location to the ViewBuilder. |
|
| 42 | - * |
|
| 43 | - * @since 0.1.0 |
|
| 44 | - * |
|
| 45 | - * @param LocationInterface $location Location to add. |
|
| 46 | - */ |
|
| 47 | - public static function addLocation(LocationInterface $location) |
|
| 48 | - { |
|
| 49 | - $viewBuilder = static::getViewBuilder(); |
|
| 50 | - $viewBuilder->addLocation($location); |
|
| 51 | - } |
|
| 40 | + /** |
|
| 41 | + * Add a location to the ViewBuilder. |
|
| 42 | + * |
|
| 43 | + * @since 0.1.0 |
|
| 44 | + * |
|
| 45 | + * @param LocationInterface $location Location to add. |
|
| 46 | + */ |
|
| 47 | + public static function addLocation(LocationInterface $location) |
|
| 48 | + { |
|
| 49 | + $viewBuilder = static::getViewBuilder(); |
|
| 50 | + $viewBuilder->addLocation($location); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Get the ViewBuilder instance. |
|
| 55 | - * |
|
| 56 | - * @since 0.1.0 |
|
| 57 | - * |
|
| 58 | - * @return ViewBuilder |
|
| 59 | - */ |
|
| 60 | - public static function getViewBuilder() |
|
| 61 | - { |
|
| 62 | - if (null === static::$viewBuilder) { |
|
| 63 | - static::$viewBuilder = static::instantiateViewBuilder(); |
|
| 64 | - } |
|
| 53 | + /** |
|
| 54 | + * Get the ViewBuilder instance. |
|
| 55 | + * |
|
| 56 | + * @since 0.1.0 |
|
| 57 | + * |
|
| 58 | + * @return ViewBuilder |
|
| 59 | + */ |
|
| 60 | + public static function getViewBuilder() |
|
| 61 | + { |
|
| 62 | + if (null === static::$viewBuilder) { |
|
| 63 | + static::$viewBuilder = static::instantiateViewBuilder(); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return static::$viewBuilder; |
|
| 67 | - } |
|
| 66 | + return static::$viewBuilder; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Instantiate the ViewBuilder. |
|
| 71 | - * |
|
| 72 | - * @since 0.1.0 |
|
| 73 | - * |
|
| 74 | - * @param ConfigInterface|null $config Optional. Configuration to pass into the ViewBuilder. |
|
| 75 | - * |
|
| 76 | - * @return ViewBuilder Instance of the ViewBuilder. |
|
| 77 | - */ |
|
| 78 | - public static function instantiateViewBuilder(ConfigInterface $config = null) |
|
| 79 | - { |
|
| 80 | - return static::$viewBuilder = new ViewBuilder($config ?: static::getDefaultConfig()); |
|
| 81 | - } |
|
| 69 | + /** |
|
| 70 | + * Instantiate the ViewBuilder. |
|
| 71 | + * |
|
| 72 | + * @since 0.1.0 |
|
| 73 | + * |
|
| 74 | + * @param ConfigInterface|null $config Optional. Configuration to pass into the ViewBuilder. |
|
| 75 | + * |
|
| 76 | + * @return ViewBuilder Instance of the ViewBuilder. |
|
| 77 | + */ |
|
| 78 | + public static function instantiateViewBuilder(ConfigInterface $config = null) |
|
| 79 | + { |
|
| 80 | + return static::$viewBuilder = new ViewBuilder($config ?: static::getDefaultConfig()); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Get the default configuration to inject into the ViewBuilder. |
|
| 85 | - * |
|
| 86 | - * @since 0.1.0 |
|
| 87 | - * |
|
| 88 | - * @return ConfigInterface Default configuration. |
|
| 89 | - */ |
|
| 90 | - public static function getDefaultConfig() |
|
| 91 | - { |
|
| 92 | - return ConfigFactory::create(__DIR__ . '/../config/defaults.php') |
|
| 93 | - ->getSubConfig('BrightNucleus\View'); |
|
| 94 | - } |
|
| 83 | + /** |
|
| 84 | + * Get the default configuration to inject into the ViewBuilder. |
|
| 85 | + * |
|
| 86 | + * @since 0.1.0 |
|
| 87 | + * |
|
| 88 | + * @return ConfigInterface Default configuration. |
|
| 89 | + */ |
|
| 90 | + public static function getDefaultConfig() |
|
| 91 | + { |
|
| 92 | + return ConfigFactory::create(__DIR__ . '/../config/defaults.php') |
|
| 93 | + ->getSubConfig('BrightNucleus\View'); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Create a new view for a given URI. |
|
| 98 | - * |
|
| 99 | - * @since 0.1.0 |
|
| 100 | - * |
|
| 101 | - * @param string $view View identifier to create a view for. |
|
| 102 | - * @param string|null $type Type of view to create. |
|
| 103 | - * |
|
| 104 | - * @return ViewInterface Instance of the requested view. |
|
| 105 | - */ |
|
| 106 | - public static function create($view, $type = null) |
|
| 107 | - { |
|
| 108 | - $viewBuilder = static::getViewBuilder(); |
|
| 96 | + /** |
|
| 97 | + * Create a new view for a given URI. |
|
| 98 | + * |
|
| 99 | + * @since 0.1.0 |
|
| 100 | + * |
|
| 101 | + * @param string $view View identifier to create a view for. |
|
| 102 | + * @param string|null $type Type of view to create. |
|
| 103 | + * |
|
| 104 | + * @return ViewInterface Instance of the requested view. |
|
| 105 | + */ |
|
| 106 | + public static function create($view, $type = null) |
|
| 107 | + { |
|
| 108 | + $viewBuilder = static::getViewBuilder(); |
|
| 109 | 109 | |
| 110 | - return $viewBuilder->create($view, $type); |
|
| 111 | - } |
|
| 110 | + return $viewBuilder->create($view, $type); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Render a view for a given URI. |
|
| 115 | - * |
|
| 116 | - * @since 0.1.0 |
|
| 117 | - * |
|
| 118 | - * @param string $view View identifier to create a view for. |
|
| 119 | - * @param array $context Optional. The context in which to render the view. |
|
| 120 | - * @param string|null $type Type of view to create. |
|
| 121 | - * |
|
| 122 | - * @return string Rendered HTML content. |
|
| 123 | - */ |
|
| 124 | - public static function render($view, array $context = [], $type = null) |
|
| 125 | - { |
|
| 126 | - $viewBuilder = static::getViewBuilder(); |
|
| 127 | - $viewObject = $viewBuilder->create($view, $type); |
|
| 113 | + /** |
|
| 114 | + * Render a view for a given URI. |
|
| 115 | + * |
|
| 116 | + * @since 0.1.0 |
|
| 117 | + * |
|
| 118 | + * @param string $view View identifier to create a view for. |
|
| 119 | + * @param array $context Optional. The context in which to render the view. |
|
| 120 | + * @param string|null $type Type of view to create. |
|
| 121 | + * |
|
| 122 | + * @return string Rendered HTML content. |
|
| 123 | + */ |
|
| 124 | + public static function render($view, array $context = [], $type = null) |
|
| 125 | + { |
|
| 126 | + $viewBuilder = static::getViewBuilder(); |
|
| 127 | + $viewObject = $viewBuilder->create($view, $type); |
|
| 128 | 128 | |
| 129 | - return $viewObject->render($context); |
|
| 130 | - } |
|
| 129 | + return $viewObject->render($context); |
|
| 130 | + } |
|
| 131 | 131 | } |
@@ -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 | } |