/
AbstractStorageInterface.php
59 lines (48 loc) · 1.61 KB
/
AbstractStorageInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace pcrt\file;
use pcrt\file\StorageInterface;
use yii\base\NotSupportedException;
abstract class AbstractStorageInterface implements StorageInterface
{
/**
* @var Handler
*/
private $nextHandler;
public function setNext(StorageInterface $handler): StorageInterface
{
$this->nextHandler = $handler;
// Returning a handler from here will let us link handlers in a
// convenient way like this:
// $monkey->setNext($squirrel)->setNext($dog);
return $handler;
}
public function handle(object $request): ?object
{
// Need Improve Error Manage
$method = $request->method;
$request = $this->$method($request);
\Yii::warning(get_class($this));
\Yii::warning($request);
// Call Next Method
if ($this->nextHandler) {
return $this->nextHandler->handle($request);
}
return $request;
}
public function put(object $request): ?object
{
throw new NotSupportedException('Method "' . __CLASS__ . '::' . __METHOD__ . '" is not implemented.');
}
public function get(object $request): ?object
{
throw new NotSupportedException('Method "' . __CLASS__ . '::' . __METHOD__ . '" is not implemented.');
}
public function rm(object $request): ?object
{
throw new NotSupportedException('Method "' . __CLASS__ . '::' . __METHOD__ . '" is not implemented.');
}
public function update(object $request): ?object
{
throw new NotSupportedException('Method "' . __CLASS__ . '::' . __METHOD__ . '" is not implemented.');
}
}