From 6e4e3a6374e6492a5a50604ade7ba1f70c70a7c5 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sun, 24 Mar 2019 16:15:53 +0100 Subject: [PATCH] Add default locations if none provided --- src/Infrastructure/View/TemplatedView.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Infrastructure/View/TemplatedView.php b/src/Infrastructure/View/TemplatedView.php index 06e61c7..d9c7193 100644 --- a/src/Infrastructure/View/TemplatedView.php +++ b/src/Infrastructure/View/TemplatedView.php @@ -50,6 +50,10 @@ public function __construct( * @return self Modified templated view. */ public function set_locations( array $locations ): self { + if ( empty( $locations ) ) { + $locations = $this->get_default_locations(); + } + $this->locations = array_map( function ( $location ) { return $this->ensure_trailing_slash( $location ); }, $locations ); @@ -111,15 +115,15 @@ private function get_locations( string $path ): array { } /** - * Set the default locations for the templated view. + * Get the default locations for the templated view. * - * @return self Modified templated view. + * @return array Array of default locations. */ - private function set_default_locations(): self { - return $this->set_locations( [ + private function get_default_locations(): array { + return [ STYLESHEETPATH, TEMPLATEPATH, \dirname( __DIR__, 2 ), - ] ); + ]; } }