Skip to content

Instantly share code, notes, and snippets.

View vincenzodibiaggio's full-sized avatar

Vincenzo vincenzodibiaggio

View GitHub Profile
@vincenzodibiaggio
vincenzodibiaggio / your_module.module
Created February 10, 2016 10:03
Drupal 7 - Add a textarea to custom variables edit form
/**
* Implements hook_variable_info().
*/
function your_module_variable_info($options) {
$variables['your_variable'] = array(
'title' => t('Title', array(), $options),
'description' => t('Description.', array(), $options),
'type' => 'text',
'default' => 'Default value',
@vincenzodibiaggio
vincenzodibiaggio / ct_test_results.csv
Created January 25, 2016 10:18
Drupal migrate content with field translation
id titolo_en titolo_it titolo_fr txt_breve txt_completo
1 Title 1 Titolo 1 Title 1 Short 1 Complete 1
2 Title 2 Titolo 2 Title 2 Short 2 Complete 2
@vincenzodibiaggio
vincenzodibiaggio / drupal8_beta_16_file_configuration.md
Last active October 7, 2015 22:01
Drupal 8 (from beta 16) enable file configuration before install

At this moment ( 8.0.0-beta16 ) to switch to file configuration before install Drupal:

Into settings.php Uncomment

    $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');

then add:

    $config_directories = array(
 CONFIG_ACTIVE_DIRECTORY => 'PATH_OUTSIDE_WEB_ROOT/config/active/',
@vincenzodibiaggio
vincenzodibiaggio / gist:6251665
Created August 16, 2013 17:07
Useful snipset to manage Drupal redirection/page refresh on form submit (user creation/update, etc..) in a Behat's scenario
/**
* Useful snipset to manage Drupal redirection/page refresh on form submit (user creation/update, etc..) in a Behat's scenario
*
* Is not mine, I have found in Drupal site, but I don't remember where
*/
/**
* @Given /^I follow meta refresh$/
@vincenzodibiaggio
vincenzodibiaggio / my.info
Created August 8, 2013 06:39
Drupal - Migrations - Date Field Mapping with Range Date - with patch
dependencies[] = migrate
dependencies[] = migrate_extras
dependencies[] = date
dependencies[] = date_migrate
@vincenzodibiaggio
vincenzodibiaggio / MyMigration.inc
Created August 7, 2013 01:45
Drupal - Migration - Add term reference, included in a field collection, to an entity from CSV data
class MyMigration extends MyBaseMigration {
public function __construct(array $arguments) {
parent::__construct($arguments);
// Description.
$this->description = t('Description');
// Dependencies.
$this->dependencies = array('MyUser');
@vincenzodibiaggio
vincenzodibiaggio / gist:5965342
Created July 10, 2013 10:50
php array diff recursive (from php.net site)
private function arrayRecursiveDiff($aArray1, $aArray2) {
$aReturn = array();
foreach ($aArray1 as $mKey => $mValue) {
if (array_key_exists($mKey, $aArray2)) {
if (is_array($mValue)) {
$aRecursiveDiff = $this->arrayRecursiveDiff($mValue, $aArray2[$mKey]);
if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; }
} else {
if ($mValue != $aArray2[$mKey]) {
@vincenzodibiaggio
vincenzodibiaggio / TwitterProvider.php
Last active December 19, 2015 07:49
FriendsOfSymfony/FOSTwitterBundle - Load existing user and connect to twitter account using twitter account data after authorization
<?php
# On documentation we can see:
public function findUserByTwitterId($twitterID)
{
return $this->userManager->findUserBy(array('twitterID' => $twitterID));
}
public function loadUserByUsername($username)