Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

8931 compatibility with 6 5 #11

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d08eec9
add translation to blog data
ihormandzyuk Feb 17, 2023
effd100
update config naming
IgorMandzyuk Mar 3, 2023
d98d97e
update short content view
IgorMandzyuk Mar 3, 2023
ba99506
fix issue with short content description view
Mar 3, 2023
7b4e8b8
add seo url template
ihormandzyuk Mar 7, 2023
8aca98f
update translations
ihormandzyuk Mar 7, 2023
efe18bb
update translations logic
ihormandzyuk Mar 8, 2023
d63280b
fixes small issues
ihormandzyuk Apr 5, 2023
23b1d67
update builded admin javascript
ihormandzyuk Apr 5, 2023
9bee468
update events functionality
ihormandzyuk Apr 5, 2023
63a2611
update subsriber
ihormandzyuk Apr 6, 2023
a1ec58b
update blog translation
ihormandzyuk Apr 6, 2023
9300117
Merge branch 'main' into 7831-blog-data-translation
ihormandzyuk Apr 6, 2023
7616ee5
resolve conflict post view
ihormandzyuk Apr 6, 2023
03e141d
fix entity list count
ihormandzyuk Apr 6, 2023
a4a1f48
add breadcrumbs and smass fixes
ihormandzyuk Apr 7, 2023
648063d
update bredcrumb logic
ihormandzyuk Apr 7, 2023
c205eb8
Update article.html.twig
ihormandzyuk Apr 10, 2023
ce2a547
Update article.html.twig
ihormandzyuk Apr 10, 2023
3120990
Update article.html.twig
ihormandzyuk Apr 10, 2023
3872f81
Update article.html.twig
ihormandzyuk Apr 10, 2023
d001ec3
Merge remote-tracking branch 'origin/7793-fix-short-content-view' int…
ihormandzyuk Jul 14, 2023
015c54b
Merge remote-tracking branch 'origin/7793-update-plugin-config-naming…
ihormandzyuk Jul 14, 2023
6150f16
merge to test
ihormandzyuk Jul 14, 2023
90548e7
merge breadcrumbs to test
ihormandzyuk Jul 14, 2023
7c7f83b
add method stubs
ihormandzyuk Jul 14, 2023
de2a0f8
add basic fixes
ihormandzyuk Jul 14, 2023
30757da
remove empty array from criteria
ihormandzyuk Jul 14, 2023
622273c
update repository class
ihormandzyuk Jul 24, 2023
2f7231e
fix compatibility with older than 6.5
ihormandzyuk Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Core/Content/Blog/Author/AuthorDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Magefan\Blog\Core\Content\Blog\Author;

use Magefan\Blog\Core\Content\Blog\Author\AuthorTranslation\AuthorTranslationDefinition;
use Magefan\Blog\Core\Content\Blog\Post\PostDefinition;
use Shopware\Core\Content\Media\MediaDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
Expand Down Expand Up @@ -61,11 +62,10 @@ protected function defineFields(): FieldCollection
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
(new IdField('admin_user_id', 'adminUserId'))->addFlags(new Required()),
(new BoolField('is_active', 'isActive')),
new FkField('media_id', 'mediaId', MediaDefinition::class),

(new StringField('firstname', 'firstname')),
(new StringField('lastname', 'lastname')),
(new StringField('email', 'email')),
(new StringField('role', 'role')),
(new StringField('facebook_page_url', 'facebookPageUrl')),
(new StringField('twitter_page_url', 'twitterPageUrl')),
(new StringField('instagram_page_url', 'instagramPageUrl')),
Expand All @@ -79,6 +79,9 @@ protected function defineFields(): FieldCollection
(new LongTextField('content', 'content')),
(new LongTextField('short_content', 'short_content')),
(new StringField('featured_img', 'featuredImg')),
(new BoolField('is_active', 'isActive')),
(new StringField('email', 'email')),
(new StringField('role', 'role')),
(new StringField('page_layout', 'pageLayout')),
(new StringField('layout_update_xml', 'layoutUpdateXml')),
(new StringField('custom_theme', 'customTheme')),
Expand All @@ -91,7 +94,8 @@ protected function defineFields(): FieldCollection
(new IdField('media_id', 'mediaId')),
(new StringField('created_at', 'createdAt')),
(new StringField('updated_at', 'updatedAt')),
new FkField('media_id', 'mediaId', MediaDefinition::class),

// associations
new OneToManyAssociationField('authorPosts', PostDefinition::class, 'author_id'),
(new OneToOneAssociationField('media', 'media_id', 'id', MediaDefinition::class, true))->addFlags(new ApiAware()),
]);
Expand Down
29 changes: 19 additions & 10 deletions src/Core/Content/Blog/Category/CategoryDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

namespace Magefan\Blog\Core\Content\Blog\Category;

use Magefan\Blog\Core\Content\Blog\Category\CategoryTranslation\CategoryTranslationDefinition;
use Magefan\Blog\Core\Content\Blog\Post\PostDefinition;
use Magefan\Blog\Core\Content\Blog\PostCategory\PostCategoryDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\DateField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\CascadeDelete;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Inherited;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToManyAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\TranslatedField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\TranslationsAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\Framework\DataAbstractionLayer\Field\BoolField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
Expand Down Expand Up @@ -59,16 +63,18 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
(new StringField('title', 'title'))->addFlags(new Required()),
(new StringField('meta_title', 'metaTitle')),
(new StringField('meta_keywords', 'metaKeywords')),
(new StringField('meta_description', 'metaDescription')),
(new StringField('identifier', 'identifier')),
(new LongTextField('content_heading', 'contentHeading')),
(new LongTextField('content', 'content')),
(new StringField('path', 'path')),

//translations
(new TranslatedField('title'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('metaTitle'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('metaKeywords'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('metaDescription'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('contentHeading'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('content'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('path'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('identifier'))->addFlags(new ApiAware(), new Inherited()),

(new IntField('position', 'position')),
(new StringField('path', 'path')),
(new StringField('posts_sort_by', 'postsSortBy')),
(new BoolField('include_in_menu', 'includeInMenu')),
(new BoolField('is_active', 'isActive')),
Expand All @@ -84,7 +90,10 @@ protected function defineFields(): FieldCollection
(new StringField('posts_list_template', 'postsListTemplate')),
(new StringField('created_at', 'createdAt')),
(new StringField('updated_at', 'updatedAt')),

// associations
(new OneToOneAssociationField('blogCategories', 'id', 'category_id', PostCategoryDefinition::class, false))->addFlags(new CascadeDelete()), new ManyToManyAssociationField('blogPosts', PostDefinition::class, PostCategoryDefinition::class, 'category_id', 'post_id'),
(new TranslationsAssociationField(CategoryTranslationDefinition::class, 'magefanblog_category_id'))->addFlags(new ApiAware(), new Required())
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Core\Content\Blog\Category\CategoryTranslation;

use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;

/**
* @method void add(CategoryTranslationEntity $entity)
* @method void set(string $key, CategoryTranslationEntity $entity)
* @method CategoryTranslationEntity[] getIterator()
* @method CategoryTranslationEntity[] getElements()
* @method CategoryTranslationEntity|null get(string $key)
* @method CategoryTranslationEntity|null first()
* @method CategoryTranslationEntity|null last()
*/
class CategoryTranslationCollection extends EntityCollection
{
/**
* @return string
*/
protected function getExpectedClass(): string
{
return CategoryTranslationEntity::class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Core\Content\Blog\Category\CategoryTranslation;

use Magefan\Blog\Core\Content\Blog\Category\CategoryDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityTranslationDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware;
use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
use Shopware\Core\System\Language\LanguageDefinition;

class CategoryTranslationDefinition extends EntityTranslationDefinition
{
public const ENTITY_NAME = 'magefanblog_category_translation';

/**
* @return string
*/
public function getEntityName(): string
{
return self::ENTITY_NAME;
}

/**
* @return string
*/
public function getEntityClass(): string
{
return CategoryTranslationEntity::class;
}

/**
* @return string
*/
public function getCollectionClass(): string
{
return CategoryTranslationCollection::class;
}

protected function getParentDefinitionClass(): string
{
return CategoryDefinition::class;
}

/**
* @return FieldCollection
*/
protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new FkField('language_id', 'languageId', LanguageDefinition::class))->addFlags(new ApiAware(), new Required()),
(new StringField('title', 'title'))->addFlags(new Required()),
(new StringField('meta_title', 'metaTitle')),
(new StringField('meta_keywords', 'metaKeywords')),
(new StringField('meta_description', 'metaDescription')),
(new LongTextField('content_heading', 'contentHeading')),
(new LongTextField('content', 'content')),
(new StringField('identifier', 'identifier')),
(new StringField('path', 'path')),
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Core\Content\Blog\Category\CategoryTranslation;

use DateTimeInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
use Shopware\Core\Framework\DataAbstractionLayer\TranslationEntity;

class CategoryTranslationEntity extends TranslationEntity
{
use EntityIdTrait;
}
5 changes: 3 additions & 2 deletions src/Core/Content/Blog/DataResolver/BlogCategoryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(
public function getCategory($identifier, $context)
{
$criteria = (new Criteria())
->addFilter(new EqualsFilter('identifier', $identifier))
->addFilter(new EqualsFilter('id', $identifier))
->addFilter(new EqualsFilter('isActive', 1))
->addAssociation('blogCategories')
->addAssociation('blogPosts');
Expand Down Expand Up @@ -97,8 +97,9 @@ public function getPostsByCategory($category, $request, $context): EntityCollect
->addAssociation('blogCategories')
->addAssociation('postTags')
->addAssociation('postAuthor')
->addFilter(new EqualsFilter('isActive', 1))
->addSorting(new FieldSorting('postTags'. '.' . $sortBy, $sorting))
->addFilter(new EqualsFilter('postCategories.identifier', $category->getIdentifier()))
->addFilter(new EqualsFilter('postCategories.id', $category->getId()))
->setLimit((bool)$category->getPostsPerPage() ? $category->getPostsPerPage() : $limit)
->setOffset($pageOffset);

Expand Down
9 changes: 0 additions & 9 deletions src/Core/Content/Blog/DataResolver/BlogListResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@

class BlogListResolver
{
/**
* @var EntityRepository
*/
private EntityRepository $blogAuthorRepository;

/**
* @var EntityRepository
*/
private EntityRepository $blogCategoryRepository;

/**
* @var SystemConfigService
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Content/Blog/DataResolver/BlogPostResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
public function getPost($identifier, $context)
{
$postCriteria = (new Criteria())
->addFilter(new EqualsFilter('identifier', $identifier))
->addFilter(new EqualsFilter('id', $identifier))
->addFilter(new EqualsFilter('isActive', 1))
->addAssociation('postCategories')
->addAssociation('postTags')
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Content/Blog/DataResolver/BlogTagResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getTag($tagId, $context)
{
$criteria = (new Criteria())
->addFilter(new EqualsFilter('isActive', 1))
->addFilter(new EqualsFilter('identifier', $tagId))
->addFilter(new EqualsFilter('id', $tagId))
->addAssociation('postTags');

$author = $this->blogTagRepository->search($criteria, $context->getContext())->getEntities()->first();
Expand Down
42 changes: 26 additions & 16 deletions src/Core/Content/Blog/Post/PostDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Magefan\Blog\Core\Content\Blog\Author\AuthorDefinition;
use Magefan\Blog\Core\Content\Blog\Category\CategoryDefinition;
use Magefan\Blog\Core\Content\Blog\Comment\CommentDefinition;
use Magefan\Blog\Core\Content\Blog\Post\PostTranslation\PostTranslationDefinition;
use Magefan\Blog\Core\Content\Blog\PostCategory\PostCategoryDefinition;
use Magefan\Blog\Core\Content\Blog\PostTag\PostTagDefinition;
use Magefan\Blog\Core\Content\Blog\Tag\TagDefinition;
Expand All @@ -20,12 +21,14 @@
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\AllowHtml;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Inherited;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToManyAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToManyAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\TranslatedField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\TranslationsAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\Framework\DataAbstractionLayer\Field\BoolField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
Expand Down Expand Up @@ -68,33 +71,40 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
(new StringField('title', 'title'))->addFlags(new Required()),
(new StringField('meta_title', 'metaTitle')),
(new StringField('meta_keywords', 'metaKeywords')),
(new StringField('meta_description', 'metaDescription')),
(new LongTextField('content_heading', 'contentHeading'))->addFlags(new AllowHtml()),
(new LongTextField('content', 'content'))->addFlags(new AllowHtml()),
(new StringField('identifier', 'identifier'))->addFlags(new Required()),
new FkField('media_id', 'mediaId', MediaDefinition::class),
new FkField('author_id', 'authorId', AuthorDefinition::class),

//translations
(new TranslatedField('title'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('metaTitle'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('metaKeywords'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('metaDescription'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('contentHeading'))->addFlags(new ApiAware(), new AllowHtml()),
(new TranslatedField('content'))->addFlags(new ApiAware(), new AllowHtml()),
(new TranslatedField('featuredImg'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('featuredImgAlt'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('ogTitle'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('ogDescription'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('ogImg'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('ogType'))->addFlags(new ApiAware(), new Inherited()),
(new TranslatedField('identifier'))->addFlags(new ApiAware(), new Inherited()),

(new IntField('position', 'position')),
(new StringField('featured_img', 'featuredImg')),
(new StringField('featured_img_alt', 'featuredImgAlt')),
(new BoolField('include_in_recent', 'includeInRecent')),
(new StringField('og_title', 'ogTitle')),
(new StringField('og_description', 'ogDescription')),
(new IdField('og_img', 'ogImg')),
(new StringField('og_type', 'ogType')),
(new DateTimeField('publish_time', 'publishTime')),
(new StringField('created_at', 'createdAt')),
(new StringField('updated_at', 'updatedAt')),
(new DateTimeField('publish_time', 'publishTime')),
(new BoolField('is_active', 'isActive')),
new FkField('media_id', 'mediaId', MediaDefinition::class),

// associations
(new OneToOneAssociationField('media', 'media_id', 'id', MediaDefinition::class, true))->addFlags(new ApiAware()),
new FkField('author_id', 'authorId', AuthorDefinition::class),
new ManyToOneAssociationField('postAuthor', 'author_id', AuthorDefinition::class, 'id'),
new ManyToManyAssociationField('postTags', TagDefinition::class, PostTagDefinition::class, 'post_id', 'tag_id'),
new ManyToManyAssociationField('postCategories', CategoryDefinition::class, PostCategoryDefinition::class, 'post_id', 'category_id'),
new OneToManyAssociationField('postComments', CommentDefinition::class, 'post_id')
new OneToManyAssociationField('postComments', CommentDefinition::class, 'post_id'),
(new TranslationsAssociationField(PostTranslationDefinition::class, 'magefanblog_post_id'))->addFlags(new ApiAware(), new Required())
]);
}
}
7 changes: 6 additions & 1 deletion src/Core/Content/Blog/Post/PostEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,12 @@ public function setOgType($ogType)
*/
public function getContentHeading(): ?string
{
return $this->contentHeading;
$desc = $this->contentHeading;
if (!$desc) {
$desc = $this->content;
}

return $desc;
}

/**
Expand Down
Loading