Skip to content

Instantly share code, notes, and snippets.

View lcube45's full-sized avatar
🏌️‍♂️
Focusing

lcube lcube45

🏌️‍♂️
Focusing
View GitHub Profile
@lcube45
lcube45 / Blocks.md
Created January 13, 2020 15:36 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
;lsof -nP -i4TCP:9000 | grep LISTEN
;xdebug.remote_log=/fullpath/xdebug.log
opcache.enable=1
xdebug.coverage_enable=off
xdebug.extended_info=off
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
@lcube45
lcube45 / gist:38e28ad3c7f341ca7c5c52cb19260abc
Created June 1, 2020 14:46
Drupal 8 - vider des caches spécifiques
// vider les caches spécifiques
$ drush cc drush
$ drush cc theme-registry
$ drush cc router
$ drush cc css-js
$ drush cc module-list
$ drush cc theme-list
$ drush cc render
$ drush cc token
$ drush cc views
@lcube45
lcube45 / gist:2c35ff4681dcba14fd00f0a7bcab838e
Created June 1, 2020 14:47
Drupal 8 - modèle physique de données pour les entités
Drupal 8:
----------
- Content type = Bundle
- Node = Entity
- Base fields are in one table: [entity]_field_data
- Bundle fields are in seperate tables: [entity]__field_name
@lcube45
lcube45 / AjaxForm.php
Created June 1, 2020 14:48
Drupal 8 - ajax callback
<?php
class AjaxForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'ajax_form';
}
@lcube45
lcube45 / AjaxForm.php
Created June 1, 2020 14:51
Drupal 8 - ajax callback & alter form
<?php
class SimpleForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'simple_form';
}
@lcube45
lcube45 / gist:707670a4d31c571d19db1444a6827374
Created June 1, 2020 14:52
Drupa 8 - find base form id
<?php
$form_state->getBuildInfo()['base_form_id'];
@lcube45
lcube45 / gist:64532c7773d20d3bbfeb24e5995a29b4
Created June 1, 2020 14:52
Drupal - fix missing module message error
# https://www.drupal.org/node/2487215
drush sql-query "DELETE FROM key_value WHERE collection='system.schema' AND name='module_name';"
@lcube45
lcube45 / gist:e1bcfb9392392a09c13e593a1f598380
Created June 1, 2020 14:53
Drupal 8 - composer download a specific module version
Specifying a version you can specify a version from the command line with:
composer require drupal/<modulename>:<version>
For example:
composer require drupal/ctools:3.0.0-alpha26
composer require drupal/token:1.x-dev
@lcube45
lcube45 / gist:b634852c51ec100be64433a211e34e3a
Created June 1, 2020 14:54
Drupal 8 - récupérer l'arborescence des termes
<?php
namespace Drupal\mon_module\Tools
use Drupal\taxonomy\Entity\Term;
/**
* Service de récupération d'arborescence de termes
*
* @package Drupal\mon_module\Tools