Skip to content

Instantly share code, notes, and snippets.

Avatar
💦
Drupaling

Matthieu SCARSET MatthieuScarset

💦
Drupaling
View GitHub Profile
@MatthieuScarset
MatthieuScarset / config_entity_type_is_a.php
Created Oct 18, 2021
Drupal - Check if a config entity type is a content entity type (or fieldable entity type...etc)
View config_entity_type_is_a.php
<?php
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
$entity_types = \Drupal::service('entity_type.manager')->getDefinitions();
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity_type */
foreach ($entity_types as $entity_type) {
// Stop now if entity type is not fieldable.
@MatthieuScarset
MatthieuScarset / basefields.php
Last active Sep 22, 2021
Drupal 8 - Programatically create new fields
View basefields.php
<?php
/**
* Implements hook_entity_base_field_info().
*/
function mymodule_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'user') {
$fields = [];
$default_field_definition = [
@MatthieuScarset
MatthieuScarset / entity_autocomplete_views.php
Created Jul 19, 2021
Drupal selection handlers views
View entity_autocomplete_views.php
$args = [];
$form['user_in_charge'] += [
'#title' => t('Entity autocomplete'),
'#type' => 'entity_autocomplete',
'#selection_handler' => 'views',
'#selection_settings' => [
'view' => [
'view_name' => 'view_machine_name',
'display_name' => 'entity_reference',
View gist:8622aa8767f4f6870f61809a8bfe8af8
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:3:bafyreicudk4v2rlu4lt2ip7oi4kssudctl22j2p3ojqnekz7c3xcqpwmje ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
@MatthieuScarset
MatthieuScarset / .lando.yml
Created Dec 13, 2020
Lando (+3.0) with XDebug (WordPress recipe)
View .lando.yml
name: wordpress
recipe: wordpress
services:
appserver:
webroot: .
xdebug: debug
config:
php: .vscode/php.ini
tooling:
install:wordpress:
@MatthieuScarset
MatthieuScarset / reorder-form-actions.php
Created Jul 14, 2020
Drupal - Order array by another array
View reorder-form-actions.php
<?php
// Reorder actions.
$order = [
'previous',
'reset',
'submit',
'preview_next',
];
@MatthieuScarset
MatthieuScarset / fixpermissions
Created Jul 19, 2018
Fix permissions on Docker-based env with Drupal
View fixpermissions
//Files should be `644` I think
find . -type f -exec chmod u=rw,g=r,o=r {} \;
// Folders should be `executable
find . -type d -exec chmod u=rwx,g=rx,o=rx {} \;
@MatthieuScarset
MatthieuScarset / reset_admin_password.sql
Created Jun 19, 2018
SQL query to reset admin password (admin / admin)
View reset_admin_password.sql
UPDATE users SET pass ='$S$DmWStgEK4Uwao1iqvQeHJibfO6bE/x9EQ0A40qqSrV6T24UW9uAd' WHERE uid = 1;
View mixin.icons_colors.scss
// Colors
$black: #000000;
$grey: #f4f4f4;
$pale-grey: #6c94a3;
$white: #ffffff;
$navy: #004057;
$blue: #00aac0;
$pale-blue: #eff7f9;
$purple: #5d1f84;
$pink: #e461bc;
@MatthieuScarset
MatthieuScarset / .lando.yml
Last active Oct 25, 2021
Correct settings for XDebug + VSCode + Lando (+3.0)
View .lando.yml
# Lando version is at least +3.0
name: drupal-nine
recipe: drupal9
services:
appserver:
webroot: web
xdebug: debug
config:
php: .vscode/php.ini