/** * Create a new theme instance from JSON file. * * @param string $path * @return Raincolour\Containers\Theme */ public static function make($path) { $theme = new self(); $theme->fromFile($path); $theme->validate(); return $theme; }
/** * Create a new Pattern instance from JSON file. * * @param string $path * @return Raincolour\Containers\Pattern */ public static function make($path) { $pattern = new self(); $pattern->fromFile($path); $pattern->put('path', $path); $pattern->validate(); $pattern->setTemplates(); return $pattern; }
/** * Returns all pages from a given path * * @param string $path Path relative to the search path(s) * @return array */ static function findAll($path, $number = null, $offset = null) { if (!is_string($path) or empty($path)) { throw new InvalidArgumentException("No path given"); } $path = rtrim($path, "/\\"); foreach (static::$searchPath as $p) { if (is_dir($p .= DIRECTORY_SEPARATOR . $path)) { $path = $p; break; } } $directory = new DirectoryIterator($path); $pages = array(); if (null !== $offset) { $directory->seek($offset); if (!$directory->valid()) { throw new InvalidArgumentException("{$offset} is not valid"); } } foreach ($directory as $entry) { if (!$entry->isFile() or $entry->isDot() or self::$suffix !== "." . pathinfo($entry->getFilename(), PATHINFO_EXTENSION)) { continue; } if ("index" . static::$suffix === $entry->getFilename()) { continue; } $page = new self(); $pages[] = $page->fromFile($path . DIRECTORY_SEPARATOR . $entry->getFilename()); if (null !== $number and strlen($pages) === $number) { break; } } return new ArrayObject($pages); }