<?php
namespace App\Service;
class SeoHelper {
protected $seoGenerator;
protected $name;
protected $description;
protected $tags = [];
public function __construct(
\Symfony\Component\Routing\Generator\UrlGeneratorInterface $urlGeneratorInterface,
\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $params,
\Vich\UploaderBundle\Templating\Helper\UploaderHelper $uploaderHelper,
\Liip\ImagineBundle\Imagine\Cache\CacheManager $cacheManager,
\Leogout\Bundle\SeoBundle\Provider\SeoGeneratorProvider $seoGenerator
) {
$this->urlGeneratorInterface = $urlGeneratorInterface;
$this->uploaderHelper = $uploaderHelper;
$this->cacheManager = $cacheManager;
$this->seoGenerator = $seoGenerator;
$this->params = $params;
}
public function setArticleSeo(\App\Entity\BlogArticle $article) {
$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
$resourcePath = $this->cacheManager->generateUrl($imagePath, 'blog_list');
$link = $this->urlGeneratorInterface->generate('client_blog_article_view', [
'slug' => $article->getSlug()
], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($article->getTitle())
->setDescription($article->getMetaDescription())
->setKeywords($article->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('article')
->setTitle($article->getTitle())
->setDescription($article->getMetaDescription())
->setImage($resourcePath)
->setURL($link)
;
}
public function setCourseSeo(\App\Entity\Course $article) {
$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
$resourcePath = $this->cacheManager->generateUrl($imagePath, 'course_list');
$link = $this->urlGeneratorInterface->generate('client_course_view', [
'slug' => $article->getSlug()
], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($article->getTitle())
->setDescription($article->getMetaDescription())
->setKeywords($article->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('article')
->setTitle($article->getTitle())
->setDescription($article->getMetaDescription())
->setImage($resourcePath)
->setURL($link)
;
}
public function setCareerPathSeo(\App\Entity\CareerPath $article) {
$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
$resourcePath = $this->cacheManager->generateUrl($imagePath, 'career_path_list');
$link = $this->urlGeneratorInterface->generate('client_career_path_view', [
'slug' => $article->getSlug()
], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($article->getTitle())
->setDescription($article->getMetaDescription())
->setKeywords($article->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('article')
->setTitle($article->getTitle())
->setDescription($article->getMetaDescription())
->setImage($resourcePath)
->setURL($link)
;
}
public function setBlogCategorySeo(\App\Entity\BlogCategory $category) {
//$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
//$resourcePath = $this->cacheManager->generateUrl($imagePath, 'blog_list');
$link = $this->urlGeneratorInterface->generate('client_blog_category_article_list', [
'slug' => $category->getSlug()
], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($category->getTitle())
->setDescription($category->getMetaDescription())
->setKeywords($category->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('website')
->setTitle($category->getTitle())
->setDescription($category->getMetaDescription())
//->setImage($category)
->setURL($link)
;
}
public function setCourseCategorySeo(\App\Entity\CourseCategory $category) {
//$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
//$resourcePath = $this->cacheManager->generateUrl($imagePath, 'blog_list');
$link = $this->urlGeneratorInterface->generate('client_course_category_list', [
'slug' => $category->getSlug()
], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($category->getTitle())
->setDescription($category->getMetaDescription())
->setKeywords($category->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('website')
->setTitle($category->getTitle())
->setDescription($category->getMetaDescription())
//->setImage($category)
->setURL($link)
;
}
public function setCareerPathCategorySeo(\App\Entity\CareerPathCategory $category) {
//$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
//$resourcePath = $this->cacheManager->generateUrl($imagePath, 'blog_list');
$link = $this->urlGeneratorInterface->generate('client_career_path_category_list', [
'slug' => $category->getSlug()
], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($category->getTitle())
->setDescription($category->getMetaDescription())
->setKeywords($category->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('website')
->setTitle($category->getTitle())
->setDescription($category->getMetaDescription())
//->setImage($category)
->setURL($link)
;
}
public function setInternalSeo(String $title, String $url) {
//$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
//$resourcePath = $this->cacheManager->generateUrl($imagePath, 'blog_list');
$link = $this->urlGeneratorInterface->generate($url, [], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($title)
//->setDescription($page->getMetaDescription())
//->setKeywords($page->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('website')
->setTitle($title)
//->setDescription($page->getMetaDescription())
//->setImage($category)
->setURL($link)
;
}
public function setPageSeo(\App\Entity\Page $page, $url) {
//$imagePath = $this->uploaderHelper->asset($article->getImageFull(), 'imageFile');
//$resourcePath = $this->cacheManager->generateUrl($imagePath, 'blog_list');
$link = $this->urlGeneratorInterface->generate($url, [], $this->urlGeneratorInterface::ABSOLUTE_URL);
$this->seoGenerator->get('basic')
->setTitle($page->getTitle())
->setDescription($page->getMetaDescription())
->setKeywords($page->getMetaDescription())
->setCanonical($link)
->setRobots(true, true)
;
$this->seoGenerator->get('og')
->setType('website')
->setTitle($page->getTitle())
->setDescription($page->getMetaDescription())
//->setImage($category)
->setURL($link)
;
}
}