Created
September 22, 2022 18:15
EntityConvert methods API
This file contains 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 DrupalUtils\EntityConvert\EntityConvert; | |
$entityConvert = new EntityConvert(); | |
// $instance == Node/User/Taxonomy/File. | |
$entityConvert->toArray($instance, true); | |
$entityConvert->toObject($instance, false); | |
// The toArray method accepts 2 arguments. | |
/** | |
* Parse the given entity instance and return array. | |
* | |
* @param Object $instance | |
* The Entity instance to parse. | |
* @param Boolean $strict_type | |
* Flag indicating variable types should be preserved. | |
* | |
* @return array | |
*/ | |
function toArray($instance, $strict_type = false); | |
// The toObject method accepts 2 arguments. | |
/** | |
* Parse the given entity instance and return object. | |
* | |
* @param Object $instance | |
* The Entity instance to parse. | |
* @param Boolean $strict_type | |
* Flag indicating variable types should be preserved. | |
* | |
* @return EntityInterface | |
*/ | |
function toObject($instance = null, $strict_type = false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment