Denormalize Detailed Show

@param array $data
@return DetailedShow
@throws UnimplementedAttributeException
334826
final protected function denormalizeDetailedShow(array $data)
    {
        $detailedShow = new DetailedShow();

        $referenceMap = [
            'showid' => 'setShowId',
            'name' => 'setName',
            'showname' => 'setName',
            'link' => 'setLink',
            'image' => 'setImage',
            'showlink' => 'setLink',
            'ended' => 'setEnded',
            'country' => 'setCountry',
            'origin_country' => 'setOriginCountry',
            'seasons' => 'setSeasonCount',
            'totalseasons' => 'setSeasonCount',
            'status' => 'setStatus',
            'runtime' => 'setRuntime',
            'classification' => 'setClassification',
            'airtime' => 'setAirtime',
            'airday' => 'setAirday',
            'timezone' => 'setTimeZone'
        ];

        $complexMap = [
            'akas' => 'handleAkas',
            'genres' => 'handleGenres',
            'network' => 'handleNetwork',
            'Episodelist' => 'handleEpisodeList',
        ];

        $ignore = [
            'startdate' => null,
            'started' => null,
        ];

        foreach ($data as $attribute => $value) {
            if (array_key_exists($attribute, $referenceMap)) {
                $detailedShow->$referenceMap[$attribute]($value);
            } elseif (array_key_exists($attribute, $complexMap)) {
                $this->$complexMap[$attribute]($detailedShow, $value);
            } elseif (!array_key_exists($attribute, $ignore)) {
                throw new UnimplementedAttributeException(sprintf(
                    'Attribute %s is not implemented',
                    $attribute
                ));
            }
        }

        return $detailedShow;
    }
768558
protected function denormalize($data, $toEntity = null)
    {
        return $this->serializer->denormalize($data, $this->entityClass, $this->factory, $toEntity);
    }
660470
public function denormalize($data, $entityClass, $factory = null, $toEntity = null)
    {
        $context = $this->getDenormalizeContext($this->denormalizeContext, $toEntity);

        if ($factory) {
            $entityClass = $entityClass::$factory($data);
        }

        $entity = $this->serializer->denormalize($data, $entityClass, null, $context);

        // TODO: Ameliorer ce mechanisme
        EntityNormalizer::$isFirstCall = true;

        return $entity;
    }
1090751
public function denormalize($data, $class, $format = null, array $context = [])
    {
        /** @var \Apigee\Edge\Api\Monetization\Entity\RatePlanInterface $entity */
        $entity = parent::denormalize($data, $class, $format, $context);

        $this->fixTimeZoneOnDenormalization($data, $entity, $entity->getOrganization()->getTimezone());

        return $entity;
    }
492711
public static function fromArray(array $data)
    {
        $models = collect($data)->map(function ($value) {
            if ($value instanceof Model) {
                return [$value];
            } elseif ($value instanceof EloquentCollection) {
                return $value->flatten();
            }
        })->collapse()->filter();

        return $models->map(function ($model) {
            return FormatModel::given($model);
        })->all();
    }
921957
protected function unformatPayloadData(array $data)
    {
        $unformattedData = array();

        foreach ($data as $key => $value) {
            $newKey = $this->deserializeColumnName($key);

            if (is_array($value)) {
                $newValue = $this->unformatPayloadData($value);
            } else {
                $newValue = $value;
            }

            $unformattedData[$newKey] = $newValue;
        }

        return $unformattedData;
    }
928860
public function denormalize($data, $class, $format = null, array $context = [])
    {
        foreach ($this->denormalizers as $denormalizer) {
            // Return the result from the first denormalizer that can
            // denormalize this.
            if ($denormalizer->supportsDenormalization($data, $class, $format)) {
                return $denormalizer->denormalize($data, $class, $format, $context);
            }
        }
    }
1338390
private function mergePresetWidget(array $data)
    {
        if (!isset($data['preset']) || !is_string($data['preset'])) {
            return $data;
        }

        $widgetIdent = $data['preset'];

        if ($this instanceof ObjectContainerInterface) {
            if ($this->hasObj()) {
                $widgetIdent = $this->obj()->render($widgetIdent);
            }
        } elseif ($this instanceof ModelInterface) {
            $widgetIdent = $this->render($widgetIdent);
        }

        $presetWidgets = $this->config('widgets');
        if (!isset($presetWidgets[$widgetIdent])) {
            return $data;
        }

        $widgetData = $presetWidgets[$widgetIdent];
        if (isset($widgetData['attachable_objects'])) {
            $widgetData['attachable_objects'] = $this->mergePresetAttachableObjects(
                $widgetData['attachable_objects']
            );
        }

        if (isset($widgetData['default_attachable_objects'])) {
            $widgetData['attachable_objects'] = $this->mergePresetAttachableObjects(
                $widgetData['default_attachable_objects']
            );
        }

        return array_replace_recursive($widgetData, $data);
    }
470086
protected function denormalize(array $items)
    {
        $shows = [];

        foreach ($items as $show) {
            $show = $this->denormalizeDetailedShow($show);
            $shows[] = $show;
        }

        return $shows;
    }
1255796
public function denormalize($data, $class, $format = null, array $context = array())
    {
        $string = parent::denormalize($data, $class, $format, $context);

        return fopen('data:,'.$string, 'r');
    }
633381
private function denormalizeData($data)
    {
        if (is_scalar($data) || $data === null) {
            return $data;
        }

        if (isset($data[$this->classAnnotation])) {
            return $this->denormalizeObject($data);
        }

        return array_map([$this, 'denormalizeData'], $data);
    }
1293393
public function setData(array $data)
    {
        $this->isMergingData = true;
        /**
         * @todo Kinda hacky, but works with the concept of form.
         *     Should work embeded in a form group or in a dashboard.
         */
        $data = array_merge($_GET, $data);

        parent::setData($data);

        /** Merge any available presets */
        $data = $this->mergePresets($data);

        parent::setData($data);

        $this->isMergingData = false;

        if ($this->lang()) {
            $this->translator()->setLocale($this->lang());
        }

        return $this;
    }
1271918
public function denormalize($data, $class, $format = null, array $context = [])
    {
        // Avoid issues with proxies if we populated the object
        if (!isset($context[self::OBJECT_TO_POPULATE]) && isset($data['data']['id'])) {
            if (true !== ($context['api_allow_update'] ?? true)) {
                throw new NotNormalizableValueException('Update is not allowed for this operation.');
            }

            $context[self::OBJECT_TO_POPULATE] = $this->iriConverter->getItemFromIri(
                $data['data']['id'],
                $context + ['fetch_data' => false]
            );
        }

        // Merge attributes and relationships, into format expected by the parent normalizer
        $dataToDenormalize = array_merge(
            $data['data']['attributes'] ?? [],
            $data['data']['relationships'] ?? []
        );

        return parent::denormalize(
            $dataToDenormalize,
            $class,
            $format,
            $context
        );
    }
487962
public function denormalize($data, $class, $format = null, array $context = array())
    {
        if (!($_class = $this->getClassFromArray($data))) {
            return parent::denormalize($data, $class, $format, $context);
        }

        $class = $_class;

        return parent::denormalize($data, $class, $format, $context);
    }
422533
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
    {
        if (!($_class = $this->getClassFromArray($data))) {
            return parent::denormalizeProperty($data, $class, $name, $format, $context);
        }

        $class = $_class;
        if (!$this->serializer instanceof DenormalizerInterface) {
            $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
            throw new RuntimeException(sprintf($message, $name));
        }

        return $this->serializer->denormalize($data, $class, $format, $context);
    }
576212
public function mergePropertyData(array $data)
    {
        $this->propertyData = array_replace($this->propertyData, $data);

        if (!$this->isMergingWidgetData) {
            $this->setCoreData($this->propertyData);
        }

        if ($this->property) {
            $this->property->setData($data);
        }

        return $this;
    }
445977
protected function flattenData(array $data, $prefix = '', $format = '%s')
    {
        $flat = array();

        foreach ($data as $name => $value) {

            $ref = $prefix . sprintf($format, $name);

            if (is_array($value)) {

                $flat += $this->flattenData($value, $ref, '[%s]');
                continue;
            }

            $flat[$ref] = $value;
        }

        return $flat;
    }