Add blueprints and fake content
This commit is contained in:
parent
1ff19bf38f
commit
8235816462
592 changed files with 22385 additions and 31535 deletions
|
@ -6,9 +6,9 @@ use Exception;
|
|||
use Kirby\Data\Data;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Exception\NotFoundException;
|
||||
use Kirby\Filesystem\F;
|
||||
use Kirby\Form\Field;
|
||||
use Kirby\Toolkit\A;
|
||||
use Kirby\Toolkit\F;
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Throwable;
|
||||
|
||||
|
@ -58,6 +58,10 @@ class Blueprint
|
|||
throw new InvalidArgumentException('A blueprint model is required');
|
||||
}
|
||||
|
||||
if (is_a($props['model'], ModelWithContent::class) === false) {
|
||||
throw new InvalidArgumentException('Invalid blueprint model');
|
||||
}
|
||||
|
||||
$this->model = $props['model'];
|
||||
|
||||
// the model should not be included in the props array
|
||||
|
@ -288,6 +292,8 @@ class Blueprint
|
|||
return static::$loaded[$name] = Data::read($file);
|
||||
} elseif (is_array($file) === true) {
|
||||
return static::$loaded[$name] = $file;
|
||||
} elseif (is_callable($file) === true) {
|
||||
return static::$loaded[$name] = $file($kirby);
|
||||
}
|
||||
|
||||
// neither a valid file nor array data
|
||||
|
@ -697,6 +703,7 @@ class Blueprint
|
|||
'columns' => $this->normalizeColumns($tabName, $tabProps['columns'] ?? []),
|
||||
'icon' => $tabProps['icon'] ?? null,
|
||||
'label' => $this->i18n($tabProps['label'] ?? ucfirst($tabName)),
|
||||
'link' => $this->model->panel()->url(true) . '/?tab=' . $tabName,
|
||||
'name' => $tabName,
|
||||
]);
|
||||
}
|
||||
|
@ -720,7 +727,13 @@ class Blueprint
|
|||
return $props;
|
||||
}
|
||||
|
||||
return static::$presets[$props['preset']]($props);
|
||||
$preset = static::$presets[$props['preset']];
|
||||
|
||||
if (is_string($preset) === true) {
|
||||
$preset = require $preset;
|
||||
}
|
||||
|
||||
return $preset($props);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -760,11 +773,15 @@ class Blueprint
|
|||
/**
|
||||
* Returns a single tab by name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|null $name
|
||||
* @return array|null
|
||||
*/
|
||||
public function tab(string $name): ?array
|
||||
public function tab(?string $name = null): ?array
|
||||
{
|
||||
if ($name === null) {
|
||||
return A::first($this->tabs);
|
||||
}
|
||||
|
||||
return $this->tabs[$name] ?? null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue