Created
July 22, 2019 06:58
-
-
Save nkgokul/d8dcbaf1ad0abe892d962346ca59d356 to your computer and use it in GitHub Desktop.
Entity and Field Details
This file contains hidden or 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\node\Entity\Node; | |
$entity = Node::load(1183); | |
$fields = array_keys($entity->getFieldDefinitions()); | |
dpm($fields); | |
foreach($fields as $field_name) { | |
dpm("Field Name"); | |
dpm($field_name); | |
dpm("--------------"); | |
dpm("Field Value"); | |
dpm($entity->get($field_name)->value); | |
dpm("--------------"); | |
dpm("Target Id"); | |
dpm($entity->get($field_name)->target_id); | |
dpm("--------------"); | |
dpm("Array Keys of Entity"); | |
dpm(array_keys((array)$entity->get($field_name)->entity)); | |
dpm("#########################################################"); | |
} | |
// More details on https://drupal.stackexchange.com/a/231314/4876. Checkout answer by Berdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment