Skip to content

Commit 332ff6b

Browse files
committed
feat: add tags
1 parent 908991f commit 332ff6b

File tree

26 files changed

+136
-8
lines changed

26 files changed

+136
-8
lines changed

CHANGELOG_de-DE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 4.2.0
2+
- Tags hinzugefügt [5](https://github.com/Werkstattl/OpenBlogware/issues/5)
3+
14
# 4.1.4
25
- Fehler bei Author für Meta-Daten behoben [9](https://github.com/Werkstattl/OpenBlogware/issues/9)
36

CHANGELOG_en-GB.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 4.2.0
2+
- Added tags [5](https://github.com/Werkstattl/OpenBlogware/issues/5)
3+
14
# 4.1.4
25
- Fixed author for meta data [9](https://github.com/Werkstattl/OpenBlogware/issues/9)
36

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "werkstattl/openblogware",
33
"description": "OpenBlogware: A Blog Module for Shopware 6.",
4-
"version": "4.1.4",
4+
"version": "4.2.0",
55
"type": "shopware-platform-plugin",
66
"keywords": ["blog", "news"],
77
"license":"MIT",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Werkl\OpenBlogware\Content\Blog\Aggregate;
5+
6+
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
7+
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
8+
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
9+
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
10+
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
11+
use Shopware\Core\Framework\DataAbstractionLayer\MappingEntityDefinition;
12+
use Shopware\Core\System\Tag\TagDefinition;
13+
use Werkl\OpenBlogware\Content\Blog\BlogEntriesDefinition;
14+
15+
16+
class BlogEntriesTagMappingDefinition extends MappingEntityDefinition
17+
{
18+
public const ENTITY_NAME = 'werkl_blog_entries_tag';
19+
20+
public function getEntityName(): string
21+
{
22+
return self::ENTITY_NAME;
23+
}
24+
25+
protected function defineFields(): FieldCollection
26+
{
27+
return new FieldCollection([
28+
(new FkField('werkl_blog_entries_id', 'blogId', BlogEntriesDefinition::class))->addFlags(new PrimaryKey(), new Required()),
29+
(new FkField('tag_id', 'tagId', TagDefinition::class))->addFlags(new PrimaryKey(), new Required()),
30+
31+
new ManyToOneAssociationField('blog', 'werkl_blog_entries_id', BlogEntriesDefinition::class, 'id', false),
32+
new ManyToOneAssociationField('tag', 'tag_id', TagDefinition::class, 'id', false),
33+
]);
34+
}
35+
}

src/Content/Blog/BlogEntriesDefinition.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Shopware\Core\Framework\DataAbstractionLayer\Field\TranslatedField;
2424
use Shopware\Core\Framework\DataAbstractionLayer\Field\TranslationsAssociationField;
2525
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
26+
use Shopware\Core\System\Tag\TagDefinition;
2627
use Werkl\OpenBlogware\Content\Blog\Aggregate\BlogCategoryMappingDefinition;
2728
use Werkl\OpenBlogware\Content\Blog\BlogEntriesTranslation\BlogEntriesTranslationDefinition;
2829
use Werkl\OpenBlogware\Content\BlogAuthor\BlogAuthorDefinition;
@@ -81,6 +82,7 @@ protected function defineFields(): FieldCollection
8182
(new ManyToManyAssociationField('blogCategories', BlogCategoryDefinition::class, BlogCategoryMappingDefinition::class, 'werkl_blog_entries_id', 'werkl_blog_category_id'))->addFlags(new CascadeDelete(), new ApiAware(), new SearchRanking(SearchRanking::ASSOCIATION_SEARCH_RANKING)),
8283
(new ManyToOneAssociationField('blogAuthor', 'author_id', BlogAuthorDefinition::class, 'id', false))->addFlags(new ApiAware(), new SearchRanking(SearchRanking::ASSOCIATION_SEARCH_RANKING)),
8384
(new OneToOneAssociationField('cmsPage', 'cms_page_id', 'id', CmsPageDefinition::class, false))->addFlags(new ApiAware()),
85+
(new ManyToManyAssociationField('tags', TagDefinition::class, 'werkl_blog_entries_tag', 'werkl_blog_entries_id', 'tag_id'))->addFlags(new ApiAware()),
8486
]);
8587
}
8688
}

src/Content/Blog/BlogEntriesEntity.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
99
use Shopware\Core\Framework\DataAbstractionLayer\EntityCustomFieldsTrait;
1010
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
11+
use Shopware\Core\System\Tag\TagCollection;
1112
use Werkl\OpenBlogware\Content\Blog\BlogEntriesTranslation\BlogEntriesTranslationCollection;
1213
use Werkl\OpenBlogware\Content\BlogAuthor\BlogAuthorEntity;
1314
use Werkl\OpenBlogware\Content\BlogCategory\BlogCategoryCollection;
@@ -57,6 +58,11 @@ class BlogEntriesEntity extends Entity
5758

5859
protected ?CmsPageEntity $cmsPage;
5960

61+
/**
62+
* @var TagCollection|null
63+
*/
64+
protected ?TagCollection $tags = null;
65+
6066
public function getTitle(): ?string
6167
{
6268
return $this->title;
@@ -226,4 +232,20 @@ public function setCmsPageId(string $cmsPageId): void
226232
{
227233
$this->cmsPageId = $cmsPageId;
228234
}
229-
}
235+
236+
/**
237+
* @return TagCollection|null
238+
*/
239+
public function getTags(): ?TagCollection
240+
{
241+
return $this->tags;
242+
}
243+
244+
/**
245+
* @param TagCollection|null $tags
246+
*/
247+
public function setTags(?TagCollection $tags): void
248+
{
249+
$this->tags = $tags;
250+
}
251+
}

src/Content/Blog/BlogSeoUrlRoute.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function prepareCriteria(Criteria $criteria, SalesChannelEntity $salesCha
4040
$criteria->addAssociations([
4141
'blogCategories',
4242
'blogAuthor',
43+
'tags'
4344
]);
4445
}
4546

src/Content/Blog/DataResolver/BlogCmsElementResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function collect(CmsSlotEntity $slot, ResolverContext $resolverContext):
6060
'blogAuthor.media',
6161
'blogAuthor.blogEntries',
6262
'blogCategories',
63+
'tags'
6364
]);
6465

6566
$criteria->addSorting(

src/Content/Blog/DataResolver/BlogDetailCmsElementResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function collect(CmsSlotEntity $slot, ResolverContext $resolverContext):
3636
new EqualsFilter('customFields.salesChannelIds', null),
3737
]));
3838
$criteria
39-
->addAssociations(['blogAuthor', 'blogCategories'])
39+
->addAssociations(['blogAuthor', 'blogCategories', 'tags'])
4040
->addAssociation('cmsPage.sections.backgroundMedia')
4141
->addAssociation('cmsPage.sections.blocks.backgroundMedia');
4242
$criteria

src/Content/Blog/DataResolver/BlogNewestListingCmsElementResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private function createCriteria(FieldConfigCollection $config, SalesChannelConte
113113
'blogAuthor.media',
114114
'blogAuthor.blogEntries',
115115
'blogCategories',
116+
'tags',
116117
]);
117118

118119
$showTypeConfig = $config->get('showType') ?? null;

0 commit comments

Comments
 (0)