Skip to content

Instantly share code, notes, and snippets.

View PSF1's full-sized avatar
☀️
Focusing

Pedro Peláez PSF1

☀️
Focusing
View GitHub Profile
@PSF1
PSF1 / phpcbf
Last active September 28, 2023 13:52
Drupal code style with DDEV
#!/bin/bash
# Fix code style automatically.
#
# To create the command 'ddev phpcbf', create in '.ddev/commands/web' a new file 'phpcbf'.
# This require, in project, install 'squizlabs/php_codesniffer' and 'drupal/coder' how a dev dependency.
# 2023 By Pedro Pelaez <[email protected]>
folders=""
@PSF1
PSF1 / drupal-8-cheatsheet.md
Created November 14, 2023 15:55 — forked from cesarmiquel/drupal-8-cheatsheet.md
Drupal 8/9/10 Cheatsheet

Drupal 8 Cheatsheet

Files, Images and Media

// Load file object
$file = File::load($fid);

// Get uri (public://foo/bar/baz.png)
$uri = $file-&gt;getFileUri();
@PSF1
PSF1 / new_drupal.sh
Created February 5, 2024 10:41
DDEV Create Drupal Project
#!/bin/bash
#
# 2024-02-05 - Creado con gpt-4-1106-preview
# Por Pedro Pelaez
#
# Define una función para imprimir mensajes en azul
print_blue() {
echo -e "\033[34m$1\033[0m"
@PSF1
PSF1 / gist:f82d31920fa1032e12dce1513948cc89
Created February 19, 2024 10:37
Steps to add a new action operation to Entity
Steps to add a new operation to Entity:
- In the entity class:
-- Add definition in handlers/form
-- Override handlers/route_provider with a new route generator.
-- Add route template in links
- Create a new form to manage the operation.
- Generate a new route in the route generator class.
- Add operation in the entity's ListBuilder.
@PSF1
PSF1 / Prompt
Created October 9, 2024 11:11
Rerun Drupal update_n
drush eval '\Drupal::service("update.update_hook_registry")->setInstalledVersion("mOdule_name", "previous_update_number");'