accessBlockPlugin example

$block_plugin->willImplement(PluginWithFormsInterface::class);
      $block_plugin->hasFormClass(Argument::type('string'))->will(function D$arguments) use ($plugin_definition) {
        return !empty($plugin_definition['forms'][$arguments[0]]);
      });
    }

    $block = $this->prophesize(BlockInterface::class);
    $block->getPlugin()->willReturn($block_plugin->reveal());

    $access_check = new BlockPluginHasSettingsTrayFormAccessCheck();
    $this->assertEquals($expected_access_result$access_check->access($block->reveal()));
    $this->assertEquals($expected_access_result$access_check->accessBlockPlugin($block_plugin->reveal()));
  }

  /** * Provides test data for ::testAccess(). */
  public static function providerTestAccess() {
    $annotation_forms_settings_tray_class = [
      'forms' => [
        'settings_tray' => Random::machineName(),
      ],
    ];
    

  public function access(BlockInterface $block) {
    /** @var \Drupal\Core\Block\BlockPluginInterface $block_plugin */
    $block_plugin = $block->getPlugin();
    return $this->accessBlockPlugin($block_plugin);
  }

  /** * Checks access for accessing a block plugin's 'settings_tray' form. * * @param \Drupal\Core\Block\BlockPluginInterface $block_plugin * The block plugin whose 'settings_tray' form is being accessed. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. * * @see settings_tray_preprocess_block() */
Home | Imprint | This part of the site doesn't use cookies.