Create Article with its author, tags.
Create BusinessPage for this Article.

@param Article $article
@param User    $author

@return BusinessPage
356745
public function create(Article $article, User $author)
    {
        $article->setAuthor($author);

        /** @var Tag[] $tags */
        $tags = $article->getTags();
        if (is_array($tags)) {
            foreach ($tags as $tag) {
                $tag->setBlog($article->getBlog());
                $this->entityManager->persist($tag);
            }
        }

        //Article has to be persisted before BusinessPage generation
        $this->entityManager->persist($article);
        $this->entityManager->flush();

        $page = $this->businessPageBuilder->generateEntityPageFromTemplate(
            $article->getTemplate(),
            $article,
            $this->entityManager
        );

        //Transform VBP into BP
        $this->virtualToBusinessPageTransformer->transform($page);
        $page->setParent($article->getBlog());
        $page->setStatus($article->getStatus());

        $this->entityManager->persist($page);
        $this->entityManager->flush();

        return $page;
    }
1212020
public function edit(Article $article)
    {
        $tags         = Article::existingTags()->pluck('name');
        $selectedTags = implode(',', $article->tagNames());

        return view('administrator.articles.edit', compact('article', 'tags', 'selectedTags'));
    }
549391
public function modified_author() {
		$user_id = get_post_meta($this->ID, '_edit_last', true);
		return ($user_id ? new User($user_id) : $this->author());
	}
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;
    }
277727
public boolean addAuthor(String author) {
        try {
            return add(new Meta(Element.AUTHOR, author));
		} catch (DocumentException de) {
            throw new ExceptionConverter(de);
        }
    }
1295250
public function viewOnFrontend(User $user, Content $content)
    {
        if ($content->canBeShown()) {
            return true;
        }
        return ($content->author->id === $user->id);
    }
823289
protected function AuthorName(Article $article)
    {
        $author = $article->GetAuthor();
        return $author ? $author->GetFirstName() . ' ' . $author->GetLastName() : '';
    }
796405
public function setAuthor(array $author)
    {
        $person = new Person();
        foreach ($author as $authorInstance) {
            Validate::isInstanceOf($authorInstance, $person, 'author');
        }
        $this->author = $author;
    }
751512
private function mapUserToCreatedContent(User $user)
    {
        return new CreatedContent([
            'content' => new RestContent(
                $user->contentInfo,
                $this->repository->getLocationService()->loadLocation($user->contentInfo->mainLocationId),
                $this->repository->getContentService()->loadContentByContentInfo($user->contentInfo),
                $this->repository->getContentTypeService()->loadContentType($user->contentInfo->contentTypeId),
                $this->repository->getContentService()->loadRelations($user->versionInfo)
            ),
        ]);
    }
787933
def create(self, section, article):
        
        return CRUDRequest(self).post(article, create=True, id=section)
1197279
public function run(Article $article): self {
        $this->document($article->getDoc());

        $this->removeXPath('//comment()');
        $this->replace('em, strong, b, i, strike, del, ins', function($node) {
            return !$node->find('img')->count();
        });
        $this->replace('span[class~=dropcap], span[class~=drop_cap]');
        $this->remove('script, style');
        $this->remove('header, footer, input, form, button, aside');
        $this->removeBadTags();
        $this->remove("[id='caption'],[class='caption']");
        $this->remove("[id*=' google '],[class*=' google ']");
        $this->remove("[id*='more']:not([id^=entry-]),[class*='more']:not([class^=entry-])");
        $this->remove("[id*='facebook']:not([id*='-facebook']),[class*='facebook']:not([class*='-facebook'])");
        $this->remove("[id*='facebook-broadcasting'],[class*='facebook-broadcasting']");
        $this->remove("[id*='twitter']:not([id*='-twitter']),[class*='twitter']:not([class*='-twitter'])");
        $this->replace('span', function($node) {
            if (is_null($node->parent())) {
                return false;
            }

            return $node->parent()->is('p');
        });
        $this->convertToParagraph('div, span, article');

        return $this;
    }
937245
public function createAuthorTag($name, $email = null)
    {
        return $this->internalCreateTag(true, 'author', $name, $email ? "<$email>" : null);
    }
190391
public function createNewPageFromTemplate($user, $data)
    {
        if (empty($user)) {
            throw new TrackingException('A valid user is required in ' . get_class($this));
        }
        $validatedData = $data;
        /** @var \Rcm\Entity\Page $page */
        $page = $this->pageRepo->findOneBy(
            [
                'pageId' => $validatedData['page-template'],
                'pageType' => 't'
            ]
        );

        if (empty($page)) {
            throw new PageNotFoundException(
                'No template found for page id: '
                . $validatedData['page-template']
            );
        }

        $pageData = [
            'name' => $validatedData['name'],
            'pageTitle' => $validatedData['pageTitle'],
            'pageType' => 'n', // "n" means "normal"
            'createdByUserId' => $user->getId(),
            'createdReason' => 'New page from template in ' . get_class($this),
            'author' => $user->getName(),
        ];

        $createdPage = $resultRevisionId = $this->pageRepo->copyPage(
            $this->currentSite,
            $page,
            $pageData
        );

        $this->immuteblePageVersionRepo->createUnpublished(
            new PageLocator(
                $this->currentSite->getSiteId(),
                $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType())
            ),
            $this->immutablePageContentFactory->__invoke(
                $createdPage->getPageTitle(),
                $createdPage->getDescription(),
                $createdPage->getKeywords(),
                $this->revisionRepo->find($resultRevisionId)->getPluginWrappers()->toArray()
            ),
            $user->getId(),
            __CLASS__ . '::' . __FUNCTION__
        );
    }
377159
public function addCommentAction(
        Request $request,
        $authorToken,
        $context,
        $source
    ) {
        $requestBag = $request->request;
        $content = $requestBag->get('content');
        $authorName = $requestBag->get('author_name');
        $authorEmail = $requestBag->get('author_email');
        $parentId = $requestBag->get('parent');

        /**
         * @var CommentInterface|null $parent
         */
        $parent = $parentId > 0
            ? $this
                ->commentRepository
                ->find($parentId)
            : null;

        $comment = $this
            ->commentManager
            ->addComment(
                $source,
                $context,
                $content,
                $authorToken,
                $authorName,
                $authorEmail,
                $parent
            );

        $commentStructure = $this
            ->commentCache
            ->createCommentStructure($comment);

        return new Response(json_encode([
            'entity' => $commentStructure,
            'children' => [],
        ]));
    }
556303
def create
      @article = Article.new(params[:article])

      respond_to do |format|
        if @article.save
          format.html { redirect_to edit_category_article_path(@article.category, @article), notice: 'Article was successfully created.' }
          format.json { render json: @article, status: :created, location: @article }
        else
          format.html { render action: "new", :category_id => @article.category, :id => @article }
          format.json { render json: @article.errors, status: :unprocessable_entity }
        end
      end
    end
632727
protected function get_post_author($userid, $course, $forum, $cm, $context) {
        if (!isset($this->users[$userid])) {
            // This user no longer exists.
            return false;
        }

        $user = $this->users[$userid];

        if (!isset($user->groups)) {
            // Initialise the groups list.
            $user->groups = [];
        }

        if (!isset($user->groups[$forum->id])) {
            $user->groups[$forum->id] = groups_get_all_groups($course->id, $user->id, $cm->groupingid);
        }

        // Clone the user object to prevent leaks between messages.
        return (object) (array) $user;
    }
220764
private function createTweet(array $tweet, User $user)
    {
        $this->fields = [
            'id'             => $this->getValue('id', $tweet),
            'text'           => $this->getValue('text', $tweet),
            'source'         => $this->getValue('source', $tweet),
            'url'            => $this->getValue('url', $tweet),
            'retweet_count'  => $this->getValue('retweet_count', $tweet),
            'favorite_count' => $this->getValue('favorite_count', $tweet),
            'created_at'     => $this->getValue('created_at', $tweet),
            'hashtags'       => $this->listHashTags($tweet),
            'user'           => $user
        ];
    }