mirror of
https://github.com/getgrav/grav.git
synced 2026-07-13 16:02:35 +02:00
Event improvements
This commit is contained in:
10
bin/plugin
10
bin/plugin
@@ -2,6 +2,7 @@
|
||||
<?php
|
||||
|
||||
use Grav\Common\Composer;
|
||||
use Grav\Events\PluginsLoadedEvent;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
@@ -55,7 +56,14 @@ $grav->setup($environment);
|
||||
$grav['config']->init();
|
||||
$grav['uri']->init();
|
||||
$grav['users'];
|
||||
$grav['plugins']->init();
|
||||
|
||||
$plugins = $grav['plugins'];
|
||||
$plugins->init();
|
||||
|
||||
// Plugins Loaded Event
|
||||
$event = new PluginsLoadedEvent($grav, $plugins);
|
||||
$grav->dispatchEvent($event);
|
||||
|
||||
$grav['themes']->init();
|
||||
|
||||
$app = new Application('Grav Plugins Commands', GRAV_VERSION);
|
||||
|
||||
@@ -11,16 +11,32 @@ namespace Grav\Events;
|
||||
|
||||
use Grav\Framework\Acl\Permissions;
|
||||
|
||||
class RegisterPermissionsEvent
|
||||
/**
|
||||
* Permissions Register Event
|
||||
*
|
||||
* This event is called the first time $grav['permissions'] is being called.
|
||||
*
|
||||
* Use this event to register any new permission types you use in your plugins.
|
||||
*
|
||||
* @property Permissions $permissions Permissions instance.
|
||||
*/
|
||||
class PermissionsRegisterEvent
|
||||
{
|
||||
/** @var Permissions */
|
||||
public $permissions;
|
||||
|
||||
/**
|
||||
* PermissionsRegisterEvent constructor.
|
||||
* @param Permissions $permissions
|
||||
*/
|
||||
public function __construct(Permissions $permissions)
|
||||
{
|
||||
$this->permissions = $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __debugInfo(): array
|
||||
{
|
||||
return (array)$this;
|
||||
@@ -12,6 +12,16 @@ namespace Grav\Events;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Plugins;
|
||||
|
||||
/**
|
||||
* Plugins Loaded Event
|
||||
*
|
||||
* This event is called from InitializeProcessor.
|
||||
*
|
||||
* This is the first event plugin can see. Please avoid using this event if possible.
|
||||
*
|
||||
* @property Grav $grav Grav container.
|
||||
* @property Plugins $plugins Plugins instance.
|
||||
*/
|
||||
class PluginsLoadedEvent
|
||||
{
|
||||
/** @var Grav */
|
||||
@@ -19,12 +29,20 @@ class PluginsLoadedEvent
|
||||
/** @var Plugins */
|
||||
public $plugins;
|
||||
|
||||
/**
|
||||
* PluginsLoadedEvent constructor.
|
||||
* @param Grav $grav
|
||||
* @param Plugins $plugins
|
||||
*/
|
||||
public function __construct(Grav $grav, Plugins $plugins)
|
||||
{
|
||||
$this->grav = $grav;
|
||||
$this->plugins = $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __debugInfo(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -9,14 +9,21 @@
|
||||
|
||||
namespace Grav\Events;
|
||||
|
||||
use Grav\Framework\Session\Session;
|
||||
use Grav\Framework\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* Plugins Loaded Event
|
||||
*
|
||||
* This event is called from $grav['session']->start() right after successful session_start() call.
|
||||
*
|
||||
* @property SessionInterface $session Session instance.
|
||||
*/
|
||||
class SessionStartEvent
|
||||
{
|
||||
/** @var Session */
|
||||
/** @var SessionInterface */
|
||||
public $session;
|
||||
|
||||
public function __construct(Session $session)
|
||||
public function __construct(SessionInterface $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user