This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Implements hook_inline_entity_form_table_fields_alter(). | |
| * | |
| * Displays a field from a custom entity in the Inline Entity Form windget table. | |
| */ | |
| function MODULENAME_inline_entity_form_table_fields_alter(&$fields, $context) { | |
| // Display Entity field in a column within Inline Entity Form widget. | |
| if ($context['parent_bundle'] == 'content_type_parent_to_ief' && $context['field_name'] == 'entity_reference_field_name') { | |
| // Unset original IEF label if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\node\Entity\Node; | |
| /** | |
| * Before attaching a term(s) to a term reference field, | |
| * Must know: | |
| * - field_example_name: the full name of the term reference field | |
| * - tid: the term ID(s) to attach | |
| * | |
| * Keep in mind that this example uses Node::load() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Create media entities from existing file fields. | |
| * | |
| * @link https://chromatichq.com/blog/migrating-drupal-file-fields-media-entities-without-migrate-module | |
| */ | |
| function MODULENAME_update_8001() { | |
| // Nodes types that will get media migrated. | |
| $node_types = ['article','event','page','session','sponsor']; | |
| // Map old file fields => new media fields. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| l( | |
| t('<span></span>Link Title'), | |
| 'link_path', | |
| array( | |
| 'attributes' => array( | |
| 'class' => array('menu-link'), | |
| 'id' =>'faq-page', | |
| ), | |
| 'html' => TRUE, | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\DrupalExtension\Context\DrupalContext, | |
| Drupal\DrupalExtension\Event\EntityEvent, | |
| Drupal\Component\Utility\Random; | |
| use Behat\Behat\Context\BehatContext, | |
| Behat\Behat\Context\Step, | |
| Behat\Behat\Context\Step\Given, | |
| Behat\Gherkin\Node\PyStringNode, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Configure error messages | |
| ini_set('display_errors',1); | |
| error_reporting(E_ALL); | |
| class Adult { | |
| /* | |
| We set the visibility of these properties to 'protected' so they are accessible within the Child class. | |
| We prefix private and protected properties/methods with an underscore, so (at a glance) while scanning a long file we can instantly recognise the visibility. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # This script can be run from any location. | |
| # - sh automated_dbpull.sh | |
| # SSH to the server using SSH key. | |
| ssh -tt -i ~/.ssh/id_rsa YOURUSERNAME@SERVER << EOF | |
| cd /var/www/sites/SITEDIRECTORY/www; | |
| drush sql-dump --result-file=../build/DBNAMEOFCHOICE.sql --gzip --structure-tables-key=cache,cache_*,history,search_*,sessions,watchdog; | |
| exit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "env": { | |
| "browser": true | |
| }, | |
| "globals": { | |
| "Drupal": true, | |
| "jQuery": true, | |
| "tinyMCE": true | |
| }, | |
| "rules": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Basics | |
| // Get a value. | |
| $value = $wrapper->field_x->value(); | |
| // If the field is a reference field you will get the field object | |
| // To get the wrapper back use: | |
| $wrapper_b = $wrapper->field_ref; | |
| // To set a value. |