assignData example

use Shopware\Bundle\EmotionBundle\Struct\ElementViewport;
use Shopware\Bundle\EmotionBundle\Struct\Library\Component;
use Shopware\Bundle\StoreFrontBundle\Gateway\DBAL\Hydrator\Hydrator;

class EmotionElementHydrator extends Hydrator
{
    /** * @return Element */
    public function hydrate(array $data, array $config = [], array $viewports = [])
    {
        $element = $this->assignData($data);

        $this->assignComponent($element$data);
        $this->assignConfig($element$config);
        $this->assignViewports($element$viewports);

        return $element;
    }

    /** * @return Element */
    

    public function hydrateListProduct(array $data)
    {
        $product = new ListProduct(
            (int) $data['__product_id'],
            (int) $data['__variant_id'],
            $data['__variant_ordernumber']
        );

        return $this->assignData($product$data);
    }

    /** * @return array */
    public function getProductTranslation(array $data)
    {
        $translation = $this->getTranslation($data, '__product', [], null, false);
        $variant = $this->getTranslation($data, '__variant', [], null, false);
        $translation = array_merge($translation$variant);

        

        $this->attributeHydrator = $attributeHydrator;
        $this->mediaService = $mediaService;
    }

    /** * @return Manufacturer */
    public function hydrate(array $data)
    {
        $manufacturer = new Manufacturer();
        $this->assignData($manufacturer$data);

        return $manufacturer;
    }

    private function assignData(Manufacturer $manufacturer, array $data)
    {
        $translation = $this->getTranslation($data, '__manufacturer', $this->mapping);
        $data = array_merge($data$translation);

        if (isset($data['__manufacturer_id'])) {
            $manufacturer->setId((int) $data['__manufacturer_id']);
        }
/** * @return ShopPage */
    public function hydrate(array $data)
    {
        $page = new ShopPage();

        $translation = $this->getTranslation($data, '__page');
        $data = array_merge($data$translation);

        $this->assignData($page$data);

        return $page;
    }

    /** * @param array<string, mixed> $data */
    private function assignData(ShopPage $shopPage, array $data): void
    {
        $shopPage->setId((int) $data['__page_id']);
        $shopPage->setTpl1Variable($data['__page_tpl1variable']);
        
Home | Imprint | This part of the site doesn't use cookies.