This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Views Bulk Operations doesn't respect Role Delegation's permissions in the "Modify user roles" | |
* action and will offer all roles as options to add or remove from the users being edited. This form | |
* alter fixed that by checking which roles the user had permissions to assign and altering the options | |
* in the select element. | |
* | |
* This is no longer needed since I can just use the "Delegate roles" action provided by Role Delegation. | |
* I didn't realise that was there! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Reboot system if required | |
command: shutdown -r now 'Rebooting to complete system upgrade' removes=/var/run/reboot-required | |
register: reboot_required | |
tags: | |
- apt | |
- updates | |
- name: Wait for server to come back. | |
local_action: wait_for port={{ ansible_ssh_port }} host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10 | |
when: reboot_required.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function themename_theme_suggestions_block_alter(array &$suggestions, array $variables) { | |
$elements = $variables['elements']; | |
if (isset($elements['content']['#block_content'])) { | |
$bundle = $elements['content']['#block_content']->bundle(); | |
if ($bundle == 'bundle_name') { | |
$suggestions[] = 'block__template_name'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements template_preprocess_paragraph(). | |
*/ | |
function TEMPLATE_preprocess_paragraph(&$variables) { | |
$paragraph = $variables['paragraph']; | |
$bundle = $paragraph->bundle(); | |
if ($bundle == 'mybundle') { | |
// do stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This will load the view from config, set a new name and ID, then change the vocabulary to tags. | |
$config = \Drupal::configFactory()->getEditable('views.view.blog_categories'); | |
$config->setName('views.view.blog_categories_tags'); | |
$config->set('id', 'blog_categories_tags'); | |
$config->set('display.default.display_options.filters.vid.value', ['tags' => 'tags']); | |
$config->save(TRUE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_theme_suggestions_HOOK_alter(). | |
*/ | |
function THEME_theme_suggestions_image_alter(&$suggestions, $variables) { | |
// Get the directory and filename. | |
// Need to use dir and filename to form the URI, since trying to load the file by filename alone | |
// will skip files that might have been uploaded with the same name as another and had "_0" added to the end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\my_module\EventSubscriber; | |
use Drupal\Core\Routing\RouteSubscriberBase; | |
use Drupal\Core\Routing\RoutingEvents; | |
use Symfony\Component\Routing\RouteCollection; | |
/** | |
* My module route subscriber. |