Пример #1
0
 /**
  * Read and parse file
  */
 public function parse()
 {
     parent::parse();
     if (is_null($this->name)) {
         throw $this->exception('No Name in header');
     }
     if (is_null($this->description)) {
         throw $this->exception('No Description in header');
     }
     // Load any recipes
     $path = str_replace('00-about', '*', $this->filename);
     $this->recipes = array();
     $files = File::glob($path);
     foreach ($files as $file) {
         $name = basename($file);
         if ($name !== '00-about.md') {
             $this->recipes[] = new RecipeFile($file);
         }
     }
     if (count($this->recipes) == 0) {
         throw $this->exception('No recipes for category');
     }
 }
Пример #2
0
 public function unparse()
 {
     // Update categories
     $array = $this->my_cats;
     natcasesort($array);
     if (count($array) == 0) {
         $this->attributes['categories'] = '-';
     } else {
         $this->attributes['categories'] = join(', ', $array);
     }
     return parent::unparse();
 }