X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FPsysh%2FCaster.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FPsysh%2FCaster.php;h=7e806b5aa57fdf63017d9d7e7112515d8a1be817;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/drush/drush/src/Psysh/Caster.php b/vendor/drush/drush/src/Psysh/Caster.php new file mode 100644 index 000000000..7e806b5aa --- /dev/null +++ b/vendor/drush/drush/src/Psysh/Caster.php @@ -0,0 +1,114 @@ + $item) { + $array[BaseCaster::PREFIX_PROTECTED . $property] = $item; + } + } + + return $array; + } + + /** + * Casts \Drupal\Core\Field\FieldItemListInterface classes. + */ + public static function castFieldItemList($list_item, $array, $stub, $isNested) + { + if (!$isNested) { + foreach ($list_item as $delta => $item) { + $array[BaseCaster::PREFIX_VIRTUAL . $delta] = $item; + } + } + + return $array; + } + + /** + * Casts \Drupal\Core\Field\FieldItemInterface classes. + */ + public static function castFieldItem($item, $array, $stub, $isNested) + { + if (!$isNested) { + $array[BaseCaster::PREFIX_VIRTUAL . 'value'] = $item->getValue(); + } + + return $array; + } + + /** + * Casts \Drupal\Core\Config\Entity\ConfigEntityInterface classes. + */ + public static function castConfigEntity($entity, $array, $stub, $isNested) + { + if (!$isNested) { + foreach ($entity->toArray() as $property => $value) { + $array[BaseCaster::PREFIX_PROTECTED . $property] = $value; + } + } + + return $array; + } + + /** + * Casts \Drupal\Core\Config\ConfigBase classes. + */ + public static function castConfig($config, $array, $stub, $isNested) + { + if (!$isNested) { + foreach ($config->get() as $property => $value) { + $array[BaseCaster::PREFIX_VIRTUAL . $property] = $value; + } + } + + return $array; + } + + /** + * Casts \Drupal\Component\DependencyInjection\Container classes. + */ + public static function castContainer($container, $array, $stub, $isNested) + { + if (!$isNested) { + $service_ids = $container->getServiceIds(); + sort($service_ids); + foreach ($service_ids as $service_id) { + $service = $container->get($service_id); + $array[BaseCaster::PREFIX_VIRTUAL . $service_id] = is_object($service) ? get_class($service) : $service; + } + } + + return $array; + } + + /** + * Casts \Drupal\Component\Render\MarkupInterface classes. + */ + public static function castMarkup($markup, $array, $stub, $isNested) + { + if (!$isNested) { + $array[BaseCaster::PREFIX_VIRTUAL . 'markup'] = (string) $markup; + } + + return $array; + } +}