Fixed onBlueprintCreated event being called multiple times in Flex Pages

This commit is contained in:
Matias Griese
2021-01-28 20:12:33 +02:00
parent 0ba23ca278
commit a35b9b1279
2 changed files with 11 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
* Fixed cannot change image format [#3173](https://github.com/getgrav/grav/issues/3173)
* Fixed saving page in expert mode [#3174](https://github.com/getgrav/grav/issues/3174)
* Fixed exception in `$flexPage->frontmatter()` method when setting value
* Fixed `onBlueprintCreated` event being called multiple times in `Flex Pages` [grav-plugin-flex-objects#97](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/97)
# v1.7.3
## 01/21/2021

View File

@@ -65,6 +65,8 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
private $_flexDirectory;
/** @var FlexFormInterface[] */
private $_forms = [];
/** @var Blueprint|null */
private $_blueprint;
/** @var array */
private $_meta;
/** @var array */
@@ -769,11 +771,15 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
*/
public function getBlueprint(string $name = '')
{
$blueprint = $this->doGetBlueprint($name);
$blueprint->setScope('object');
$blueprint->setObject($this);
if (null === $this->_blueprint) {
$blueprint = $this->doGetBlueprint($name);
$blueprint->setScope('object');
$blueprint->setObject($this);
return $blueprint->init();
$this->_blueprint = $blueprint->init();
}
return $this->_blueprint;
}
/**