paths; } /** * @param array $paths * @return $this */ public function setPaths(array $paths) { if ($paths != $this->paths) { $this->clearList(); } $this->paths = $paths; return $this; } public function clearList() { $this->list = null; return $this; } public function getList() { if (null !== $this->list) { return $this->list; } $this->list = []; foreach ($this->paths as $path) { if (!file_exists($path) || !is_dir($path)) { continue; } $files = glob($path . '/*.tpl'); foreach ($files as $file) { $name = basename($file); if (array_key_exists($name, $this->list)) { continue; } $this->list[$name] = [ 'file' => $file, 'title' => $name, ]; } } return $this->list; } public function search($name, $field = null, $default = null) { $list = $this->getList(); if (array_key_exists($name, $list)) { return Qs_Array::get($list[$name], $field, $default); } return $default; } }