First let's install Homebrew.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
<?php | |
/** | |
* @When I switch to the frame by selector "[title=:arg1]" | |
*/ | |
public function switchToIFrameFromSelector($iframeSelector) { | |
$function = <<<JS | |
(function(){var iframe = document.querySelector("$iframeSelector");iframe.name = "iframeToSwitchTo";})() | |
JS; | |
try { |
<?php | |
namespace Drupal\module\Helper; | |
use Drupal\Core\Entity\EntityInterface; | |
use Drupal\Core\Entity\EntityTypeManagerInterface; | |
use Drupal\Core\Logger\LoggerChannelInterface; | |
use Drupal\paragraphs\Entity\Paragraph; | |
/** |
#!/bin/bash | |
# How to use this script? | |
# | |
# 1. create an empty module that depends on default_content or reuse an | |
# existing one. | |
# 2. use `drush dcer --folder=path/to/module/content ENTITY_TYPE ID` | |
# to add default content to your module. | |
# 3. once all your content is in your module, clean up the content folder | |
# to only keep the content you need (ie. remove users most of the time). |
<?php | |
namespace Drupal\custom_commerce_recurring; | |
use Drupal\commerce_order\Entity\OrderInterface; | |
use Drupal\commerce_recurring\RecurringOrderManager as BaseRecurringOrderManager; | |
use Drupal\commerce_recurring\RecurringOrderManagerInterface; | |
use Drupal\Component\Datetime\TimeInterface; | |
use Drupal\Core\Entity\EntityTypeManagerInterface; |
# Redis configuration file example | |
# Note on units: when memory size is needed, it is possible to specifiy | |
# it in the usual form of 1k 5GB 4M and so forth: | |
# | |
# 1k => 1000 bytes | |
# 1kb => 1024 bytes | |
# 1m => 1000000 bytes | |
# 1mb => 1024*1024 bytes | |
# 1g => 1000000000 bytes |
Url::fromUri('mailto:[email protected]')
MailHog is a nice mail testing tool for developers.
Website: https://github.com/mailhog/MailHog
Download the latest release on your local machine
<?php | |
/** | |
* Implements hook_token_info_alter() | |
*/ | |
function MODULE_token_info_alter(&$data) { | |
// Modify description of node tokens for our site. | |
$data['tokens']['node-field_myfield']['foo'] = [ | |
'name' => "Foo", | |
'description' => "Process field_myfield value" |
<?php | |
namespace Drupal\MY_MODULE\EventSubscriber; | |
use Drupal\Core\Session\AccountInterface; | |
use Drupal\taxonomy\TermInterface; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\HttpKernel\KernelEvents; | |
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |