Skip to content

Instantly share code, notes, and snippets.

@opi
opi / OpiToolsCommands.php
Last active January 14, 2021 11:17
Drupal9 - Create field_group from drush command
<?php
namespace Drupal\opitools\Commands;
use Drush\Commands\DrushCommands;
use Drupal\Core\Language\LanguageInterface;
/**
* A Drush commandfile.
*
@opi
opi / drupal7_contrib_update.sh
Created December 4, 2020 08:20
Automate Drupal7 contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
@opi
opi / drupal7_core_update.sh
Created December 4, 2020 08:19
Automate Drupal7 core update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
@opi
opi / drupal_contrib_update.sh
Created September 14, 2020 08:40
Drupal 7 Contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
@opi
opi / drupal_contrib_update.sh
Created March 9, 2020 09:32
Drupal 7 contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
# Get document root path
@opi
opi / module.php
Created March 11, 2019 12:41
Drupal 8 Custom form mode
<?php
/**
* Implements hook_entity_form_display_alter().
*/
function MY_MODULE_entity_form_display_alter(&$form_display, array $context) {
if ($context['entity_type'] == 'node' && $context['bundle'] == 'MY_BUNDLE') {
$current_user = \Drupal::currentUser();
if ($current_user->hasPermission('CUSTOM PERMISSION')) {
$storage = \Drupal::entityManager()->getStorage('entity_form_display');
@opi
opi / a11y_question.md
Last active September 12, 2018 06:02
a11y_question.md

a11y question

On a screen we want to display this sentence: Limit to X messages per Y, where X and Y are dropdown list of options.

On a screen reader we want 2 distinct fields with corresponding label:

  • Email send limit X
  • Email send time window Y

Note: Label are hidden with the .element-invisible class, using the clip method.

<?php
$form['numeric_default_zero'] = array(
'#type' => 'radios',
'#title' => "Only numeric keys, starting at 0. #default_value to 0",
'#default_value' => 0,
'#options' => array(
0 => "key: 0",
1 => "key: 1",
2 => "key: 2",
@opi
opi / skype_on_debian_stretch.md
Last active July 1, 2021 21:56
Install Skype on Debian Stretch

Install Skype on Debian Stretch

Install the GPG key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1F3045A5DF7587C3

Ensure apt is set up to work with https sources:

sudo apt-get install apt-transport-https