Handles updating of the product type.

@param AttributeRepository $attributeRepository
@param Dispatcher $event
@return Attribute
352108
public function handle(AttributeRepository $attributeRepository, Dispatcher $event)
    {
        $attribute = $attributeRepository->find($this->id)->fill(get_object_vars($this));

        $attributeRepository->save($attribute);

        $event->fire(new AttributeWasUpdated($attribute));

        return $attribute;
    }
848182
public function updateAccessoryPosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        return $this->genericUpdatePosition(AccessoryQuery::create(), $event, $dispatcher);
    }
1069378
public function updateOrCreateProductAttributeForProduct(
        ProductInterface $product,
        Attribute $attribute,
        array $attributeData,
        $locale
    ) {
        // Check if ProductAttribute already exists for attribute
        $existingProductAttribute = $this->retrieveProductAttributeByAttribute(
            $product,
            $attribute
        );

        // If product-attribute already exists we just need to update the translation.
        if ($existingProductAttribute) {
            $this->setOrCreateAttributeValueTranslation(
                $existingProductAttribute->getAttributeValue(),
                $attributeData['attributeValueName'],
                $locale
            );

            return;
        }

        // Create new AttributeValue and ProductAttribute.
        $attributeValue = $this->createAttributeValue(
            $attribute,
            $attributeData['attributeValueName'],
            $locale
        );
        $this->createProductAttribute(
            $attribute,
            $product,
            $attributeValue
        );
    }
469050
public function update(CategoryUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
            $category
                ->setDispatcher($dispatcher)
                ->setDefaultTemplateId($event->getDefaultTemplateId() == 0 ? null : $event->getDefaultTemplateId())
                ->setLocale($event->getLocale())
                ->setTitle($event->getTitle())
                ->setDescription($event->getDescription())
                ->setChapo($event->getChapo())
                ->setPostscriptum($event->getPostscriptum())

                ->setParent($event->getParent())
                ->setVisible($event->getVisible())

                ->save();

            $event->setCategory($category);
        }
    }
490276
public function handle(ProductRepository $productRepository, Dispatcher $event)
    {
        $product = $productRepository->find($this->id)->fill(array_except(get_object_vars($this), ['attributes']));

        $productRepository->save($product, $this->attributes);

        $event->fire(new ProductWasUpdated($product));

        return $product;
    }
853708
public function updatePosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $this->genericUpdateDelegatePosition(
            ProductCategoryQuery::create()
                ->filterByProductId($event->getObjectId())
                ->filterByCategoryId($event->getReferrerId()),
            $event,
            $dispatcher
        );
    }
1049922
public function editAction($attributeId, $id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Attribute $attribute */
        $attribute = $em->getRepository('EcommerceBundle:Attribute')->find($attributeId);

        if (!$attribute) {
            throw $this->createNotFoundException('Unable to find Attribute entity.');
        }

        /** @var AttributeValue $entity */
        $entity = $em->getRepository('EcommerceBundle:AttributeValue')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find AttributeValue entity.');
        }

        $editForm = $this->createForm(new AttributeValueType(), $entity);
        $deleteForm = $this->createDeleteForm($attributeId, $id);

        return array(
            'entity'      => $entity,
            'attribute'   => $attribute,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
28467
public function handle(AttributeRepository $attributeRepository, AttributeValueRepository $attributeValueRepository,
                           Dispatcher $event)
    {
        $attribute = $attributeRepository->find($this->attributeId);

        $attributeValue = AttributeValue::instantiate($attribute, $this->value);

        $attributeValueRepository->save($attributeValue);

        $event->fire(new AttributeValueWasStored($attributeValue));

        return $attributeValue;
    }
1325176
public function attributeUseHandler(
        string $attribute,
        Type\HandlerDeserializerInterface $deserialize,
        Type\HandlerSerializerInterface $serialize
    ): ObjectInterface {
        $this->attributes[$attribute] = new Type\Handler($deserialize, $serialize);

        return $this;
    }
242892
public function update($productId, $file, $data, $storeView = null, $identifierType = null)
    {
        return $this->__createAction('catalogProductAttributeMediaUpdate', func_get_args());
    }
1313469
public function create(AttributeAvCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $attribute = new AttributeAvModel();

        $attribute
            ->setDispatcher($dispatcher)

            ->setAttributeId($event->getAttributeId())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())

            ->save()
        ;

        $event->setAttributeAv($attribute);
    }
938305
public function update(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $coupon = $event->getCouponModel();

        $this->createOrUpdate($coupon, $event, $dispatcher);
    }
3480
public function onUpdated(UpdatedEvent $event)
    {
        if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
            $this->addPackage($event->getPackage());
        }
    }
267895
public function handle(AttributeRepository $attributeRepository, Dispatcher $event)
    {
        $attribute = $attributeRepository->find($this->id);

        // TODO : Check if the attribute is in use

        $attributeRepository->destroy($attribute);

        $event->fire(new AttributeWasDestroyed($attribute));

        return $attribute;
    }
450903
public function handle(AttributeValueRepository $attributeValueRepository, Dispatcher $event)
    {
        $attributeValue = $attributeValueRepository->find($this->id);

        $attributeValueRepository->destroy($attributeValue);

        $event->fire(new AttributeValueWasDestroyed($attributeValue));

        return $attributeValue;
    }
1211576
public function update(TemplateUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) {
            $template
                ->setDispatcher($dispatcher)
                
                ->setLocale($event->getLocale())
                ->setName($event->getTemplateName())
                ->save();
            
            $event->setTemplate($template);
        }
    }
845935
protected function genericUpdateDelegatePosition(ModelCriteria $query, UpdatePositionEvent $event, EventDispatcherInterface $dispatcher = null)
    {
        if (null !== $object = $query->findOne()) {
            if (!isset(class_uses($object)['Thelia\Model\Tools\PositionManagementTrait'])) {
                throw new \InvalidArgumentException("Your model does not implement the PositionManagementTrait trait");
            }

            //$object->setDispatcher($dispatcher !== null ? $dispatcher : $event->getDispatcher());

            $mode = $event->getMode();

            if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) {
                $object->changeAbsolutePosition($event->getPosition());
            } elseif ($mode == UpdatePositionEvent::POSITION_UP) {
                $object->movePositionUp();
            } elseif ($mode == UpdatePositionEvent::POSITION_DOWN) {
                $object->movePositionDown();
            }
        }
    }