Repository navigation
Expand file tree
/
Copy pathAPI.php
More file actions
94 lines (84 loc) · 1.94 KB
/
Copy pathAPI.php
File metadata and controls
94 lines (84 loc) · 1.94 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace Dingo\Api\Facade;
use Dingo\Api\Http\InternalRequest;
use Illuminate\Support\Facades\Facade;
class API extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'api.dispatcher';
}
/**
* Bind an exception handler.
*
* @param callable $callback
*
* @return void
*/
public static function error(callable $callback)
{
return static::$app['api.exception']->register($callback);
}
/**
* Register a class transformer.
*
* @param string $class
* @param string|\Closure $transformer
*
* @return \Dingo\Api\Transformer\Binding
*/
public static function transform($class, $transformer)
{
return static::$app['api.transformer']->register($class, $transformer);
}
/**
* Get the authenticator.
*
* @return \Dingo\Api\Auth\Auth
*/
public static function auth()
{
return static::$app['api.auth'];
}
/**
* Get the authenticated user.
*
* @return \Illuminate\Auth\GenericUser|\Illuminate\Database\Eloquent\Model
*/
public static function user()
{
return static::$app['api.auth']->user();
}
/**
* Determine if a request is internal.
*
* @return bool
*/
public static function internal()
{
return static::$app['api.router']->getCurrentRequest() instanceof InternalRequest;
}
/**
* Get the response factory to begin building a response.
*
* @return \Dingo\Api\Http\Response\Factory
*/
public static function response()
{
return static::$app['api.http.response'];
}
/**
* Get the API router instance.
*
* @return \Dingo\Api\Routing\Router
*/
public static function router()
{
return static::$app['api.router'];
}
}