Pimcore\Model\Object\ClassDefinition\Data\Hotspotimage::getFromWebserviceImport PHP Method

getFromWebserviceImport() public method

public getFromWebserviceImport ( mixed $value, null $object = null, array $params = [], null $idMapper = null ) : null | Asset | Pimcore\Model\Object\Data\Hotspotimage
$value mixed
$object null
$params array
$idMapper null
return null | Pimcore\Model\Asset | Pimcore\Model\Object\Data\Hotspotimage
    public function getFromWebserviceImport($value, $object = null, $params = [], $idMapper = null)
    {
        if (!is_null($value)) {
            $value = json_decode(json_encode($value), true);
            if ($value['image__image']) {
                $value['image__image'] = $idMapper->getMappedId('asset', $value['image__image']);
            }
        }
        if (is_array($value) && isset($value['image__hotspots']) && $value['image__hotspots']) {
            $value['image__hotspots'] = serialize($value['image__hotspots']);
        }
        $hotspotImage = $this->getDataFromResource($value);
        /** @var $hotspotImage Object\Data\Hotspotimage */
        if (!$hotspotImage) {
            return null;
        }
        $theImage = $hotspotImage->getImage();
        if (!$theImage) {
            return null;
        }
        $id = $theImage->getId();
        $asset = Asset::getById($id);
        if (empty($id)) {
            return null;
        } elseif (is_numeric($id) and $asset instanceof Asset) {
            $hotspotImage->setImage($asset);
            return $hotspotImage;
        } else {
            if (!$idMapper || !$idMapper->ignoreMappingFailures()) {
                throw new \Exception("cannot get values from web service import - invalid data, referencing unknown (hotspot) asset with id [ " . $id . " ]");
            } else {
                $idMapper->recordMappingFailure("object", $relatedObject->getId(), "asset", $value);
            }
        }
    }