<?php
namespace Maknz\Slack\BlockElement;
use DateTime;
use Maknz\Slack\PlaceholderTrait;
abstract class Temporalpicker extends Confirmable
{
use PlaceholderTrait;
protected $initial_value;
protected function getInitialValue()
{
return $this->initial_value;
}
protected function setInitialValue(DateTime $initialValue)
{
$this->initial_value = $initialValue;
return $this;
}
abstract protected function getInitialValueField();
abstract protected function getInitialValueFormat();
public function toArray()
{
$data = [
'type' => $this->getType(),
'action_id' => $this->getActionId(),
];
if ($this->getPlaceholder()) {
$data['placeholder'] = $this->getPlaceholder()->toArray();
}
if ($this->getInitialValue()) {
$data[$this->getInitialValueField()] = $this->getInitialValue()->format($this->getInitialValueFormat());
}
if ($this->getConfirm()) {
$data['confirm'] = $this->getConfirm()->toArray();
}
return $data;
}
}