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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Web Components</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<style type="text/css"> | |
body { | |
margin: 0 auto; |
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
/** | |
* @file | |
* Example code from http://agaric.com/blogs/conditional-fields-paragraphs-using-javascript-states-api-drupal-8. | |
*/ | |
/** | |
* Implements hook_field_widget_WIDGET_TYPE_form_alter(). | |
* | |
* Example of conditional fields in paragraphs for Drupal 8. | |
*/ |
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
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(); |
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\Tests\tablefield\Functional; | |
use Drupal\Tests\BrowserTestBase; | |
/** | |
* Simple test to ensure that a field can be created. | |
* | |
* @group tablefield |
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
/** | |
* {@inheritdoc} | |
*/ | |
public function viewElements(FieldItemListInterface $items, $langcode) { | |
$elements = []; | |
$id = $items->getEntity()->id(); | |
# Generate a wrapper to use as dom root to attach the React component. | |
$field_name = $this->fieldDefinition->getItemDefinition()->getFieldDefinition()->getName(); | |
$wrapper_id = 'drupal-and-react-app-' . $field_name .'-'. $id; |
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_preprocess_views_view | |
*/ | |
function my_module_preprocess_views_view(&$vars){ | |
// Only use unique IDs for view. | |
// Use this code for views with Better Exposed Filters. | |
if ($vars['view']->id() === 'view_name_bef') { | |
$rows = []; |
NewerOlder