- Issue created by @joachim
- Assigned to bmahesh03121
- Status changed to Needs work
12 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.
- 🇬🇧United Kingdom jacobupal Leeds
Updated the proposed resolution with regards to providing more settings.
The changed the snippet is describing the default values not possible options.
- Merge request !9615Issue #3436435 by bmahesh03121, joachim: Update the documentation for... → (Closed) created by bmahesh03121
- 🇬🇧United Kingdom ChrisDarke London
Hi bmahesh03121, please do not assign core issues to yourself, these should just be commented on, with something similar to "I am working on this issue for the next week".
Also please try to not do updates on issues that are marked as reserved for Mentored Contribution, thanks!
- Issue was unassigned.
- 🇧🇷Brazil brandonlira
Status update / Question: It looks like the docblock has been updated to address the visibility and region defaults. Is there anything else that needs to be done for this issue? If not, I can help test or review the current changes.
Thanks!
- 🇬🇧United Kingdom joachim
MR looks good. Test failures are unrelated JS issues.
- 🇮🇳India Sivaji_Ganesh_Jojodae Chennai
On a related note, shouldn't we use wildcard
/*
instead of empty array[]
to indicate the global visibility to be inline with the page visibility settings? - First commit to issue fork.