1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Charcoal\Email; |
6
|
|
|
|
7
|
|
|
// From 'psr/http-message' (PSR-7) |
8
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request; |
9
|
|
|
use Psr\Http\Message\ResponseInterface as Response; |
10
|
|
|
|
11
|
|
|
// From 'locomotivemtl/charcoal-app' |
12
|
|
|
use Charcoal\App\Module\AbstractModule; |
13
|
|
|
|
14
|
|
|
use Charcoal\Email\Api\V1\LinkAction; |
15
|
|
|
use Charcoal\Email\Api\V1\OpenAction; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
class ApiModule extends AbstractModule |
21
|
|
|
{ |
22
|
|
|
const BASE_PATH = '/email/v1'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @return self |
26
|
|
|
*/ |
27
|
|
|
public function setUp() |
28
|
|
|
{ |
29
|
|
|
$this->setupPublicRoutes(); |
30
|
|
|
|
31
|
|
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
private function setupPublicRoutes() |
38
|
|
|
{ |
39
|
|
|
$container = $this->app()->getContainer(); |
40
|
|
|
|
41
|
|
|
$this->app()->group(self::BASE_PATH, function() use ($container) { |
42
|
|
|
|
43
|
|
|
$group = $this; |
44
|
|
|
|
45
|
|
|
$group->get('/link/{linkId}', function(Request $request, Response $response, array $args) use ($container) { |
|
|
|
|
46
|
|
|
$action = new LinkAction( |
47
|
|
|
$args['linkId'], |
48
|
|
|
$container['email/tracker'], |
49
|
|
|
$container['model/factory'] |
50
|
|
|
); |
51
|
|
|
return $action($request, $response); |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
$group->get('/open/{emailId}[.png]', function(Request $request, Response $response, array $args) use ($container) { |
|
|
|
|
55
|
|
|
$action = new OpenAction( |
56
|
|
|
$args['emailId'], |
57
|
|
|
$container['email/tracker'] |
58
|
|
|
); |
59
|
|
|
return $action($request, $response); |
60
|
|
|
}); |
61
|
|
|
}); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.