File tree Expand file tree Collapse file tree 5 files changed +38
-6
lines changed Expand file tree Collapse file tree 5 files changed +38
-6
lines changed Original file line number Diff line number Diff line change 1
1
# Release Notes for Webhooks for Craft CMS
2
2
3
+ ## 2.3.1 - 2020-07-19
4
+
5
+ ### Added
6
+ - Added a new “Element is enabled” filter. ([ #29 ] ( https://github.com/craftcms/webhooks/issues/29 ) )
7
+
3
8
## 2.3.0 - 2020-07-18
4
9
5
10
### Added
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " craftcms/webhooks" ,
3
3
"description" : " Post webhooks when events are triggered in Craft CMS." ,
4
- "version" : " 2.3.0 " ,
4
+ "version" : " 2.3.1 " ,
5
5
"type" : " craft-plugin" ,
6
6
"keywords" : [
7
7
" html" ,
Original file line number Diff line number Diff line change 13
13
use craft \web \UrlManager ;
14
14
use craft \webhooks \filters \DraftFilter ;
15
15
use craft \webhooks \filters \DuplicatingFilter ;
16
+ use craft \webhooks \filters \ElementEnabledFilter ;
16
17
use craft \webhooks \filters \FilterInterface ;
17
18
use craft \webhooks \filters \NewElementFilter ;
18
19
use craft \webhooks \filters \PropagatingFilter ;
@@ -475,6 +476,7 @@ public function getAllFilters(): array
475
476
{
476
477
$ filterTypes = [
477
478
NewElementFilter::class,
479
+ ElementEnabledFilter::class,
478
480
DraftFilter::class,
479
481
RevisionFilter::class,
480
482
DuplicatingFilter::class,
Original file line number Diff line number Diff line change 17
17
*/
18
18
abstract class BaseElementFilter implements FilterInterface
19
19
{
20
- public static function displayName (): string
21
- {
22
- return Craft::t ('webhooks ' , 'Element is a draft ' );
23
- }
24
-
25
20
public static function show (string $ class , string $ event ): bool
26
21
{
27
22
return (is_subclass_of ($ class , ElementInterface::class) || (
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace craft \webhooks \filters ;
4
+
5
+ use Craft ;
6
+ use craft \base \Element ;
7
+ use craft \base \ElementInterface ;
8
+ use craft \events \ElementEvent ;
9
+ use craft \events \ModelEvent ;
10
+ use yii \base \Event ;
11
+
12
+ /**
13
+ * Filters events based on whether the element is enabled
14
+ *
15
+ * @author Pixel & Tonic, Inc. <[email protected] >
16
+ * @since 2.3.1
17
+ */
18
+ class ElementEnabledFilter extends BaseElementFilter
19
+ {
20
+ public static function displayName (): string
21
+ {
22
+ return Craft::t ('webhooks ' , 'Element is enabled ' );
23
+ }
24
+
25
+ protected static function checkElement (ElementInterface $ element , bool $ value ): bool
26
+ {
27
+ /** @var Element $element */
28
+ return $ value === ($ element ->enabled && $ element ->enabledForSite );
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments