Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
trying to do my best, I swear!

David Rodriguez davidjguru

🚀
trying to do my best, I swear!
View GitHub Profile
@davidjguru
davidjguru / MyCustomForm.php
Created May 19, 2023 08:22 — forked from MatthieuScarset/MyCustomForm.php
Drupal - Autosubmit exposed form in JS
View MyCustomForm.php
<?php
namespace Drupal\mymodule\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a custom form.
*/
@davidjguru
davidjguru / working_with_github_cli_and_derivative_extensions.md
Last active April 25, 2023 16:24
Working with Github CLI and derivative extensions
View working_with_github_cli_and_derivative_extensions.md

Introduction

Github CLI is a console tool for working on interactions with Github from terminal. This tool allow to add new extension by developing them and adding to the main gh prompt as sub-commands from your command line. Read More about how to implement custom Github CLI extensions.

For this example we use a private extension not available for public purposes but you can explore some others existing Github CLI extensions. See the list of available extensions at https://github.com/topics/gh-extension.

In order to follow the next steps just change [RESOURCE] by your marked extension.

Install Github CLI in Ubuntu / Debian

Add repository

View blt-hands-on-tutorial.md
@davidjguru
davidjguru / Drupal Multisite Drush Script
Created October 3, 2022 09:49 — forked from gueno/Drupal Multisite Drush Script
If you're running multiple sites on one drupal installation, here is a script to run different Drush commands on all of them
View Drupal Multisite Drush Script
#!/bin/bash
# Get all Drupal sites
sites=`find . -maxdepth 1 -type d -print | grep -v '/all$' | grep -v '/default$' | grep -v '\.$'`
echo "Choose the commande to execute : "
echo "1. update"
echo "2. put sites offline"
echo "3. put sites online"
echo "4. clear all cache"
@davidjguru
davidjguru / top_ten_frequent_operations_developing_with_drupal.md
Last active September 28, 2022 08:00
List of top ten most frequent operations developing with Drupal.
View top_ten_frequent_operations_developing_with_drupal.md

1. Getting config values from the system

1.1 Getting config values from a hook

$slogan = \Drupal::config('system.site')->get('slogan');

1.2 Getting config values from a preprocess function of a template file

e.g. => mytheme_preprocess_node(&$variables))

@davidjguru
davidjguru / my_favourite_git_aliases_for_prompt.md
Created March 31, 2022 09:22
Gathering my favourite git aliases (from the Linux OS level, not like Git aliases).
View my_favourite_git_aliases_for_prompt.md

Git Related Aliases

Getting basic info of the situation of your project: status, branches, current branch, naming of remote repo.

alias gs='git status'
alias gb='git branch'
alias gr='git remote -v'
alias gp='git rev-parse --abbrev-ref HEAD'

Getting info from 'Git log' about last commits, last changed files in 12 months by order and by commit message.

@davidjguru
davidjguru / git_getting_all_remote_branches_updated_in_local_environment.md
Created March 30, 2022 11:30
How to get all the code from remote repository from all the available remote branches.
View git_getting_all_remote_branches_updated_in_local_environment.md
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@davidjguru
davidjguru / _intro_drupal_8_9_getting_data_from_user_account.md
Last active February 17, 2022 20:15
Drupal 8 || 9 - Getting data from user account in Drupal
View _intro_drupal_8_9_getting_data_from_user_account.md
@davidjguru
davidjguru / _introduction_drupal_8_9_getting_info_about_services_using_drush.md
Last active February 17, 2022 13:13
Drupal 8 || 9 - Getting info about available services in your Drupal installation
View _introduction_drupal_8_9_getting_info_about_services_using_drush.md

Drupal 8 || 9 - Getting info about available services in your Drupal installation

Sometimes you need to know what classes you have available to use as a service in your Drupal installation: either because you don't remember by heart all the services provided by the Drupal core (it's impossible!) or because you come to a project with a lot of custom developments accumulated. In between, there are also all the services available through contributed modules, which you can also use in your implementations. For all these reasons I have compiled some ways to get information about services in a Drupal installation.

Author

@davidjguru
davidjguru / drupal_8_9_configure_phpunit_for_testing.md
Last active February 9, 2023 14:44
Drupal 8 || 9 - Configure your PHPUnit environment for functional testing
View drupal_8_9_configure_phpunit_for_testing.md