Skip to content

Commit

Permalink
Flex Pages: Fixed frontend issues with plugin events [#5]
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Oct 7, 2019
1 parent c98fbb6 commit 892fd14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
1. [](#bugfix)
* Flex Pages: Fixed default language not being translated in both `translatedLanguages()` and `untranslatedLanguages()` results
* Flex Pages: Language interface compatibility fixes
* Flex Pages: Fixed frontend issues with plugin events [#5](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/5)

# v1.0.0-beta.10
## 10/03/2019
Expand Down
11 changes: 11 additions & 0 deletions classes/Types/GravPages/GravPageObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Grav\Plugin\FlexObjects\Types\GravPages\Traits\PageLegacyTrait;
use Grav\Plugin\FlexObjects\Types\GravPages\Traits\PageRoutableTrait;
use Grav\Plugin\FlexObjects\Types\GravPages\Traits\PageTranslateTrait;
use RocketTheme\Toolbox\Event\Event;

/**
* Class GravPageObject
Expand All @@ -42,6 +43,8 @@ class GravPageObject extends FlexPageObject
/** @var string File format, eg. 'md' */
protected $format;

private $_initialized = false;

/**
* @return array
*/
Expand All @@ -53,6 +56,14 @@ public static function getCachedMethods(): array
] + parent::getCachedMethods();
}

public function initialize(): void
{
if (!$this->_initialized) {
Grav::instance()->fireEvent('onPageProcessed', new Event(['page' => $this]));
$this->_initialized = true;
}
}

/**
* @param string|array $query
* @return Route
Expand Down

0 comments on commit 892fd14

Please sign in to comment.