Blueprint refactor: fix theme thumbnails

This commit is contained in:
Matias Griese
2016-01-22 10:07:40 +02:00
parent b791e8efda
commit 80d0c2a405
2 changed files with 47 additions and 1 deletions

View File

@@ -51,6 +51,52 @@ class Blueprint extends BaseBlueprints implements ExportInterface
return $this;
}
/**
* Get meta value by using dot notation for nested arrays/objects.
*
* @param string $name Dot separated path to the requested value.
* @param string $field Meta field to fetch.
* @param mixed $default Default value (or null).
* @param string $separator Separator, defaults to '.'
*
* @return mixed Value.
*/
public function getMeta($name, $field, $default = null, $separator = '.')
{
$name = $separator != '.' ? strtr($name, $separator, '.') : $name;
return isset($this->items[$name]['meta'][$field]) ? $this->items[$name]['meta'][$field] : $default;
}
/**
* Set meta value by using dot notation for nested arrays/objects.
*
* @param string $name Dot separated path to the requested value.
* @param string $field Meta field to fetch.
* @param mixed $value New value.
* @param string $separator Separator, defaults to '.'
*/
public function setMeta($name, $field, $value, $separator = '.')
{
$name = $separator != '.' ? strtr($name, $separator, '.') : $name;
$this->items[$name]['meta'][$field] = $value;
}
/**
* Define meta value by using dot notation for nested arrays/objects.
*
* @param string $name Dot separated path to the requested value.
* @param string $field Meta field to fetch.
* @param mixed $value New value.
* @param string $separator Separator, defaults to '.'
*/
public function defMeta($name, $field, $value, $separator = '.')
{
$this->setMeta($name, $field, $this->getMeta($name, $field, $value, $separator), $separator);
}
/**
* Return all form fields in a nested list.
*

View File

@@ -127,7 +127,7 @@ class Themes extends Iterator
// Find thumbnail.
$thumb = "themes://{$name}/thumbnail.jpg";
if ($path = $this->grav['locator']->findResource($thumb, false)) {
$blueprint->set('thumbnail', $this->grav['base_url'] . '/' . $path);
$blueprint->setMeta('', 'thumbnail', $this->grav['base_url'] . '/' . $path);
}
$obj = new Data($file->content(), $blueprint);