A list of available events that you can use to extend Vvveb.
Components
All components have at least an event trigger in results method
list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
You can attach to a component results event to filter the content using
// filter comments and add gravatars for users that don't have an avatar, __CLASS__ is usually used instead of 'Vvveb\Plugins\GravatarPlugin' for convenience.
Event::on('Vvveb\Component\Comments', 'results', 'Vvveb\Plugins\GravatarPlugin' , function ($comments) {
foreach ($comments['comment'] as &$comment) {
$comment['avatar'] = 'https://www.gravatar.com/avatar/' . md5(strtolower($comment['email']));
}
return [$comments];
});
View the components overview for per-component details.
Admin
Admin menu
To add a new menu item in the admin dashboard menu you need to attach to the init-menu event in the Vvveb\Controller\Base namespace.
// add a new entry in the admin dashboard menu, used by plugins to add a link to plugin settings
Event::on('Vvveb\Controller\Base', 'init-menu', __CLASS__, function ($menu) use ($admin_path) {
$menu['plugins']['items']['insert-scripts'] = [
'name' => __('Insert scripts'),
'url' => $admin_path . '?module=plugins/insert-scripts/settings',
//'icon-img' => PUBLIC_PATH . 'plugins/insert-scripts/insert-scripts.svg',
'icon' => 'icon-storefront-outline',
];
return [$menu];
});
Core
Routes
Vvveb\System\Routes
- init - parameters: $routes - fired when routes are compiled, use it to add or remove routes before they are cached. Listeners must return
[$routes].
// remove ecommerce cart and checkout pages
Event::on('Vvveb\System\Routes', 'init', __CLASS__, function ($routes) {
unset($routes['/cart'], $routes['/checkout']);
return [$routes];
});
To simply append new routes you can also call Vvveb\System\Routes::addRoute($url, $data) directly from your plugin's app() or admin() method since plugins are loaded before routes are matched.
Front controller
Vvveb\System\Core\FrontController
- call - parameters: $template, $controller, $actionName - fired after the controller action method returns and before the view is rendered, use it to change the template or short-circuit rendering (return
false).
Event::on('Vvveb\System\Core\FrontController', 'call', __CLASS__, function ($template, $controller, $actionName) {
if ($actionName == 'index') {
// ...
}
return [$template, $controller, $actionName];
});
View
Vvveb\System\Core\View
- compile - parameters: $this->template, $filename, $this->tplFile, $this->templateEngine, $this - perform an action when a template is compiled like adding a the template for your plugin
- compile:after - same parameters as compile, fired after the tpl commands were applied to the html but before the compiled file is saved; use it to inject additional
.tplcommands for your plugin - render - parameters: $this->template, $this->tplFile, $this->templateEngine, $this - perform an action before the template is rendered like pushing new data to the view
Images
Vvveb\System\Images
- publicPath - parameters: $publicPath, $type, $image, $size - use this filter to alter the public path or other parameters of an image before is resized
- image - parameters: $image, $type, $size - use this filter to alter the path or other parameters of an image after is resized
Extensions
Vvveb\System\Extensions\Extensions
- install - parameters: $extensionZipFile, $success - when a plugin or theme is installed
Themes
Vvveb\System\Extensions\Themes
- install - parameters: $extensionZipFile, $slug, $success - when a theme is installed
Plugins
Vvveb\System\Extensions\Plugins
- setup - parameters: $pluginName, $site_id - first plugin activation, use this event to create tables or other first time run of your plugin
- activate - parameters: $pluginName, $site_id - when a plugin is activated
- deactivate - parameters: $pluginName, $site_id - when a plugin is deactivated
- uninstall - parameters: $pluginName, $success - when a plugin is uninstalled/removed
Controllers
Post / Product pages
Vvveb\Controller\Content\<Type> and Vvveb\Controller\Product\<Type> - the namespace is built dynamically from the post/product type ($class = __NAMESPACE__ . '\\' . ucfirst($this->type)), so for default types attach to Vvveb\Controller\Content\Post and Vvveb\Controller\Product\Product:
- index - parameters: $content, $language, $slug - before post/product data is processed
- index:after - parameters: $content, $languageContent, $language, $slug - after content is processed
User Login
Login runs through Vvveb\Controller\User\LoginTrait::login() (used by Vvveb\Controller\User\Login and the checkout controller). Inside a trait, __CLASS__ resolves to the using class, so attach to:
Vvveb\Controller\User\Login
- login - parameters: $userInfo - before user login data is checked, use it to cancel login by returning
false(falsy$userInfoaborts the login) or to add info/run an action.
User Signup
Vvveb\Controller\User\Signup
- addUser - parameters: $userInfo - before a user is created, use it to cancel user creation by returning false or add additional info or run an action.
User Reset
Vvveb\Controller\User\Reset
- index - parameters: $loginData - before a password reset is checked for the email use it to cancel password reset by returning false or add additional info or run an action.