Every time you choose to apply a rule(s), explicitly state the rule(s) in the output. You can abbreviate the rule description to a single word or phrase.
[Brief description ]
- [more description]
- [more description]
- [more description]
<?php | |
// Import arbitrary config from a variable. | |
// Assumes $data has the data you want to import for this config. | |
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html'); | |
$config->setData($data)->save(); | |
// Or, re-import the default config for a module or profile, etc. | |
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module'); |
I have a content type with a media (image) entity reference field (field_thumbnail_image) and I want to grab its file URL. For this, I need to load the media entity, isolate its source object using getSource, then load this source as a file entity so I can make a proper URL.
// load the media entity from the media entity reference field
$media_entity = Media::load($entity->field_thumbnail_image->target_id);
// get the file source value for the media entity
$source_value = $media_entity->getSource()->getSourceFieldValue($media_entity);
A guide of best practices to developing in Python (meant for the first year students of the Instituto Superior Técnico, University of Lisbon). Do you want to have a hard-cover book on this, check this list out.
Inspired in Steve Sloria's gist.
"Beautiful is better than ugly." - [PEP 20][]
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
<?php | |
// The drupal_set_message() function is being deprecated! | |
// @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x | |
// > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. | |
// > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. | |
// In some custom code. | |
\Drupal::messenger()->addMessage('Say something else'); |
<?php | |
use Drupal\views\ViewExecutable; | |
use Drupal\views\Plugin\views\query\QueryPluginBase; | |
/** | |
* Implementation of hook_views_query_alter | |
* @param type $view | |
* @param type $query |
<?php | |
/** | |
* Implements theme_suggestions_HOOK_alter(). | |
*/ | |
function mytheme_theme_suggestions_paragraph_alter(array &$suggestions, array $variables) { | |
/** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ | |
$paragraph = $variables['elements']['#paragraph']; | |
/** @var \Drupal\Core\Entity\ContentEntityInterface $parent */ | |
$parent = $paragraph->getParentEntity(); |
{{ path('entity.node.canonical', {'node': node.id }) }} |