-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAbstractController.php
42 lines (37 loc) · 1.11 KB
/
AbstractController.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
<?php
namespace Ihsan\Client\Platform\Controller;
use Ihsan\Client\Platform\Api\ApiClientAwareInterface;
use Ihsan\Client\Platform\Api\ApiClientAwareTrait;
use Ihsan\Client\Platform\Template\TemplateAwareInterface;
use Ihsan\Client\Platform\Template\TemplateAwareTrait;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Muhamad Surya Iksanudin <[email protected]>
*/
abstract class AbstractController implements ControllerInterface, TemplateAwareInterface, ApiClientAwareInterface
{
use TemplateAwareTrait;
use ApiClientAwareTrait;
/**
* @param string $url
* @param string $method
* @param array $data
*
* @return Response
*/
protected function request($url, $method = 'GET', array $data = [])
{
try {
return call_user_func_array([$this, strtolower($method)], [$url, $data]);
} catch (\Exception $exception) {
throw new \RuntimeException('Http method is not valid.');
}
}
/**
* @param string $token
*/
protected function auth($token)
{
$this->client->bearer($token);
}
}