Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F53429666
GateController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
GateController.php
View Options
<?php
namespace
Nasqueron\Notifications\Http\Controllers\Gate
;
use
Nasqueron\Notifications\Http\Controllers\Controller
;
/**
* Represents a controller handling an entry-point for API payloads
*/
class
GateController
extends
Controller
{
///
/// Private members
///
/**
* @var string
*/
protected
$door
;
///
/// Requests
///
/**
* Handles GET requests
*/
public
function
onGet
(
$door
=
null
)
{
// Virtually all the push APIs will send they payloads
// using a POST request, so we can provide a sensible
// default GET error message.
return
view
(
'gate/ispostonly'
);
}
/**
* Logs the request
*/
protected
function
logRequest
()
{
Log
::
info
(
'[Gate] New payload.'
,
[
'service'
=>
static
::
SERVICE_NAME
,
'door'
=>
$this
->
door
,
]);
}
///
/// Credentials
///
/**
* Gets service credentials
*
* @return stdClass the services credentials
*/
protected
function
getServicesCredentials
()
{
$path
=
config
(
'services.gate.credentials'
);
$data
=
json_decode
(
file_get_contents
(
$path
));
return
$data
->
services
;
}
/**
* Determines if a service definition matches this current gate and door.
*
* @param stdClass $service the service to check
*/
protected
function
doesServiceMatch
(
$service
)
{
return
$service
->
gate
==
static
::
SERVICE_NAME
&&
$service
->
door
==
$this
->
door
;
}
/**
* Gets secret for this service and door.
*
* @return string the secret, or if unknown, an empty string
*/
protected
function
getSecret
()
{
foreach
(
$this
->
getServicesCredentials
()
as
$service
)
{
if
(
$this
->
doesServiceMatch
(
$service
))
{
return
$service
->
secret
;
}
}
return
""
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 11, 21:28 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4096094
Default Alt Text
GateController.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment