Skip to content

Instantly share code, notes, and snippets.

View davidjguru's full-sized avatar
🍅
Working within a pomodoro cycle

David Rodriguez davidjguru

🍅
Working within a pomodoro cycle
View GitHub Profile
@davidjguru
davidjguru / alterforms.module (initial)
Last active April 20, 2018 14:02
Initial Version: Alterforms for Drupal 8, module file
<?php
/**
*Implements hook_form_alter()
*/
function alterforms_form_alter(&$form, $form_state, $form_id) {
// Initial zone
@davidjguru
davidjguru / Installing_drush_launcher.txt
Created May 4, 2018 11:25
Drush Launcher Installation
## Get the Drush Launcher
wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar
## Make downloaded file executable
chmod +x drush.phar
## Move drush.phar to a location listed in your $PATH, rename to drush
sudo mv drush.phar /usr/local/bin/drush
## Update the tool
@davidjguru
davidjguru / drupal_call_to_service.txt
Created May 7, 2018 14:45
Drupal 8 general Services Calling
$values = \Drupal::service('name.service')->methodFromService();
@davidjguru
davidjguru / Drupal Horizontal Layout.txt
Created May 8, 2018 12:00
Drupal set horizontal layout from a render array of elements
// Context: Within a formElement, inside a FormWidget
$element += array(
'#type' => 'fieldset',
'#attributes' => array('class' => array('container-inline')),
);
@davidjguru
davidjguru / IntegerDropdownWidget.php
Created May 8, 2018 12:06 — forked from crittermike/IntegerDropdownWidget.php
Drupal 8 form widget example: creates a select dropdown for integer fields. Place in src/Plugin/Field/FieldWidget
<?php
/**
* @file
* Defines a dropdown widget for integer fields.
*/
namespace Drupal\nba_content_core\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldFilteredMarkup;
use Drupal\Core\Field\FieldItemListInterface;
@davidjguru
davidjguru / Info and links
Created May 10, 2018 19:25
[INFO] Custom Compound Fields in Drupal 8
@davidjguru
davidjguru / from_timestamp_to_date_drupal_8.txt
Last active February 3, 2023 09:36
Getting a timestamp and transforming to date in Drupal 8
## From a current timestamp (today) to a date
$today = DrupalDateTime::createFromTimestamp(time());
## From a current timestamp to a future date (six months ahead)
$next = DrupalDateTime::createFromTimestamp(strtotime('+6 months', time()));
## And using it to poblate a datefield within a Drupal Form (by example)
$element['nextdate'] = [
'#type' => 'datetime',
'#title' => t('See you'),
# A global recipe to set up a new workstation. For the on-boarding of new workmates.
## Getting Google Chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install libxss1 libgconf2-4 libappindicator1 libindicator7
sudo dpkg -i google-chrome-stable_current_amd64.deb
## Setting up a LAMP environment
sudo apt-get update
sudo apt-get install apache2 mysql-server php libapache2-mod-php php-mcrypt php-mysql
@davidjguru
davidjguru / basic_workflow_ignored_files
Created June 18, 2018 12:47
Cleaning Git: Deactivating follow-up on projects through . gitignore
git rm -r --cached .
git add -A
git commit -am 'Basic workflow to clean git with ignored files from a new gitignore'
@davidjguru
davidjguru / .gitignore
Created June 19, 2018 15:47 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #