This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($, Drupal) { | |
'use strict'; | |
Drupal.behaviors.reCaptchaFix = { | |
attach: function (context, settings) { | |
if (context == document) { | |
var intervalID = window.setInterval(setAccesibilityLabel, 50); | |
function setAccesibilityLabel() { | |
var textAreaCheck = document.getElementsByClassName('g-recaptcha-response'); | |
if (textAreaCheck.length > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client = \Drupal::httpClient(); | |
// Sending application/x-www-form-urlencoded POST requests requires | |
// that you specify the POST fields as an array in the form_params request options. | |
$req = $client->request('POST', $url, [ | |
'form_params' => [ | |
'action' => urlencode($action), | |
'username' => urlencode($username), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ brew info gpatch | grep "gpatch:" gpatch: stable 2.7.5 (bottled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\title_block\Plugin\Block; | |
use Drupal\Core\Block\BlockBase; | |
/** | |
* Provides a block rendering the title of the current node. | |
* | |
* @Block( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\title_block\Plugin\Block; | |
use Drupal\Core\Block\BlockBase; | |
/** | |
* Provides a block rendering the title of the current node. | |
* | |
* @Block( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Assuming link field has a machine name of field_call_to_action_button #} | |
{% set cta_link_url = '' %} | |
{% set cta_has_link = 'no' %} | |
{% if content.field_call_to_action_button['#items'] %} | |
{# @var route_object - instance of Drupal\Core\Url #} | |
{% set route_object = content.field_call_to_action_button['#items'].0.url %} | |
{% set link_title = content.field_call_to_action_button['#items'].title %} | |
{% if route_object.external %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; | |
$orGroup = \Drupal::entityQuery('node')->orConditionGroup() | |
->condition('type', 'page'); | |
->condition('type', 'article') | |
->condition('type', 'landing'); | |
$result = \Drupal::entityQuery('node') | |
->status(1) | |
->condition($orGroup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\node\NodeInterface; | |
/** | |
* Implements hook_ENTITY_TYPE_view(). | |
*/ | |
function mymodule_node_view(array &$build, NodeInterface $node, $display, $view_mode) { | |
if ($node->getType() === 'post') { | |
$build['#cache']['max-age'] = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Removing traces of the test_marco_socialfood_workflow module after merging. | |
*/ | |
function hook_update_N() { | |
$schema_store = \Drupal::keyValue('system.schema'); | |
$schema_store->delete('module_name'); | |
\Drupal::database()->delete('key_value') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_library_info_build(). | |
*/ | |
function drupal_and_react_library_info_build() { | |
# Load current module path. | |
$module = \Drupal::moduleHandler()->getModule('drupal_and_react'); | |
$module_path = $module->getPath(); |