1. Enable devel
  2. Visit http://drupal.d8/node/3/devel
  3. Note
    $node->*fieldDefinitions (array, 20 elements)</li>
      <li>    Array ( [nid] => Drupal\Core\Field\FieldDefinition Object ( [type:protected] => integer [propertyDefinitions:protected] => [schema:protected] => [indexes:protected] => Array ( ) [itemDefinition:protected] => Drupal\Core\Field\TypedData\FieldItemDataDefinition Object ( [fieldDefinition:protected] => Drupal\Core\Field\FieldDefinition Object *RECURSION* [definition:protected] => Array ( [type] => field_item:integer [settings] => Array ( [unsigned] => 1 [min] => [max]
  4. Enable kint
  5. Visit http://drupal.d8/node/3/devel
  6. Note protected fieldDefinitions -> NULL
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

clemens.tolboom’s picture

Same goes for using the core exporter: a nullified fieldDefinitions ... weird :-/

// DevelController.php

  public function nodeLoad(NodeInterface $node) {
    $exporter = new \SebastianBergmann\Exporter\Exporter();
    return var_export($exporter->toArray($node));
//    return $this->loadObject('node', $node);
  }
lussoluca’s picture

Status: Active » Needs review
FileSize
847 bytes

In the latest version of Devel/Core this field is empty regardless of dumper used. One way to force Drupal to compute the value is by calling the getFieldDefinitions() method on the entity.

willzyx’s picture

I think we need to add a comment that explains why is needed to call ::getFieldDefinitions() . Otherwise looks good +1

lussoluca’s picture

Something like that?

willzyx’s picture

Yes, something like that . Or something like

// Field definitions are lazy loaded and are populated only when needed.
// By calling ::getFieldDefinitions() you are sure that field definitions
// are populated and available in the dump output.

  • lussoluca committed fbe3926 on 8.x-1.x
    Issue #2311557 by lussoluca, willzyx: node field definitions nullified...
lussoluca’s picture

Status: Needs review » Closed (fixed)

Committed and pushed to 8.x

willzyx’s picture

Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.