$value) { if (isset($manifest[$attribute])) { $this->$attribute = $manifest[$attribute]; } } if (file_exists($directory.self::SCREENSHOT)) { $this->screenshot = true; } if (!$this->name) { throw new sfException("Template name was not set and it is mandatory."); } $this->directory = $this->generateDirectoryName(); } public function getName() { return $this->name; } public function getVersion() { return $this->version; } public function getAuthor() { return $this->author; } public function getEmail() { return $this->email; } public function getHomepage() { return $this->homepage; } public function getDirectoryName() { return $this->directory; } public function hasScreenshot() { return $this->screenshot; } public function isCompiled() { return (bool) $this->compiled; } public function setCompiled($value) { $this->compiled = (bool) $value; } /** * Transforms manifest.name into an underscored and filtered directory name * @return string * @author Carlos */ protected function generateDirectoryName() { $old = ini_get('mbstring.substitute_character'); ini_set('mbstring.substitute_character', "none"); $name = preg_replace('/\s+/', '-', strtolower(filter_var(mb_convert_encoding($this->name, 'ASCII'), FILTER_SANITIZE_STRING))); ini_set('mbstring.substitute_character', $old); return $name; } /** * Returns valid template names as an array * @return array * @author Carlos Escribano **/ public static function getTemplateNames() { return explode(',', self::TEMPLATES); } protected function toArray() { $res = array(); foreach (get_object_vars($this) as $attribute => $value) { $res[$attribute] = $value; } return $res; } public function dump() { return sfYaml::dump($this->toArray()); } }