mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-20 05:13:42 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -35,6 +35,7 @@ class HandlerList implements \Countable
|
|||
const VALIDATE = 'validate';
|
||||
const BUILD = 'build';
|
||||
const SIGN = 'sign';
|
||||
const ATTEMPT = 'attempt';
|
||||
|
||||
/** @var callable */
|
||||
private $handler;
|
||||
|
@ -50,6 +51,7 @@ class HandlerList implements \Countable
|
|||
|
||||
/** @var array Steps (in reverse order) */
|
||||
private $steps = [
|
||||
self::ATTEMPT => [],
|
||||
self::SIGN => [],
|
||||
self::BUILD => [],
|
||||
self::VALIDATE => [],
|
||||
|
@ -201,6 +203,28 @@ class HandlerList implements \Countable
|
|||
$this->add(self::SIGN, $name, $middleware, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a middleware to the attempt step.
|
||||
*
|
||||
* @param callable $middleware Middleware function to add.
|
||||
* @param string $name Name of the middleware.
|
||||
*/
|
||||
public function appendAttempt(callable $middleware, $name = null)
|
||||
{
|
||||
$this->add(self::ATTEMPT, $name, $middleware);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend a middleware to the attempt step.
|
||||
*
|
||||
* @param callable $middleware Middleware function to add.
|
||||
* @param string $name Name of the middleware.
|
||||
*/
|
||||
public function prependAttempt(callable $middleware, $name = null)
|
||||
{
|
||||
$this->add(self::ATTEMPT, $name, $middleware, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a middleware before the given middleware by name.
|
||||
*
|
||||
|
@ -286,7 +310,8 @@ class HandlerList implements \Countable
|
|||
return count($this->steps[self::INIT])
|
||||
+ count($this->steps[self::VALIDATE])
|
||||
+ count($this->steps[self::BUILD])
|
||||
+ count($this->steps[self::SIGN]);
|
||||
+ count($this->steps[self::SIGN])
|
||||
+ count($this->steps[self::ATTEMPT]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,12 +359,14 @@ class HandlerList implements \Countable
|
|||
{
|
||||
if (is_string($fn)) {
|
||||
return "callable({$fn})";
|
||||
} elseif (is_array($fn)) {
|
||||
}
|
||||
|
||||
if (is_array($fn)) {
|
||||
$ele = is_string($fn[0]) ? $fn[0] : get_class($fn[0]);
|
||||
return "callable(['{$ele}', '{$fn[1]}'])";
|
||||
} else {
|
||||
return 'callable(' . spl_object_hash($fn) . ')';
|
||||
}
|
||||
|
||||
return 'callable(' . spl_object_hash($fn) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue