1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace OC\Template;
- class TemplateFileLocator {
- protected $dirs;
- private $path;
-
- public function __construct($dirs) {
- $this->dirs = $dirs;
- }
-
- public function find($template) {
- if ($template === '') {
- throw new \InvalidArgumentException('Empty template name');
- }
- foreach ($this->dirs as $dir) {
- $file = $dir.$template.'.php';
- if (is_file($file)) {
- $this->path = $dir;
- return $file;
- }
- }
- throw new \Exception('template file not found: template:'.$template);
- }
- public function getPath() {
- return $this->path;
- }
- }
|