-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4.13' of https://github.com/craftcms/cms into 5.5
- Loading branch information
Showing
4 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* @link https://craftcms.com/ | ||
* @copyright Copyright (c) Pixel & Tonic, Inc. | ||
* @license https://craftcms.github.io/license/ | ||
*/ | ||
|
||
namespace craft\filters; | ||
|
||
/** | ||
* Filter for ensuring the user should be able to access the configured utility. | ||
* | ||
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 5.5.0 | ||
*/ | ||
trait ConditionalFilterTrait | ||
{ | ||
/** | ||
* @var callable|null A PHP callable that determines when this filter should be applied. | ||
*/ | ||
public mixed $when = null; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function isActive(mixed $action): bool | ||
{ | ||
// Retain only/except logic | ||
if (!parent::isActive($action)) { | ||
return false; | ||
} | ||
|
||
if (isset($this->when) && !call_user_func($this->when, $action)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters