You are here

public function TrumbaBlockBase::blockValidate in Trumba 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Block/TrumbaBlockBase.php \Drupal\trumba\Plugin\Block\TrumbaBlockBase::blockValidate()

Overrides BlockPluginTrait::blockValidate

File

src/Plugin/Block/TrumbaBlockBase.php, line 118

Class

TrumbaBlockBase
Defines a base block implementation that Trumba blocks plugins will extend.

Namespace

Drupal\trumba\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) {

  // Ensure that internal url's start with a forward slash.
  $rawUrl = $form_state
    ->getValue('trumba_spud_url');
  $firstChar = substr($rawUrl, 0, 1);
  if (!empty($rawUrl) && !$this
    ->isExternalUri($rawUrl) && $firstChar != '/') {
    $form_state
      ->setErrorByName('trumba_spud_url', $this
      ->t('Internal Url\'s must begin with a forward slash.'));
  }
}