mc-cms-namelessmc/core/classes/Events/HookBase.php
Partydragen 370430256f
Remove deprecated event system (#3631)
* Remove old event system & Convert renderPost event

* Remove old event system

* Misc

* Convert Custom Pages to use new event system

* Change RenderPost to RenderContent

* Convert profile posts and messaging

* All events converted

* Fixes

* Fixes

* Add tag support in Profile Posts & Messaging

* Execute rendercreate for profile post reply

* Update webhooks

* Remove return function

* Remove array response

* Remove more array response

* Remove fallback webhooks

* Test phpstan

* Fix phpdoc

* Remove name() & description()
2025-05-02 10:19:52 -07:00

37 lines
848 B
PHP

<?php
/**
* Base for hook implementations.
*
* @package NamelessMC\Events
* @author Samerton
* @version 2.3.0
* @license MIT
*/
abstract class HookBase
{
/**
* Ensure a set of parameters has all the required fields.
*
* @param AbstractEvent $event Event to check
* @param array $required_params Array of required parameter keys
*
* @return bool Whether $params contains all of $required_params
*/
protected static function validateParams(AbstractEvent $event, array $required_params): bool
{
$params = $event->params();
if (empty($params)) {
return false;
}
foreach ($required_params as $required) {
if (empty($params[$required])) {
return false;
}
}
return true;
}
}