Last active
September 22, 2022 17:57
-
-
Save vishwac09/b1f0012d9c69e7d04caeaf820789a483 to your computer and use it in GitHub Desktop.
EntityConvert getting response as an array
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
<?php | |
use Drupal\Node\Entity\Node; | |
use DrupalUtils\EntityConvert\EntityConvert; | |
// Load instance of node | |
$node = Node::load(1); | |
// Creating a new Instance. | |
$entityConvert = new EntityConvert(); | |
// Pass on the Node object to get the parsed value as array. | |
$parsedNode = $entityConvert->toArray($node, false); | |
var_dump($parsedNode); | |
^ array:42 [▼ | |
"nid" => 1 | |
"uuid" => "8270a03c-a95f-4033-84a7-361597b581a9" | |
"vid" => 39 | |
"langcode" => "en" | |
"type" => 0 | |
"revision_timestamp" => 1660994564 | |
"revision_uid" => 1 | |
"revision_log" => null | |
"status" => true | |
"uid" => 1 | |
"title" => "Car 1" | |
"created" => 1659367826 | |
"changed" => 1660994564 | |
"promote" => true | |
"sticky" => true | |
"default_langcode" => true | |
"revision_default" => true | |
"revision_translation_affected" => true | |
"path" => array:3 [▶] | |
"field_bool_multi_value" => array:1 [▼ | |
0 => true | |
] | |
"field_comments_single_value" => array:1 [▶] | |
"field_content_multi_value" => array:1 [▶] | |
"field_datetime_multi_value" => array:1 [▼ | |
0 => "2022-08-31T00:31:28" | |
] | |
"field_date_multi_value" => array:2 [▼ | |
0 => "2022-08-14" | |
1 => "2022-08-31" | |
] | |
"field_email_multi_value" => array:2 [▼ | |
0 => "[email protected]" | |
1 => "[email protected]" | |
] | |
"field_file_multi_value" => array:1 [▼ | |
0 => array:11 [▼ | |
"fid" => "3" | |
"uuid" => "6eb73b6e-be50-449e-a57d-bccf9d6b0bc0" | |
"langcode" => "en" | |
"uid" => "1" | |
"filename" => "testing.csv" | |
"uri" => "public://2022-08/testing.csv" | |
"filemime" => "text/csv" | |
"filesize" => "96" | |
"status" => "1" | |
"created" => "1660992978" | |
"changed" => "1660993028" | |
] | |
] | |
"field_image_multi_value" => array:1 [▶] | |
"field_link_multi_value" => array:1 [▼ | |
0 => array:3 [▶] | |
] | |
"field_listint_multi_value" => array:1 [▶] | |
"field_listtext_multi_value" => array:2 [▶] | |
"field_list_multi_value" => array:1 [▶] | |
"field_numberfloat_multi_value" => array:1 [▶] | |
"field_numberint_multi_value" => array:1 [▶] | |
"field_textflws_multi_value" => array:1 [▶] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment