Skip to content

Instantly share code, notes, and snippets.

View fede-green's full-sized avatar

fede-green

  • Trimble Solutions
  • Helsinki
View GitHub Profile
git rm $(git ls-files --deleted)
#create the new user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
#create the new database
CREATE DATABASE newdatabase;
#assign the user to it
GRANT ALL PRIVILEGES ON newdatabase. * TO 'newuser'@'localhost';
#flush
FLUSH PRIVILEGES;
@fede-green
fede-green / ImageOverlayFieldFormatter.php
Last active October 4, 2017 05:40
How to create a custom formatter for fields. This example can be used as is for a hover effect as the one you can see on siili.com for cases in homepage. the ImageOverlayFieldFormatter class goes to the *src/Plugin/Field/FieldFormatter* folder, the css and svg file in a folder called *svg*.
<?php
namespace Drupal\my_module\Plugin\Field\FieldFormatter;
use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter;
use Drupal\Core\Field\FieldItemListInterface;
/**
* Plugin implementation of the 'my_module image' formatter.
*
@fede-green
fede-green / DoStuff.php
Last active October 4, 2017 05:40
How to create a service that does stuff for you.
<?php
namespace Drupal\my_module;
/**
* Service to doi Stuff.
*/
class DoStuff extends XYZ {
/**
@fede-green
fede-green / module.module
Last active October 9, 2017 11:16
Module implementing custom template suggestions altering an already existing hook.
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYMODULE_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) {
array_unshift($suggestions, 'ADD_MY_MODULE_SUGGESTION');
}
/**
* Implements hook_theme_registry_alter().
*/
function MYMODULE_theme_registry_alter(&$theme_registry) {
We couldn’t find that file to show.