Event propagation

Are further subscribed events propagated to a plugin even if $this->active is set to false in onPageInitialized()?

Basically could plugin classes look like this

    public static function getSubscribedEvents()
    {
        return [
            'onPageInitialized' => ['onPageInitialized', 0],
            'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
            'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
        ];
    }

    public function onPageInitialized()
    {
        if ($this->isAdmin() ) {
            $this->active = false;
            return;
        }
    } 

or better like this

    public static function getSubscribedEvents()
    {
        return [
            'onPageInitialized' => ['onPageInitialized', 0],
        ];
    }

    public function onPageInitialized()
    {
        if ($this->isAdmin() ) {
            $this->active = false;
            return;
        }
        $this->enable([
            'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
            'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
        ]);
    }

In short yes. $this->active is not used internally, it is there to be used by your plugin if you need it.

Thanks for clarification. Btw, in above examples I was meant to use onPluginsInitialized instead of onPageInitialized.

It really is the same, you just need to sure you don’t try to enable an event that has already occurred. You can use the Grav Lifecycle to reference the order events are fired. Also the Event Hooks page has relevant information.