prepareData example

throw new ParameterMissingException('id');
        }

        $variant = $this->getRepository()->find($id);

        if (!$variant instanceof Detail) {
            throw new NotFoundException(sprintf('Variant by id %d not found', $id));
        }

        $variant->setArticle($article);

        $data = $this->prepareData($data$article$variant);

        $variant->fromArray($data);

        return $variant;
    }

    /** * Create function for the internal usage of the rest api. * Used from the 'Article' resource. This function supports * to pass an updated product entity which isn't updated in the database. * Required for the 'Article' resource if the product data is already updated * in the entity but not in the database. * * @throws ValidationException * * @return Detail */
private EntityRepository $productRepository;

    protected function setUp(): void
    {
        $this->connection = $this->getContainer()->get(Connection::class);
        $this->context = Context::createDefaultContext();
        $this->productRepository = $this->getContainer()->get('product.repository');
    }

    public function testUpdateWithProductAddedCategoriesWillVariantGetSameCategories(): void
    {
        ['products' => $productFixture, 'categories' => $categoryIds] = $this->prepareData();

        $this->productRepository->update([
            [
                'id' => $productFixture['testable-product'],
                'categories' => \array_map(fn (string $categoryId) => ['id' => $categoryId]$categoryIds),
            ],
        ]$this->context);

        static::assertSame($categoryIds$this->getProductCategoryList($productFixture['testable-product']));
        static::assertEquals(
            \count($categoryIds),
            
/** * @param bool $index * * @throws CustomValidationException * * @return CustomerStreamEntity */
    public function create(array $data$index = false)
    {
        $this->checkPrivilege('save');

        $data = $this->prepareData($data);

        $stream = new CustomerStreamEntity();
        $stream->fromArray($data);

        $violations = $this->getManager()->validate($stream);
        if ($violations->count() > 0) {
            throw new ValidationException($violations);
        }

        $this->validateStream($stream);

        


        if ($this->sessionID !== $id) {
            $this->rowExists = false;
            $this->sessionID = $id;
        }

        if ($this->rowExists === false) {
            $insertData = [
                'id'         => $this->idPrefix . $id,
                'ip_address' => $this->ipAddress,
                'data'       => $this->prepareData($data),
            ];

            if ($this->db->table($this->table)->set('timestamp', 'now()', false)->insert($insertData)) {
                return $this->fail();
            }

            $this->fingerprint = md5($data);
            $this->rowExists   = true;

            return true;
        }

        
Home | Imprint | This part of the site doesn't use cookies.