Skip to content

Instantly share code, notes, and snippets.

View kporras07's full-sized avatar

Kevin Porras kporras07

View GitHub Profile
diff --git a/core/lib/Drupal/Core/Entity/EntityChangesDetectionTrait.php b/core/lib/Drupal/Core/Entity/EntityChangesDetectionTrait.php
index ff41106..6c4caa2 100644
--- a/core/lib/Drupal/Core/Entity/EntityChangesDetectionTrait.php
+++ b/core/lib/Drupal/Core/Entity/EntityChangesDetectionTrait.php
@@ -37,6 +37,8 @@ trait EntityChangesDetectionTrait {
}
}
+ \Drupal::moduleHandler()->alter('fields_to_skip_from_translation_changes', $fields, $entity);
+
use Drupal\field\Entity\FieldStorageConfig;
/**
* Resize field.
*/
function demo_field_resize_update_8001() {
$field_name = 'field_to_resize';
$entity_type = 'node';
$database = \Drupal::database();
$database->query("ALTER TABLE node__" . $field_name . " MODIFY " . $field_name . "_value VARCHAR(200)");
@kporras07
kporras07 / lock-all-environments
Last active March 28, 2018 20:36 — forked from greg-1-anderson/lock-all-environments
Lock all of the environments for the given site, save for the live environment
#!/bin/bash
SITE=$1
USER=${2-demo}
BASE_PASSWORD=${3-secretsecret}
ALL_ENVS="$(terminus env:list $SITE --field=id | grep -v live)"
for ENV in $ALL_ENVS ; do
is_locked="$(terminus lock:info "$SITE.$ENV" --field=locked)"
@kporras07
kporras07 / update-specific-service-docker-compose.sh
Created October 9, 2017 15:07
Update specific service using docker-compose
docker-compose up -d --no-deps --build <service>
@kporras07
kporras07 / viewValue function field formatter.php
Created April 19, 2017 18:08
View Value function in email field formatter
protected function viewValue(FieldItemInterface $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
$url = Url::fromUri('mailto:' . $item->value);
return Link::fromTextAndUrl(t('Send Email'), $url)->toString();
}
@kporras07
kporras07 / install_drupal_console.sh
Created April 19, 2017 17:55
Install Drupal console on existing composer project.
composer require --dev drupal/console:~1.0 --prefer-dist --optimize-autoloader
location / {
# try_files $uri @rewrite; # For Drupal <= 6
try_files $uri /index.php?$query_string; # For Drupal >= 7
}
// En Settings.php
$local_settings = __DIR__ . "/settings.local.php";
if (file_exists($local_settings)) {
include $local_settings;
}
if (empty($settings['hash_salt'])) {
$settings['hash_salt'] = hash('sha256', serialize($databases));
}
@kporras07
kporras07 / screenshot_behat.php
Last active January 21, 2016 21:06
Screenshot with behat selenium
<?php
/**
* This works for Selenium and other real browsers that support screenshots.
*
* @Then /^show me an screenshot$/
*/
public function showMeAnScreenshot() {
$image_data = $this->getSession()->getDriver()->getScreenshot();
@kporras07
kporras07 / create_taxonomy_term.php
Created November 6, 2015 01:52
Crear taxonomy term.
$vocabulary = taxonomy_vocabulary_machine_name_load($name);
$vid = $vocabulary->vid;
$term = new stdClass();
$term->vid = $vid;
$term->name = 'foo';
$term->description = 'bar';
taxonomy_term_save($term);