Last active
June 1, 2023 10:26
-
-
Save reindert-vetter/cef0cd3c058fa7e6c0162198f21aaf16 to your computer and use it in GitHub Desktop.
order history handlers
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
<?php | |
namespace App\Services; | |
use Carbon\Carbon; | |
class OrderHistoryHandlersPipe | |
{ | |
const PROVIDERS = [ | |
CommentsHandlerProvider::class, | |
RuleHandlerProvider::class, | |
AccountingHandlerProvider::class, | |
StandardHistoryHandlerProvider::class, | |
]; | |
/** | |
* @return OrderHistoryHandler[] | |
*/ | |
public static function get(): array | |
{ | |
/** @var OrderHistoryHandler[] $history */ | |
$handlers = collect(); | |
foreach (self::PROVIDERS as $provider) { | |
$handlers = array_merge($handlers, (new $provider())->getHistoryHandlers()); | |
} | |
return $handlers->sort('date')->pagination(1, 100, 'desc'); | |
} | |
} | |
interface OrderHistoryHandler | |
{ | |
/** | |
* @return array|OrderHistoryHandlerInterface[] | |
*/ | |
public function getHistoryHandlers(): array; | |
} | |
interface OrderHistoryHandlerInterface | |
{ | |
/** | |
* @return ActionInterface[] | |
*/ | |
public function actions(): array; | |
public function driver(): string; | |
public function date(): Carbon; | |
public function error(): string; | |
} | |
interface ActionInterface | |
{ | |
public function url(): string; | |
public function method(): string; | |
public function body(): string; | |
// name or icon | |
public function name(): array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment