diff --git a/CHANGELOG.md b/CHANGELOG.md index f8ad73565..edd93b07e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 58b817329..ba5cc85e0 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -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(); diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php index 8fbc0a84d..37de6e9a9 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectory.php +++ b/system/src/Grav/Framework/Flex/FlexDirectory.php @@ -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); } /** diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 7cd6ea57e..e6e9943a4 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -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()