This file contains hidden or 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
/** | |
* Enable language module, delete english and set french as default. | |
*/ | |
function my_module_update_N() { | |
\Drupal::service('module_installer')->install(['language']); | |
// Enable french language and set it as default. | |
if (NULL === ConfigurableLanguage::load('fr')) { | |
ConfigurableLanguage::create([ | |
'id' => 'fr', |
This file contains hidden or 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 | |
/** | |
* Helper to hide the page title (see THEME_preprocess_page). | |
*/ | |
function _feature_commons_hide_title($value = NULL) { | |
$static = &drupal_static(__FUNCTION__, FALSE); | |
if (NULL !== $value) { | |
$static = (bool) $value; | |
} |
This file contains hidden or 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 | |
use Drupal\node\Entity\Node; | |
/** | |
* Implements hook_ENTITY_TYPE_create(). | |
*/ | |
function my_module_node_create(Node $node) { | |
if ($node->bundle() == 'my_bundle') { | |
$field = $node->get('field_my_paragraph_field'); |
This file contains hidden or 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
#!/bin/bash | |
RAND=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32) | |
SQLITE="/mnt/ramdisk/d8test.sqlite.$RAND" | |
DBURL="sqlite://localhost//mnt/ramdisk/d8test.sqlite.BASE" | |
URL="http://d8test.sqlite" | |
CONC=6 | |
if [ $1 ]; then | |
if [ $1 == "group" ] & [ $2 ]; then |
This file contains hidden or 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
/** | |
* Implements hook_install(). | |
*/ | |
function my_module_install() { | |
$bean = bean_create(array('type' => 'simple')); | |
$bean->label = 'Mon bloc simple custom'; | |
$bean->title = ''; | |
$bean->delta = 'my-delta'; | |
$bean->field_content = array( | |
LANGUAGE_NONE => array( |
This file contains hidden or 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
// Declaration globale. | |
window.MonHelper = { | |
function1: function (context, settings) { alert("truc de base"); } | |
}; | |
(function ($, Drupal) { | |
"use strict"; | |
Drupal.behaviors.TrucDuCore = { | |
attach: function (context, settings) { |
This file contains hidden or 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
#!/bin/bash | |
RAND=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32) | |
SQLITE="/mnt/ramdisk/d8test.sqlite.$RAND" | |
DBURL="sqlite://localhost//mnt/ramdisk/d8test.sqlite.BASE" | |
URL="http://d8test.sqlite" | |
CONC=6 | |
if [ $1 ]; then | |
if [ $1 == "group" ] & [ $2 ]; then |
This file contains hidden or 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
/** | |
* Implements hook_ENTITY_TYPE_presave(). | |
* | |
* Force the expanded state on menu items in the main menu. | |
*/ | |
function MYMODULE_menu_link_content_presave(MenuLinkContentInterface $entity) { | |
if ($entity->get('menu_name')->value == 'main') { | |
$entity->get('expanded')->set(0, TRUE); | |
} | |
} |
This file contains hidden or 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 | |
/** | |
* @file | |
* Contains \Drupal\sf_test\Controller\DefaultController. | |
*/ | |
namespace Drupal\sf_test\Controller; | |
use Drupal\Core\Controller\ControllerBase; |
This file contains hidden or 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 | |
$vocabulary_name = 'my_machine_name'; | |
$root_tid = 0; | |
$vocabulary = $this->vocabularyStorage->load($vocabulary_name); | |
$terms = $this->termStorage->loadTree($vocabulary->id(), $root_tid); | |
$tree = [$root_tid => []]; | |
foreach ($terms as $term) { | |
$tree[$term->tid] = [ |