mirror of
https://github.com/getgrav/grav.git
synced 2026-02-20 21:48:04 +01:00
Improve blueprint initialization in Flex Objects (fixes content aware fields)
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.7.0-beta.9
|
||||
## mm/dd/2019
|
||||
|
||||
1. [](#bugfix)
|
||||
* Improve blueprint initialization in Flex Objects (fixes content aware fields)
|
||||
|
||||
# v1.7.0-beta.8
|
||||
## 09/19/2019
|
||||
|
||||
|
||||
@@ -1307,7 +1307,7 @@ class Pages
|
||||
return;
|
||||
}
|
||||
|
||||
$this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..');
|
||||
$this->grav['debugger']->addMessage('Page cache missed, rebuilding Flex Pages..');
|
||||
|
||||
$root = $this->buildRootPage();
|
||||
$root_path = $root->path();
|
||||
|
||||
@@ -44,8 +44,6 @@ class FlexDirectory implements FlexAuthorizeInterface
|
||||
protected $blueprint_file;
|
||||
/** @var Blueprint[] */
|
||||
protected $blueprints;
|
||||
/** @var bool[] */
|
||||
protected $blueprints_init;
|
||||
/** @var FlexIndexInterface|null */
|
||||
protected $index;
|
||||
/** @var FlexCollectionInterface|null */
|
||||
@@ -154,25 +152,18 @@ class FlexDirectory implements FlexAuthorizeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new uninitialized instance of blueprint.
|
||||
*
|
||||
* Always use $object->getBlueprint() or $object->getForm()->getBlueprint() instead.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $context
|
||||
* @return Blueprint
|
||||
* @internal
|
||||
*/
|
||||
public function getBlueprint(string $type = '', string $context = '')
|
||||
{
|
||||
$blueprint = $this->getBlueprintInternal($type, $context);
|
||||
|
||||
if (empty($this->blueprints_init[$type])) {
|
||||
$this->blueprints_init[$type] = true;
|
||||
|
||||
$blueprint->setScope('object');
|
||||
$blueprint->init();
|
||||
if (empty($blueprint->fields())) {
|
||||
throw new RuntimeException(sprintf('Flex: Blueprint for %s is missing', $this->type));
|
||||
}
|
||||
}
|
||||
|
||||
return $blueprint;
|
||||
return clone $this->getBlueprintInternal($type, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -731,12 +731,22 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
||||
*/
|
||||
public function getBlueprint(string $name = '')
|
||||
{
|
||||
$blueprint = clone $this->_flexDirectory->getBlueprint($name ? '.' . $name : $name);
|
||||
$blueprint = $this->doGetBlueprint($name);
|
||||
$blueprint->setScope('object');
|
||||
$blueprint->setObject($this);
|
||||
|
||||
return $blueprint->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Blueprint
|
||||
*/
|
||||
protected function doGetBlueprint(string $name = ''): Blueprint
|
||||
{
|
||||
return $this->_flexDirectory->getBlueprint($name ? '.' . $name : $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::getForm()
|
||||
|
||||
Reference in New Issue
Block a user