createBlock example


  protected static $modules = ['node', 'block', 'user', 'field'];

  /** * Tests that exposed filter blocks have the correct dependencies. * * @see \Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock::getDerivativeDefinitions() */
  public function testExposedBlock() {
    $block = $this->createBlock('views_exposed_filter_block:test_exposed_block-page_1');
    $dependencies = $block->calculateDependencies()->getDependencies();
    $expected = [
      'config' => ['views.view.test_exposed_block'],
      'module' => ['views'],
      'theme' => ['stark'],
    ];
    $this->assertSame($expected$dependencies);
  }

  /** * Tests that exposed filter blocks have the correct dependencies. * * @see \Drupal\views\Plugin\Derivative\ViewsBlock::getDerivativeDefinitions() */
/** * Formats a message as a block of text. * * @return void */
    public function block(string|array $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
    {
        $messages = \is_array($messages) ? array_values($messages) : [$messages];

        $this->autoPrependBlock();
        $this->writeln($this->createBlock($messages$type$style$prefix$padding$escape));
        $this->newLine();
    }

    /** * @return void */
    public function title(string $message)
    {
        $this->autoPrependBlock();
        $this->writeln([
            sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
            
/** * Formats a message as a block of text. * * @return void */
    public function block(string|array $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
    {
        $messages = \is_array($messages) ? array_values($messages) : [$messages];

        $this->autoPrependBlock();
        $this->writeln($this->createBlock($messages$type$style$prefix$padding$escape));
        $this->newLine();
    }

    /** * @return void */
    public function title(string $message)
    {
        $this->autoPrependBlock();
        $this->writeln([
            sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
            
Home | Imprint | This part of the site doesn't use cookies.