@@ -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 | } |