-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Description
When trying to edit a webhook I get the following error:
Class modules\webhookfiltersmodule\filters\UsersChannelFilter contains 9 abstract methods and must therefore be declared abstract or implement the remaining methods (yii\base\StaticInstanceInterface::instance, IteratorAggregate::getIterator, ArrayAccess::offsetExists, ...)
In my learning about this all (bit of a newbie to custom modules) it is my understand that there are some additional methods needed to be declared in order to implement the FilterInterface class.
Wondering if the example in the readme may need to be updated with a better example.
Here is the the code for the filter that is inspiring this error. Like the readme we declare displayName, show, and check. We also declare isSelectable which I am guessing was required for Craft 3.x
Appreciate any guidance so we can get this Craft 4 update complete (and others as we use Webhooks and custom filters on a few sites.
<?php
namespace modules\webhookfiltersmodule\filters;
use craft\elements\User;
use craft\events\UserAssignGroupEvent;
use craft\services\Users;
use craft\webhooks\filters\FilterInterface;
use yii\base\Event;
class UsersChannelFilter implements FilterInterface
{
public static function displayName(): string
{
return 'Only send on confirmation step';
}
public static function isSelectable(): bool
{
return false;
}
public static function show(string $class, string $event): bool
{
return $class === Users::class || $class === User::class;
}
public static function check(Event $event, bool $value): bool
{
/** @var UserAssignGroupEvent|Event $event */
/** @var User $user */
$user = is_a($event, UserAssignGroupEvent::class) ? $event->user : $event->sender;
$user = User::find()->id($user->id)->anyStatus()->one();
$status = $user->getFieldValue('saveOrigin');
if ($status == 'send') {
return true;
}
return false;
}
}
Steps to reproduce
Additional info
- Craft version: 4.3.1
- PHP version: 8.0.24
- Database driver & version:
- Plugins & versions: Webhook 3.0.4
Metadata
Metadata
Assignees
Labels
No labels