- Issue created by @joachim
- Assigned to bmahesh03121
- Status changed to Needs work
3 months ago 9:26am 28 March 2024 - 🇮🇳India bmahesh03121
/** * Creates a block instance based on default settings. * * @param string $plugin_id * The plugin ID of the block type for this block instance. * @param array $settings * (optional) An associative array of settings for the block entity. * Override the defaults by specifying the key and value in the array, for * example: * @code * $this->drupalPlaceBlock('system_powered_by_block', array( * 'label' => t('Hello, world!'), * )); * @endcode * The following defaults are provided: * - label: Random string. * - id: Random string. <del>* - region: 'sidebar_first'.</del> * - region: 'content'. * - theme: The default theme. * - visibility: Empty array (block will be visible on all pages). * * @return \Drupal\block\Entity\Block * The block entity. * * @todo * Add support for creating content block instances. */ protected function placeBlock($plugin_id, array $settings = []) { $config = \Drupal::configFactory(); $settings += [ 'plugin' => $plugin_id, 'region' => 'content', 'id' => $this->randomMachineName(8), 'theme' => $config->get('system.theme')->get('default'), 'label' => $this->randomMachineName(8), 'visibility' => [], 'weight' => 0, ];
@joachim looking at this, i found that the default value for region is
sidebar_first
, but in function definition its taking
content
as default region
+ will it be good idea to provide the example with few more settings like visibility, region, theme instead of just label.