Skip to content

Commit

Permalink
Add default locations if none provided
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Mar 24, 2019
1 parent 6175129 commit 6e4e3a6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Infrastructure/View/TemplatedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ),
] );
];
}
}

0 comments on commit 6e4e3a6

Please sign in to comment.