@param Article $article

@return self
333115
public static function createFromArticle(Article $article): self
    {
        $message = new self();
        $message->setId($article->getId());
        $message->setStatus($article->getStatus());
        $message->setMediaLimit($article->getMediaLimit());
        $message->setShareOnFacebook($article->isShareOnFacebook());

        $categoryIds = array_map(function (Category $category) {
            return $category->getId();
        }, $article->getCategories());

        $message->setCategoryIds($categoryIds);

        foreach ($article->getTranslations() as $translation) {
            $translationMessage = ArticleTranslationMessage::createFromArticleTranslation($translation);

            $message->addTranslation($translationMessage);
        }

        foreach ($article->getMedias() as $media) {
            $mediaMessage = ArticleMediaMessage::createFromArticleMedia($media);

            $message->addMedia($mediaMessage);
        }

        return $message;
    }
823289
protected function AuthorName(Article $article)
    {
        $author = $article->GetAuthor();
        return $author ? $author->GetFirstName() . ' ' . $author->GetLastName() : '';
    }
817482
public function withExpression(string $expression): self
    {
        if (!(new \ReflectionClass($expression))->implementsInterface(Expression::class)) {
            throw new DomainException($expression);
        }

        $self = clone $this;
        $self->expression = new $expression($self->name);

        return $self;
    }
1302038
protected function Init()
    {
        $this->articles = array();
        $this->articleList = ContentArticleList::Schema()->ByContent($this->Content());
        $this->articlesTotal = 0;
        $this->InitArticles();
        return parent::Init();
    }
302443
public function save(ArticleInterface $article): ArticleInterface
    {
        $data = $this->serializer()->serialize($article);

        if ($article->getId() !== 0) {
            $this->shopware()
                ->put('/api/articles/' . (string)$article->getId(), [], $data);
        } else {
            $response = $this->shopware()->post('/api/articles', [], $data);
            $data = json_decode((string)$response->getBody(), true);
            $dataExists = array_key_exists('data', $data) && is_array($data['data']);
            if (!$dataExists || !array_key_exists('id', $data['data'])) {
                throw new \LogicException('Article could not be created! ' . (string)$response->getBody());
            }
            $article->setId((int)$data['data']['id']);
        }

        return $article;
    }
1022498
public function addArticle(Article $article)
    {
        $article->setBlog($this);
        $this->articles->add($article);

        return $this;
    }
1163019
public function createBlankArticle(Article &$article)
		{
			$form_data = array(
				'article_name' => $article->getName()
			);
			$data = $this->call('createblankarticle', $form_data);

			$article->setId((int)trim($data[1]));
		}
451384
public function getByArticle($article)
    {
        if (\is_scalar($article) && ! empty($article = \trim($article))) {
            // Производим "очистку" входящего значения
            $article = $this->clearArticleValue($article);

            foreach ($this->items as $auto_fine_entry) {
                if ($this->clearArticleValue($auto_fine_entry->getArticle()) === $article) {
                    return $auto_fine_entry;
                }
            }
        }
    }
345041
public function merge(self $attribute)
    {
        if ($this->propertyName === null && $attribute->hasPropertyName()) {
            $this->propertyName = $attribute->getPropertyName();
        }

        if ($this->type === null && $attribute->hasType()) {
            $this->type = $attribute->getType();
        }

        if ($this->many === null && $attribute->hasManyDefined()) {
            $this->many = $attribute->isMany();
        }

        if (empty($this->typeParameters)) {
            $this->typeParameters = $attribute->getTypeParameters();
        }

        if ($this->processNull === null && $attribute->hasProcessNull()) {
            $this->processNull = $attribute->getProcessNull();
        }
    }
866788
public static function filter(&$article)
		{
			if(count($article->textBlocks) < 2)
			{
				return;
			}
			
			$largestCount = -1;
			$largestCountKey = NULL;
			
			foreach ($article->textBlocks as $key => $textBlock) 
			{
				if($textBlock->numWords > $largestCount)
				{
					$largestCountKey = $key;
					$largestCount = $textBlock->numWords;
				}
			}
			
			foreach ($article->textBlocks as $key => $textBlock) 
			{
				if($key != $largestCountKey)
				{
					$textBlock->isContent = false;
					$textBlock->labels[] = Labels::POSSIBLY_CONTENT_LABEL;
				}
			}
		}
794601
public function postArticle(Article $article): Generator
    {
        if (!$this->postingAllowed) {
            throw new \Exception("Posting not allowed");
        }

        // Tell the server we are about to post the article.
        yield from $this->sendCommand(new Command('POST'));

        // Send the encoded article.
        yield from $this->encoder->sendData($this->stream, (string)$article);

        // Verify the article posted successfully.
        $response = $this->encoder->readResponse($this->stream);
        if (!$response->isOk()) {
            throw new RemoteException($response->message(), $response->code());
        }
    }
361676
public function addReturning(string ...$expression) : self
    {
        $this->returningExpressions = array_merge($this->returningExpressions, $expression);

        return $this;
    }
387932
public function allowAttribute($attribute)
    {
        if (is_array($attribute))
        {
            foreach ($attribute as $attrib)
                $this->allowed_attributes[$attrib] = true;
        }
        else
            $this->allowed_attributes[$attribute] = true;
        return $this;
    }
1006936
public function addAttributes(array $attributes): self
    {
        $this->attributes = array_unique(array_merge($this->attributes, $attributes));

        return $this;
    }
1320924
public function setDocument(Document $document): self
    {
        $this->_data = $document;

        $metadata = $this->_getMetadata($document);

        $this->setMetadata($metadata);

        return $this;
    }
496407
public function getArticleShowPermalink(Articles $articles, $absolute = 1)
    {
        return $this->getContainer()->get('router')->generate($this->getArticleShowRoute(), $this->getArticleShowRouteParameters($articles), $absolute);
    }
1312808
public function setIndex($index): self
    {
        if ($index instanceof Index) {
            $index = $index->getName();
        }

        $this->_index = (string) $index;

        return $this;
    }