[CLEANUP] Refactor some code in api utility
This commit is contained in:
parent
ef09ca9302
commit
33741a42f4
@ -15,6 +15,8 @@ namespace Cjel\TemplatesAide\Utility;
|
|||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
use TYPO3\CMS\Extbase\Service\ImageService;
|
use TYPO3\CMS\Extbase\Service\ImageService;
|
||||||
|
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||||
|
use TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -105,14 +107,15 @@ class ApiUtility
|
|||||||
}
|
}
|
||||||
// ---
|
// ---
|
||||||
foreach ($propertieResults as $attributeName => $methodResult) {
|
foreach ($propertieResults as $attributeName => $methodResult) {
|
||||||
|
|
||||||
|
|
||||||
if (gettype($methodResult) == 'object'
|
if (gettype($methodResult) == 'object'
|
||||||
&& get_class($methodResult) == 'DateTime'
|
&& get_class($methodResult) == 'DateTime'
|
||||||
) {
|
) {
|
||||||
$rowResult[$attributeName] = $methodResult->format('c');
|
$rowResult[$attributeName] = $methodResult->format('c');
|
||||||
}
|
}
|
||||||
if (gettype($methodResult) == 'object'
|
if (gettype($methodResult) == 'object'
|
||||||
&& get_class($methodResult)
|
&& get_class($methodResult) == ObjectStorage::class
|
||||||
== 'TYPO3\CMS\Extbase\Persistence\ObjectStorage'
|
|
||||||
) {
|
) {
|
||||||
if ($rootRowClass == null) {
|
if ($rootRowClass == null) {
|
||||||
$nextLevelClass = $rowClass;
|
$nextLevelClass = $rowClass;
|
||||||
@ -126,12 +129,18 @@ class ApiUtility
|
|||||||
$nextLevelClass
|
$nextLevelClass
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//@todo: build unversal solution without fixed class name
|
|
||||||
if (gettype($methodResult) == 'object'
|
if (
|
||||||
&& get_class($methodResult)
|
gettype($methodResult) == 'object'
|
||||||
== 'Glanzstueck\FesCustomerportal\Domain\Model'
|
&&
|
||||||
. '\FrontendUser'
|
!in_array(get_class($methodResult), [
|
||||||
|
LazyObjectStorage::class,
|
||||||
|
ObjectStorage::class,
|
||||||
|
])
|
||||||
|
&&
|
||||||
|
count(explode('\\', get_class($methodResult))) > 1
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if ($rootRowClass == null) {
|
if ($rootRowClass == null) {
|
||||||
$nextLevelClass = $rowClass;
|
$nextLevelClass = $rowClass;
|
||||||
} else {
|
} else {
|
||||||
@ -143,11 +152,11 @@ class ApiUtility
|
|||||||
$mapping,
|
$mapping,
|
||||||
$nextLevelClass
|
$nextLevelClass
|
||||||
)[0];
|
)[0];
|
||||||
|
$rowResult[$attributeName . 'Uid']
|
||||||
|
= $rowResult[$attributeName]['uid'];
|
||||||
}
|
}
|
||||||
if (gettype($methodResult) == 'object'
|
if (gettype($methodResult) == 'object'
|
||||||
&& get_class($methodResult)
|
&& get_class($methodResult) == LazyObjectStorage::class
|
||||||
== 'TYPO3\CMS\Extbase\Persistence\Generic'
|
|
||||||
. '\LazyObjectStorage'
|
|
||||||
) {
|
) {
|
||||||
$rowResult[$attributeName] = [];
|
$rowResult[$attributeName] = [];
|
||||||
foreach ($methodResult as $object) {
|
foreach ($methodResult as $object) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user