Skip to content

Instantly share code, notes, and snippets.

@vishwac09
Created September 22, 2022 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishwac09/d2840458edbfaaf3a2d83f5430555e1d to your computer and use it in GitHub Desktop.
Save vishwac09/d2840458edbfaaf3a2d83f5430555e1d to your computer and use it in GitHub Desktop.
EntityConvert methods API
<?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