drush vset preprocess_css 0 --yes
drush vset preprocess_js 0 --yes
brew cask install dockertoolbox | |
docker-machine create --driver virtualbox default | |
docker-machine ls | |
eval $(docker-machine env default) | |
Put the exports in this eval in your .zshrc or .bashrc if you use bash |
<?php | |
namespace Drupal\my_module\Services; | |
use Drupal\Core\Logger\LoggerChannelFactory; | |
/** | |
* Class MyService. | |
* | |
* @package Drupal\my_module\Services |
{{ path('entity.node.canonical', {'node': node.id }) }} |
<?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 | |
// 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'); |
This Gist is a collection of configuration files that can be used to easily setup a Homebrew-based LEMP stack on Mac OS X.
Files in this repository are numbered and named for ordering purposes only. At the top of each file is a section of metadata that denote what component the file belongs to and the default name & location of the file. Feel free to implement it however you want.
Note: some configuration files have hard-coded paths to my user directory -- fix it for your setup
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);
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).