for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Maknz\Slack\BlockElement;
use Maknz\Slack\CompositionObject\Option;
class Checkboxes extends Options
{
/**
* Block type.
*
* @var string
*/
protected $type = 'checkboxes';
* Internal attribute to property map.
* @var array
protected static $availableAttributes = [
'action_id' => 'action_id',
'options' => 'options',
'confirm' => 'confirm',
];
* Get the intially selected options.
* @return \Maknz\Slack\CompositionObject\Option[]
public function getInitialOptions()
return array_values(array_filter($this->getOptions(), function (Option $o) {
return $o->isInitiallySelected();
}));
}
* Convert the block to its array representation.
* @return array
public function toArray()
$initialOptions = [];
$data = [
'type' => $this->getType(),
'action_id' => $this->getActionId(),
'options' => $this->getOptionsAsArrays(),
foreach ($this->getOptions() as $option) {
if ($option->isInitiallySelected()) {
$initialOptions[] = $option->toArray();
if (count($initialOptions)) {
$data['initial_options'] = $initialOptions;
if ($this->getConfirm()) {
$data['confirm'] = $this->getConfirm()->toArray();
return $data;