Skip to content

Instantly share code, notes, and snippets.

@EclipseGc
Last active January 1, 2016 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EclipseGc/8184824 to your computer and use it in GitHub Desktop.
Save EclipseGc/8184824 to your computer and use it in GitHub Desktop.
<?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>');
// $definition print_r()
Drupal\Core\TypedData\DataDefinition Object
(
[definition:protected] => Array
(
[list_class] => \Drupal\Core\TypedData\Plugin\DataType\ItemList
[id] => entity
[label] => Entity
[description] => All kind of entities, e.g. nodes, comments or users.
[derivative] => \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver
[class] => Drupal\Core\Entity\Plugin\DataType\Entity
[provider] => Core
[type] => entity
[constraints] => Array
(
[EntityType] => node
)
)
)
// $definition2 print_r()
Drupal\Core\TypedData\DataDefinition Object
(
[definition:protected] => Array
(
[label] => Content
[class] => Drupal\node\Entity\Node
[constraints] => Array
(
[EntityType] => node
)
[list_class] => \Drupal\Core\TypedData\Plugin\DataType\ItemList
[id] => entity
[description] => All kind of entities, e.g. nodes, comments or users.
[derivative] => \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver
[provider] => Core
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment