Created
November 23, 2015 10:02
-
-
Save damiankloip/f812ad2ba9f8261a1a06 to your computer and use it in GitHub Desktop.
PsySH D8 casters
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 | |
$config['casters'] = [ | |
'Drupal\Core\Entity\ContentEntityInterface' => function($object, $array, $stub, $isNested) { | |
if (!$isNested) { | |
foreach ($object as $property => $item) { | |
$array[Symfony\Component\VarDumper\Caster\Caster::PREFIX_PROTECTED . $property] = $item; | |
} | |
} | |
return $array; | |
}, | |
'Drupal\Core\Field\FieldItemListInterface' => function($object, $array, $stub, $isNested) { | |
if (!$isNested) { | |
$array[Symfony\Component\VarDumper\Caster\Caster::PREFIX_PROTECTED . 'list'] = $object->getValue(); | |
} | |
return $array; | |
}, | |
'Drupal\Core\Config\Entity\ConfigEntityInterface' => function($object, $array, $stub, $isNested) { | |
if (!$isNested) { | |
foreach ($object->toArray() as $property => $value) { | |
$array[Symfony\Component\VarDumper\Caster\Caster::PREFIX_PROTECTED . $property] = $value; | |
} | |
} | |
return $array; | |
}, | |
'Drupal\Core\Config\ConfigBase' => function($object, $array, $stub, $isNested) { | |
if (!$isNested) { | |
foreach ($object->get() as $property => $value) { | |
$array[Symfony\Component\VarDumper\Caster\Caster::PREFIX_VIRTUAL . $property] = $value; | |
} | |
} | |
return $array; | |
}, | |
'Drupal\Core\Extension\Extension' => function($object, $array, $stub, $isNested) { | |
if (!$isNested) { | |
$array[Symfony\Component\VarDumper\Caster\Caster::PREFIX_PROTECTED . 'type'] = $object->getType(); | |
} | |
return $array; | |
}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment