Skip to content

Instantly share code, notes, and snippets.

View EclipseGc's full-sized avatar

Kris Vanderwater EclipseGc

View GitHub Profile
<?php
/**
* @file
* Contains \Drupal\node\Plugin\Search\NodeSearchExecute.
*/
namespace Drupal\node\Plugin\Search;
use Drupal\Component\Plugin\ContextAwarePluginBase;
<?php
namespace Drupal\lightning_layout;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
class PanelizerAwareEntityViewDisplay extends EntityViewDisplay {
protected function ensurePanelizerFieldStorage() {
$storage = $this->entityTypeManager()->getStorage('field_storage_config');
<?php
$code = file_get_contents($file);
$tokens = token_get_all($code);
$tree = new \EclipseGc\Ast\Tree;
foreach ($tokens as $id => $token) {
if (is_array($token)) {
$tree->addNode($nodeDictionary->createInstance($token[0], $token[1], $id, $tokens);
}
{
"name": "drupal/utilty",
"description": "Common utility classes for Drupal components.",
"keywords": ["drupal"],
"homepage": "http://www.drupal.org",
"license": "GPL2+",
"authors": [
{
"name": "Dries Buytaert",
"email": "dries@1.no-reply.drupal.org"
services:
block.controllers:
class: Drupal\block\BlockEntityControllers
arguments: ['@service_container', '@module_handler']
tags:
- { name: event_subscriber }
<?php
/**
* @file
* Contains \Drupal\node\NodeEntityControllers
*/
namespace Drupal\node;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
<?php
/**
* @file
* Contains PageManagerCriteriaForm.php.
*/
namespace Drupal\page_manager\Form;
use Drupal\Core\Condition\ConditionManager;
use Drupal\Core\Entity\EntityInterface;
<?php
// Adding a method to TypedDataManager
public function mapDefinition(array $type) {
/** $type comes across as:
*
* "type" = "entity",
* "constraints" = {
* "EntityType" = "node"
<?php
// My code for getting this output.
$definition = new DataDefinition(\Drupal::service('typed_data')->getDefinition('entity'));
$definition->setDataType('entity');
$definition->addConstraint('EntityType', 'node');
drupal_set_message('<pre>' . print_r($definition, TRUE) . '</pre>');
$definition2 = new DataDefinition(\Drupal::service('typed_data')->getDefinition('entity:node'));
drupal_set_message('<pre>' . print_r($definition2, TRUE) . '</pre>');
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index eab4d3e..8cd2602 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -12,72 +12,83 @@ function comment_token_info() {
$type = array(
'name' => t('Comments'),
'description' => t('Tokens for comments posted on the site.'),
- 'needs-data' => 'comment',
+ 'needs-data' => 'entity:comment',