1. Go to this page and download the library: Download craftcms/webhooks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use yii\base\Event;
use craft\webhooks\Plugin as Webhooks;
use craft\events\RegisterComponentTypesEvent;
Event::on(
Webhooks::class,
Webhooks::EVENT_REGISTER_FILTER_TYPES,
function(RegisterComponentTypesEvent $event) {
$event->types[] = ArticleFilter::class;
}
);
use craft\webhooks\filters\FilterInterface;
use craft\elements\Entry;
use yii\base\Event;
class ArticleFilter implements FilterInterface
{
public static function displayName(): string
{
return 'Entry has an “Article” type';
}
public static function show(string $class, string $event): bool
{
// Only show this filter if the Sender Class is set to 'craft\elements\Entry'
return $class === Entry::class;
}
public static function check(Event $event, bool $value): bool
{
// Filter based on whether the entry's type is 'article':
/** @var Entry $entry */
$entry = $event->sender;
return ($entry->type->handle === 'article') === $value;
}
}
return [
'disableAllWebhooks' => true,
// ...
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.