TrumbaMainCalendarSpudBlock.php in Trumba 2.x
File
src/Plugin/Block/TrumbaMainCalendarSpudBlock.php
View source
<?php
namespace Drupal\trumba\Plugin\Block;
use Drupal\Core\Form\FormStateInterface;
class TrumbaMainCalendarSpudBlock extends TrumbaBlockBase {
public function blockForm($form, FormStateInterface $form_state) {
$form = parent::blockForm($form, $form_state);
$form['trumba_main_calendar_open_events'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Open events in new window'),
'#description' => $this
->t(''),
'#default_value' => isset($this->configuration['trumba_main_calendar_open_events']) ? $this->configuration['trumba_main_calendar_open_events'] : '',
'#weight' => '3',
];
return $form;
}
public function blockSubmit($form, FormStateInterface $form_state) {
parent::blockSubmit($form, $form_state);
$this->configuration['trumba_main_calendar_open_events'] = $form_state
->getValue('trumba_main_calendar_open_events');
}
public function build() {
$params = [
'spudId' => $this->spudId,
'webName' => $this->configuration['trumba_web_name'],
'detailBase' => $this
->convertUriToAbsolutePathOrUrl($this->configuration['trumba_spud_url']),
'spudType' => 'main',
'openInNewWindow' => $this->configuration['trumba_main_calendar_open_events'],
];
$cache_spud_id = str_ireplace('_', '-', $this
->getPluginId());
return _trumba_spud_embed($this->spudId, $params, $cache_spud_id);
}
}