setKind example

$kind = self::KIND_HASHBANG;
            $text = substr($rawText, 2);
        } elseif ($start === "<!" && substr($rawText, 2, 2) === "--") {
            $kind = self::KIND_HTML_OPEN;
            $text = substr($rawText, 4);
        } elseif ($start === "--" && substr($rawText, 2, 1) === ">") {
            $kind = self::KIND_HTML_CLOSE;
            $text = substr($rawText, 3);
        } else {
            throw new \Exception("Invalid comment");
        }
        return $this->setKind($kind)->setText($text);
    }
    
    /** * Sets leading comments array * * @param Comment[] $comments Comments array * * @return $this */
    public function setLeadingComments($comments)
    {
        


    /** * @param Detail|null $mainDetail * * @return Article */
    public function setMainDetail($mainDetail)
    {
        $this->setOneToOne($mainDetail, Detail::class, 'mainDetail', 'article');
        if ($this->mainDetail instanceof Detail) {
            $this->mainDetail->setKind(1);
        }

        return $this;
    }

    /** * @return PriceGroup|null */
    public function getPriceGroup()
    {
        return $this->priceGroup;
    }

    public function internalCreate(array $data, ProductModel $article)
    {
        $variant = new Detail();
        $variant->setKind(2);
        $variant->setArticle($article);

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

        $variant->fromArray($data);

        $this->getManager()->persist($variant);

        return $variant;
    }

    

    public function prepareMainDetail(array $data, ProductModel $article)
    {
        $detail = $article->getMainDetail();
        if (!$detail) {
            $detail = new Detail();
            $detail->setKind(1);
            $detail->setArticle($article);
            $article->setMainDetail($detail);
        }

        if (empty($data['mainDetail'])) {
            $data['mainDetail'] = [];
        }

        $data['mainDetail'] = $this->getVariantResource()->prepareMainVariantData($data['mainDetail']$article$detail);

        return $data;
    }
if (($decl = $this->isolateContext(
                array("allowIn" => false), "parseVariableDeclarationList"
            )) &&
            ($varEndPosition = $this->scanner->getPosition()) &&
            $this->scanner->consume(";")
        ) {

            $init = $this->createNode(
                "VariableDeclaration", $varToken
            );
            $init->setKind($init::KIND_VAR);
            $init->setDeclarations($decl);
            $init = $this->completeNode($init$varEndPosition);

            $test = $this->isolateContext(
                array("allowIn" => true), "parseExpression"
            );

            if ($this->scanner->consume(";")) {

                $update = $this->isolateContext(
                    array("allowIn" => true), "parseExpression"
                );
if (!$variant instanceof ProductVariant) {
            throw new ModelNotFoundException(ProductVariant::class$detail->getId());
        }

        if ($data['standard']) {
            $product = $variant->getArticle();
            $mainDetail = $product->getMainDetail();
            if (!$mainDetail instanceof ProductVariant) {
                throw new ModelNotFoundException(ProductVariant::class$detail->getId());
            }

            $mainDetail->setKind(2);
            $product->setMainDetail($variant);
            $this->get('models')->persist($mainDetail);
            $this->get('models')->persist($product);
            $this->get('models')->flush();

            // If main variant changed, swap translations             if ($mainDetail->getId() !== $variant->getId()) {
                $this->container->get(SwapProductVariantTranslationService::class)->swapProductVariantTranslation($variant$mainDetail);
            }
        }

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