-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes incorrect references to "WP_error" #1 (#29) * Introduces find method in Loader Registry. #28 (#30) Resolves #28 * Issue/31 - Introduce middleware API (#33) * Moves has_trait method in Underpin class. #31 This helper method is something that can be used outside of this system. With the trend of adding methods to Underpin as static methods, it makes sense to move this method, as well. * Introduces Middleware API. #31 * Updates Readme #31
- Loading branch information
1 parent
36b21bc
commit 6689264
Showing
7 changed files
with
522 additions
and
93 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,61 @@ | ||
<?php | ||
/** | ||
* A single instance of Middleware | ||
* | ||
* @since 1.3.0 | ||
* @package Underpin\Abstracts | ||
*/ | ||
namespace Underpin\Abstracts; | ||
|
||
|
||
use Underpin\Factories\Loader_Registry_Item; | ||
use Underpin\Traits\Feature_Extension; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Class Middleware | ||
* | ||
* @since 1.3.0 | ||
* @package Underpin\Abstracts | ||
*/ | ||
abstract class Middleware { | ||
|
||
use Feature_Extension; | ||
|
||
/** | ||
* Loader Item | ||
* | ||
* @var Loader_Registry_Item The loader item | ||
*/ | ||
protected $loader_item; | ||
|
||
/** | ||
* The priority in which this middleware should be ran. | ||
* | ||
* @since 1.3.0 | ||
* @var int | ||
*/ | ||
protected $priority = 10; | ||
|
||
/** | ||
* Sets the middleware's loader. | ||
* | ||
* @since 1.3.0 | ||
* | ||
* @param Loader_Registry_Item|string|array $loader_item The loader item to set | ||
*/ | ||
public function set_loader( $loader_item ) { | ||
$this->loader_item = $loader_item; | ||
} | ||
|
||
public function __get( $key ) { | ||
if ( isset( $this->$key ) ) { | ||
return $this->$key; | ||
} else { | ||
return new \WP_Error( 'middleware_param_not_set', 'The middleware key ' . $key . ' could not be found.' ); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.