/** * @param BlogOptions $blogOptions * @param array $changeSet */ public function __construct(BlogOptions $blogOptions, $changeSet) { $blog = $blogOptions->getBlog(); $details = array('blog' => array('blog' => $blog->getId(), 'options' => json_encode($blogOptions), 'changeSet' => $changeSet)); parent::__construct($blog->getResourceNode(), $details); }
/** * @param UploadedFile $file * @param BlogOptions $options */ public function updateBanner(UploadedFile $file = null, BlogOptions $options) { $ds = DIRECTORY_SEPARATOR; if (file_exists($this->uploadDir . $ds . $options->getBannerBackgroundImage()) || $file === null) { @unlink($this->uploadDir . $ds . $options->getBannerBackgroundImage()); } if ($file) { $uniqid = uniqid(); $options->setBannerBackgroundImage($uniqid); $file->move($this->uploadDir, $uniqid); } else { $options->setBannerBackgroundImage(null); } $this->objectManager->persist($options); $this->objectManager->flush(); }
/** * @ORM\PostPersist */ public function postPersist(LifecycleEventArgs $args) { if (null === $this->getOptions()) { $entityManager = $args->getEntityManager(); $blogOptions = new BlogOptions(); $blogOptions->setBlog($this); $entityManager->persist($blogOptions); $entityManager->flush($blogOptions); } }
/** * @DI\Observe("widget_tag_list") */ public function onWidgetTagListDisplay(DisplayWidgetEvent $event) { $blog = $this->widgetManager->getTagListBlog($event->getInstance()); /** @var \icap\BlogBundle\Entity\WidgetTagListBlog $widgetTagListBlog */ $widgetTagListBlog = $this->widgetManager->getWidgetTagListBlogByWdgetInstance($event->getInstance()); $tagCloud = 0; if ($widgetTagListBlog !== null) { $tagCloud = $widgetTagListBlog->getTagCloud(); } $blogOptions = new BlogOptions(); $blogOptions->setTagCloud($tagCloud); $content = $this->templatingEngine->render('IcapBlogBundle:widget:tags.html.twig', ['blog' => $blog, '_resource' => $blog, 'blogOptions' => $blogOptions]); $event->setContent($content); $event->stopPropagation(); }