first commit
This commit is contained in:
53
bundles/KupShop/ArticlesBundle/GTM/PageViews/Article.php
Normal file
53
bundles/KupShop/ArticlesBundle/GTM/PageViews/Article.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KupShop\ArticlesBundle\GTM\PageViews;
|
||||
|
||||
use KupShop\ComponentsBundle\Interfaces\GTMComponentInterface;
|
||||
use KupShop\ComponentsBundle\Twig\BaseComponent;
|
||||
use KupShop\GTMBundle\PageType\ArticlePageType;
|
||||
|
||||
class Article extends ArticlePageType implements GTMComponentInterface
|
||||
{
|
||||
/**
|
||||
* @param \KupShop\ArticlesBundle\Twig\Components\Articles\Detail\View $component
|
||||
*/
|
||||
public function getPushData($component): object
|
||||
{
|
||||
$a = new \stdClass();
|
||||
$article = $component->articleForGTM();
|
||||
$a->category = $article['section']['name'] ?? '';
|
||||
$a->name = $article['title'];
|
||||
$a->tags = array_values($article['tags'] ?? []);
|
||||
$a->authors = array_values(array_map(function ($author) {
|
||||
return [
|
||||
'name' => $author['name'],
|
||||
'email' => $author['email'],
|
||||
'id' => $author['id'],
|
||||
];
|
||||
}, $article['authors'] ?? []));
|
||||
$a->date_created = date_create($article['date'])->format('Y-m-d');
|
||||
$a->read_time = $article['data']['readTime'] ?? false;
|
||||
|
||||
return (object) ['article' => $a];
|
||||
}
|
||||
|
||||
protected function getFirstRelatedBranch($aID)
|
||||
{
|
||||
return sqlQueryBuilder()
|
||||
->select('ab.name')
|
||||
->from('articles_relation', 'ar')
|
||||
->leftJoin('ar', 'articles_branches', 'ab', 'ar.id_branch = ab.id')
|
||||
->where('ar.id_art=:aID')
|
||||
->setParameter('aID', $aID)
|
||||
->setMaxResults(1)
|
||||
->execute()
|
||||
->fetchOne();
|
||||
}
|
||||
|
||||
public function getPageTypeString(BaseComponent $component): ?string
|
||||
{
|
||||
return 'article';
|
||||
}
|
||||
}
|
||||
26
bundles/KupShop/ArticlesBundle/GTM/PageViews/Articles.php
Normal file
26
bundles/KupShop/ArticlesBundle/GTM/PageViews/Articles.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ArticlesBundle\GTM\PageViews;
|
||||
|
||||
use KupShop\ArticlesBundle\Twig\Components\Articles\View;
|
||||
use KupShop\ComponentsBundle\Interfaces\GTMComponentInterface;
|
||||
use KupShop\ComponentsBundle\Twig\BaseComponent;
|
||||
use KupShop\GTMBundle\PageType\ArticlesViewType;
|
||||
|
||||
class Articles extends ArticlesViewType implements GTMComponentInterface
|
||||
{
|
||||
/** @param View $component */
|
||||
public function getPushData($component): object
|
||||
{
|
||||
return (object) [
|
||||
'articles' => [
|
||||
'artPath' => $this->getBreadcrumbsWithoutCurrent(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getPageTypeString(BaseComponent $component): ?string
|
||||
{
|
||||
return 'blog';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user