Created
September 22, 2022 17:59
-
-
Save vishwac09/efee8587537e83507396465ccfc8ec4b to your computer and use it in GitHub Desktop.
Using the Entity Convert Library
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; | |
// Include the library. | |
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 an array. | |
$parsedNode = $entityConvert->toArray($node, false); | |
// Pass on the Node object to get the parsed value as an object. | |
$parsedNode = $entityConvert->toObject($node, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment