<?php
namespace App\Helper;
class ObjectJson extends JsonHelper
{
public static function getJson($object, $hiddenFields = []) {
$json = [];
$class = method_exists($object, 'getClassName')
? \Pimcore\Model\DataObject\ClassDefinition::getByName($object->getClassName())
: null;
if ($class) {
$json = self::getBaseJson($object, $class->getFieldDefinitions(), $hiddenFields, $class->getAllowInherit());
$json = array_merge(['id' => $object->getId()], $json);
}
if(!in_array('creationDate', $hiddenFields)){
$json['creationDate'] = date('Y-m-d H:i:s',$object->getCreationDate());
}
if(!in_array('modificationDate', $hiddenFields)){
$json['modificationDate']= date('Y-m-d H:i:s',$object->getModificationDate());
}
return $json;
}
}