protected function delete($name, $output) { if ($file = f::resolve($this->root() . DS . $name, ['yaml', 'yml', 'php'])) { f::remove($file); } $output->writeln('<comment>The "' . $name . '" blueprint has been deleted!</comment>'); $output->writeln(''); }
public function _extend($params) { $extends = $params['extends']; $snippet = f::resolve(kirby()->roots()->blueprints() . DS . 'fields' . DS . $extends, array('yml', 'php', 'yaml')); if (empty($snippet)) { throw new Exception(l('fields.error.extended')); } $yaml = data::read($snippet, 'yaml'); $params = a::merge($yaml, $params); return $params; }
/** * Retreives a registered blueprint file path * * @param string $name * @return string */ public function get($name = null) { if (is_null($name)) { return static::$blueprints; } $file = f::resolve($this->kirby->roots()->blueprints() . DS . str_replace('/', DS, $name), ['php', 'yml', 'yaml']); if (file_exists($file)) { return $file; } else { return a::get(static::$blueprints, $name); } }
public function load() { // get the user role and load the // correspondant blueprint if available $this->name = basename(strtolower($this->user->role())); // try to find a user blueprint $file = f::resolve(static::$root . DS . $this->name, array('yml', 'php', 'yaml')); if ($file) { $this->file = $file; $this->yaml = data::read($this->file, 'yaml'); // remove the broken first line unset($this->yaml[0]); } }
public function __construct(User $user) { // store the parent user object $this->user = $user; // this should rather be coming from the user object $this->kirby = kirby::instance(); // try to find the avatar if ($file = f::resolve($this->kirby->roots()->avatars() . DS . $user->username(), ['jpg', 'jpeg', 'gif', 'png'])) { $filename = f::filename($file); } else { $filename = $user->username() . '.jpg'; $file = $this->kirby->roots()->avatars() . DS . $filename; } parent::__construct($file, $this->kirby->urls()->avatars() . '/' . $filename); }
public static function exists($name) { return f::resolve(static::$root . DS . $name, array('yml', 'php', 'yaml')) ? true : false; }
protected function exists() { return f::resolve(dirname($this->file()) . '/' . f::name($this->file()), ['php', 'yml', 'yaml']); }