Skip to content

Instantly share code, notes, and snippets.

@achraf-jeday
achraf-jeday / load_node_translations.php
Last active May 11, 2021 12:56
Drupal 8: How to load available translations of a given node, change some fields and save.
<?php
// Credit to Gábor Hojtsy
// http://hojtsy.hu/blog/2015-nov-11/drupal-8-multilingual-tidbits-19-content-translation-development
use Drupal\node\Entity\Node;
// Load node 4. In terms of language, this will get us an entity
// in the original submission language.
$node = Node::load(4);
@mailightkun
mailightkun / openssl_encrypt_decrypt.md
Created April 6, 2018 04:44
Replace mcrypt_encrypt with openssl_encrypt

Replace mcrypt_encrypt with openssl_encrypt

If you switch from PHP 5.x to 7.1 you will get the following message:

"Function mcrypt_encrypt() is deprecated"

Now it is the right time to refactor this old function :-)

function encrypt(string $data, string $key, string $method): string