Set blog.

@param string $blog

@return $this
424714
public function setBlog(Blog $blog)
    {
        $this->blog = $blog;
        foreach ($this->children as $child) {
            $child->setBlog($blog);
        }

        return $this;
    }
871770
public function setDatabase($database)
    {
        if (! $database instanceof MongoDB) {
            $database = $this->connection->getConnection()->{$database};
        }

        $this->database = $database;

        return $this;
    }
767863
public function newPostAction(Request $request, Blog $blog)
    {
        $article = new Article();
        $article->setBlog($blog);
        $form = $this->createForm(ArticleType::class, $article);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $page = $this->get('victoire_blog.manager.article')->create(
                $article,
                $this->getUser()
            );

            $dispatcher = $this->get('event_dispatcher');
            $event = new ArticleEvent($article);
            $dispatcher->dispatch(VictoireBlogEvents::CREATE_ARTICLE, $event);

            if (null === $response = $event->getResponse()) {
                $response = new JsonResponse([
                    'success' => true,
                    'url'     => $this->generateUrl('victoire_core_page_show', [
                        '_locale' => $request->getLocale(),
                        'url'     => $page->getUrl(),
                    ]),
                ]);
            }

            return $response;
        }

        return new JsonResponse([
            'success' => false,
            'message' => $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
            'html'    => $this->container->get('templating')->render(
                'VictoireBlogBundle:Article:new.html.twig',
                [
                    'form'   => $form->createView(),
                    'blogId' => $blog->getId(),
                ]
            ),
        ]);
    }
275779
public function setLanguage($language)
    {
        $this->setLocale($language);

        $code = $this->getLanguageCode($language);

        putenv('LC_ALL=' . $code);
        setlocale(LC_ALL, $code);
        setlocale(LC_NUMERIC, 'en_US');

        return $this;
    }
377545
public function setImage(string $image)
    {
        $this->image = $image;

        $this->raw = array_merge($this->raw, ['Image' => $image]);

        return $this;
    }
397008
public function setPosts(ArrayCollection $posts)
    {
        /** @var \Icap\BlogBundle\Entity\Post[] $posts */
        foreach ($posts as $post) {
            $post->setBlog($this);
        }

        $this->posts = $posts;

        return $this;
    }
213612
public function newAction(Blog $blog)
    {
        try {
            $article = new Article();
            $article->setBlog($blog);
            $form = $this->createForm(ArticleType::class, $article);

            return new JsonResponse([
                'html' => $this->container->get('templating')->render(
                    'VictoireBlogBundle:Article:new.html.twig',
                    [
                        'form'   => $form->createView(),
                        'blogId' => $blog->getId(),
                    ]
                ),
            ]);
        } catch (NoResultException $e) {
            return new JsonResponse([
                'success' => false,
                'message' => $e->getMessage(),
            ]);
        }
    }
695716
public function setEmail($email)
    {
        $email = trim($email);

        if (preg_match('/\<(.*)\>/', $email, $matches)) {
            $email = trim(str_replace($matches[ 0 ], '', $email));
            $name = $matches[ 1 ];
        }

        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $this->email = $email;

            if (isset($name)) {
                $this->setName($name);
            }
        }

        return $this;
    }
275893
public function updatePost(Blog $blog, Post $existingPost, Post $post, User $user)
    {
        $existingPost
        ->setTitle($post->getTitle())
        ->setContent($post->getContent());
        if (null !== $post->getPublicationDate()) {
            $existingPost->setPublicationDate($post->getPublicationDate());
        } else {
            $existingPost->setPublicationDate(null);
        }

        $this->om->flush();

        $unitOfWork = $this->om->getUnitOfWork();
        $unitOfWork->computeChangeSets();
        $changeSet = $unitOfWork->getEntityChangeSet($existingPost);

        $this->trackingManager->dispatchPostUpdateEvent($existingPost, $changeSet);

        if ('anon.' !== $user) {
            $this->trackingManager->updateResourceTracking($blog->getResourceNode(), $user, new \DateTime());
        }

        return $existingPost;
    }
1327546
public function getTagsAction(Blog $blog)
    {
        $this->checkPermission('OPEN', $blog->getResourceNode(), [], true);

        $parameters['limit'] = -1;
        $posts = $this->postManager->getPosts(
            $blog->getId(),
            $parameters,
            $this->checkPermission('ADMINISTRATE', $blog->getResourceNode())
            || $this->checkPermission('EDIT', $blog->getResourceNode())
            || $this->checkPermission('MODERATE', $blog->getResourceNode())
                ? PostManager::GET_ALL_POSTS
                : PostManager::GET_PUBLISHED_POSTS,
            true);

        $postsData = [];
        if (!empty($posts)) {
            $postsData = $posts['data'];
        }

        return new JsonResponse($this->blogManager->getTags($blog, $postsData));
    }
1227619
public function dispatchPostCreateEvent(Blog $blog, Post $post)
    {
        $event = new LogPostCreateEvent($post);

        return $this->dispatch($event);
    }
391809
protected function setPagerListBlog()
    {
        $pager = array(
            'total' => $this->data_total,
            'query' => $this->query_filter,
            'limit' => $this->configTheme('blog_limit', 20)
        );

        return $this->data_limit = $this->setPager($pager);
    }
373620
public function updateComment(Blog $blog, Comment $existingComment, $message)
    {
        $existingComment
            ->setMessage($message)
            ->setStatus($blog->isAutoPublishComment() ? Comment::STATUS_PUBLISHED : Comment::STATUS_UNPUBLISHED)
            ->setPublicationDate($blog->isAutoPublishComment() ? new \DateTime() : null);

        $this->om->flush();

        $unitOfWork = $this->om->getUnitOfWork();
        $unitOfWork->computeChangeSets();
        $changeSet = $unitOfWork->getEntityChangeSet($existingComment);

        $this->trackingManager->dispatchCommentUpdateEvent($existingComment->getPost(), $existingComment, $changeSet);

        return $existingComment;
    }
1116840
public function setCampaign($campaign)
    {
        if ($campaign instanceof Campaign) {
            $campaign = $campaign->getId();
        }
        $this->campaign = $campaign;

        return $this;
    }
1191175
private function getSettingsForm(Blog $blog)
    {
        return $this->createForm($this->getPageSettingsType(), $blog, [
            'attr' => [
                'novalidate'   => true,
                'v-ic-post-to' => $this->generateUrl('victoire_blog_settings', [
                    'id' => $blog->getId(),
                ]),
                'v-ic-target' => '#victoire-blog-settings',
            ],
        ]);
    }
1288659
public function allowLogs($flag = true)
    {
        $this->allowLogs = (bool) $flag;
        
        if (true === $flag) {
            $this->init();
        }
        
        return $this;
    }
314661
public function setRecord($record) {
    $this->resetObject();
    $newRecord = array();
    foreach ($this->fields as $field_name => $field) {
      if (!empty($record[$field_name])) {
        $newRecord[$field_name] = $record[$field_name];
      }
      else {
        $newRecord[$field_name] = ''; //Adds the field but with empty string.
      }
    }
    $this->record = $newRecord;
    $this->fetchedRecord = $record;

    return $this;
  }