Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/subzerobo/sabalim-action-wrapper
Action Wrapper Library for Before/After Specific action handling
https://github.com/subzerobo/sabalim-action-wrapper
php php-library php7 slim3
Last synced: 20 days ago
JSON representation
Action Wrapper Library for Before/After Specific action handling
- Host: GitHub
- URL: https://github.com/subzerobo/sabalim-action-wrapper
- Owner: subzerobo
- Created: 2019-04-25T07:38:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-25T10:23:10.000Z (over 5 years ago)
- Last Synced: 2024-10-15T01:21:43.150Z (2 months ago)
- Topics: php, php-library, php7, slim3
- Language: PHP
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sabalim-Action-Wrapper
Action Wrapper Library for Before/After Specific action handling, this library provides the abstraction layer for other libraries specially for Sabalim-Elastic-Apm-PHP-Agent.
### HandlerInterface
Interface provides two functions which whould run before and after any specific actioninterface HandlerInterface{
public function handleBefore($parent, string $actionName, array $actionData = []);
public function handleAfter($parent, string $actionName, array $actionData = []);
}
`$parent` is your main object which it's action(s) need to be wrapped for example you can pass the `redis` object
`$actionName` is the context of the action you are trying to wrap
`$actionData` is the extra data you whould like to pass to the wrapper### HandlerAbstract
HandlerAbstract class implements the HandlerInterface and does claculate the action event duration by default but you can pass the `start` and `end` microtime to override the default implemented codeIt has the built-in DataStore to save the extra parameters passed in `handleBefore` to be used later in `handlerAfter` method.
Your custom handlers may extend this class.
class myCustomHandler extends HandlerAbstract
{
private $your_custom_private;
public $your_custom_public;
public function handleBefore($request, string $actionName, array $actionData = [])
{
parent::handleBefore($request, $actionName, $actionData);
// Your code ...
}
public function handleAfter($request, string $actionName, array $actionData = [])
{
parent::handleAfter($request, $actionName, $actionData);
// Your code ...
}
}