Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Drupal\block_test\Plugin\Block; use Drupal\Core\Block\BlockBase; use Dru..

Decoded Output download

<?php

namespace Drupallock_test\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a test settings validation block.
 *
 * @Block(
 *  id = "test_settings_validation",
 *  admin_label = @Translation("Test settings validation block"),
 * )
 */
class TestSettingsValidationBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    return ['digits' => ['#type' => 'textfield']] + $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockValidate($form, FormStateInterface $form_state) {
    if (!ctype_digit($form_state->getValue('digits'))) {
      $form_state->setErrorByName('digits', $this->t('Only digits are allowed'));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    return ['#markup' => 'foo'];
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Drupal\block_test\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a test settings validation block.
 *
 * @Block(
 *  id = "test_settings_validation",
 *  admin_label = @Translation("Test settings validation block"),
 * )
 */
class TestSettingsValidationBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    return ['digits' => ['#type' => 'textfield']] + $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockValidate($form, FormStateInterface $form_state) {
    if (!ctype_digit($form_state->getValue('digits'))) {
      $form_state->setErrorByName('digits', $this->t('Only digits are allowed'));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    return ['#markup' => 'foo'];
  }

}

Function Calls

None

Variables

None

Stats

MD5 587b2756ea283c237e5b62da01ee2b4f
Eval Count 0
Decode Time 72 ms