slack/src/Blockkit/BlockAction.php
2021-08-12 14:09:40 +10:00

41 lines
867 B
PHP

<?php
namespace Slack\Blockkit;
use Slack\BlockKit;
use Slack\Blockkit\Blocks\TextEmoji;
/**
* This class creates a slack actions used in BlockKit Actions
* @todo Still needed?
*/
class BlockAction extends BlockKit
{
/**
* Add a block button
*
* @param string $text
* @param string $action
* @param string $value
* @param string $style
* @return BlockAction
* @throws \Exception
* @deprecated Move to Blocks/Button?
*/
public function addButton(TextEmoji $text,string $action,string $value,string $style=''): self
{
if ($style AND ! in_array($style,['primary','danger']))
abort('Invalid style: '.$style);
$this->_data->put('type','button');
$this->_data->put('action_id',$action);
$this->_data->put('text',$text);
$this->_data->put('value',$value);
if ($style)
$this->_data->put('style',$style);
return $this;
}
}