<?php
namespace Grav\Plugin;

use Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;

class StoryBlocksPlugin extends Plugin
{
    private $currentPage = null;

    public static function getSubscribedEvents(): array
    {
        return [
            'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
            'onPageContentRaw'    => ['onPageContentRaw', 1000],
        ];
    }

    public function onPageContentRaw(Event $event): void
    {
        $this->currentPage = $event['page'];
    }

    public function getCurrentPage()
    {
        return $this->currentPage;
    }

    public function onShortcodeHandlers(): void
    {
        $this->grav['shortcode']->registerAllShortcodes(__DIR__ . '/shortcodes');
    }
}
