slack/src/Options/Base.php

53 lines
1.3 KiB
PHP

<?php
namespace Slack\Options;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Slack\Base as SlackBase;
abstract class Base extends SlackBase
{
// Does the event respond with a reply to the HTTP request, or via a post with a trigger
// Child class should have a respond() function.
// (There should be a local implementation of the child class should respondNow = TRUE)
public $respondNow = TRUE;
public function __construct(array $request)
{
Log::info(sprintf('SOb:Slack INTERACTIVE MESSAGE Initialised [%s]',get_class($this)),['m'=>__METHOD__]);
// Our data is in a payload value
parent::__construct($request);
}
/**
* Enable getting values for keys in the response
*
* @note: This method is limited to certain values to ensure integrity reasons
* @note: Classes should return:
* + channel_id,
* + team_id,
* + ts,
* + user_id
* @param string $key
* @return mixed|object
*/
public function __get(string $key)
{
switch ($key) {
case 'team_id':
return object_get($this->_data,'team.id');
case 'channel_id':
return object_get($this->_data,'channel.id');
case 'user_id':
return object_get($this->_data,'user.id');
case 'callback_id':
//case 'action_ts':
//case 'message_ts':
case 'type':
return object_get($this->_data,$key);
}
}
}