.*)\.php$/'; if (preg_match($pattern, $this->path, $match)) { return $match['slug']; } else { // nothing to mach } } public function __construct($path) { $this->path = $path; $this->filename = basename($path); if ( $this->filename ) { // page-hoge.php => hoge $pattern = '/^page-(.*)\.php$/'; $replacement = '${1}'; $this->slug = preg_replace($pattern, $replacement, $this->filename); } $this->status = $this->getStatus(); } private function getStatus() { return AP_TemplateStatus::ENABLED; } }