Comments feature integration
Edit on GitHubInstall Feature Core
Prerequisites
To start feature integration, overview and install the necessary features:
Name | Version |
---|---|
Spryker Core | 201907.0 |
Customer Account Management | 201907.0 |
1) Install the required modules using Composer
Run the following command(s) to install the required modules:
composer require spryker-feature/comments: "^201907.0" --update-with-dependencies
Module | Expected Directory |
---|---|
`Comment` | `vendor/spryker/comment` |
`CommentDataImport` | `vendor/spryker/comment-data-import` |
2) Set up Configuration
Add the following configuration to your project:
Configuration | Specification | Namespace |
---|---|---|
CommentConfig::getAvailableCommentTags() |
Used to allow saving comment tags to the database. | Pyz\Shared\Comment |
A regular expression (See below in config/Shared/config_default.php ) |
Used to close access for not logged customers. | None |
src/Pyz/Zed/Comment/CommentConfig.php
<?php
namespace Pyz\Shared\Comment;
use Spryker\Shared\Comment\CommentConfig as SprykerCommentConfig;
class CommentConfig extends SprykerCommentConfig
{
/**
* @return string[]
*/
public function getAvailableCommentTags(): array
{
return [
'delivery',
'important',
];
}
}
config/Shared/config_default.php
<?php
$config[CustomerConstants::CUSTOMER_SECURED_PATTERN] = '(^(/en|/de)?/comment($|/))';
3) Set up Database Schema and Transfer Objects
Run the following commands to apply database changes and generate entity and transfer changes:
console transfer:generate
console propel:install
console transfer:generate
Database Entity | Type | Event |
---|---|---|
`spy_comment` | table | created |
`spy_comment_tag` | table | created |
`spy_comment_thread` | table | created |
`spy_comment_to_comment_tag` | table | created |
Transfer | Type | Event | Path |
---|---|---|---|
`SpyCommentEntityTransfer` | class | created | `src/Generated/Shared/Transfer/SpyCommentEntityTransfer` |
`SpyCommentTagEntityTransfer` | class | created | `src/Generated/Shared/Transfer/SpyCommentTagEntityTransfer` |
`SpyCommentThreadEntityTransfer` | class | created | `src/Generated/Shared/Transfer/SpyCommentThreadEntityTransfer` |
`SpyCommentToCommentTagEntityTransfer` | class | created | `src/Generated/Shared/Transfer/SpyCommentToCommentTagEntityTransfer` |
`Comment` | class | created | `src/Generated/Shared/Transfer/Comment` |
`CommentThread` | class | created | `src/Generated/Shared/Transfer/CommentThread` |
`CommentTag` | class | created | `src/Generated/Shared/Transfer/CommentTag` |
`CommentFilter` | class | created | `src/Generated/Shared/Transfer/CommentFilter` |
`CommentRequest` | class | created | `src/Generated/Shared/Transfer/CommentRequest` |
`CommentTagRequest` | class | created | `src/Generated/Shared/Transfer/CommentTagRequest` |
`CommentThreadResponse` | class | created | `src/Generated/Shared/Transfer/CommentThreadResponse` |
4) Add Translations
Append glossary according to your configuration:
src/data/import/glossary.csv
comment.validation.error.comment_not_found,Comment not found.,en_US
comment.validation.error.comment_not_found,Kommentar nicht gefunden.,de_DE
comment.validation.error.comment_thread_not_found,Comment Thread not found.,en_US
comment.validation.error.comment_thread_not_found,Kommentar Thread nicht gefunden.,de_DE
comment.validation.error.access_denied,Access denied.,en_US
comment.validation.error.access_denied,Zugriff verweigert.,en_US
comment.validation.error.comment_thread_already_exists,Comment Thread already exists.,de_DE
comment.validation.error.comment_thread_already_exists,Kommentar Thread existiert bereits.,de_DE
comment.validation.error.invalid_message_length,Invalid message length.,en_US
comment.validation.error.invalid_message_length,Ungültige Nachrichtenlänge.,de_DE
comment.validation.error.comment_tag_not_available,Comment tag not available.,en_US
comment.validation.error.comment_tag_not_available,Kommentar-Tag nicht verfügbar.,de_DE
Run the following console command to import data:
console data:import glossary
5) Set up Behavior
Set up Comment Workflow
Enable the following behaviors by registering the plugins:
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
CommentDataImportPlugin |
Imports Comments data. | None | Spryker\Zed\CommentDataImport\Communication\Plugin |
src/Pyz/Zed/DataImport/DataImportDependencyProvider.php
<?php
namespace Pyz\Zed\DataImport;
use Spryker\Zed\CommentDataImport\Communication\Plugin\CommentDataImportPlugin;
use Spryker\Zed\DataImport\DataImportDependencyProvider as SprykerDataImportDependencyProvider;
class DataImportDependencyProvider extends SprykerDataImportDependencyProvider
{
/**
* @return array
*/
protected function getDataImporterPlugins(): array
{
return [
new CommentDataImportPlugin(),
];
}
Install feature frontend
Prerequisites
Please overview and install the necessary features before beginning the integration step.
Name | Version |
---|---|
Spryker Core | 201907.0 |
Customer Account Management | 201907.0 |
1) Install the required modules using Composer
Run the following command(s) to install the required modules:
composer require spryker-feature/comments: "^201907.0" --update-with-dependencies
Module | Expected Directory |
---|---|
`CommentWidget` | `vendor/spryker-shop/comment-widget` |
`CommentWidgetExtension` | `vendor/spryker-shop/comment-widget-extension` |
2) Add Translations
Append glossary according to your configuration:
src/data/import/glossary.csv
comment_widget.comments_to_cart,Comments to Cart,en_US
comment_widget.comments_to_cart,Kommentare zum Warenkorb,de_DE
comment_widget.form.add_comment,Add,en_US
comment_widget.form.add_comment,Hinzufügen,de_DE
comment_widget.form.update_comment,Update,en_US
comment_widget.form.update_comment,Aktualisieren,de_DE
comment_widget.form.remove_comment,Remove,en_US
comment_widget.form.remove_comment,Entfernen,de_DE
comment_widget.form.you,You,en_US
comment_widget.form.you,Sie,de_DE
comment_widget.form.attach,Attach,en_US
comment_widget.form.attach,Anhängen,de_DE
comment_widget.form.unattach,Unattach,en_US
comment_widget.form.unattach, Anhang entfernen,de_DE
comment_widget.form.all,All,en_US
comment_widget.form.all,Alles,de_DE
comment_widget.form.attached,Attached,en_US
comment_widget.form.attached,Angehängt,de_DE
comment_widget.form.button_default,Button,en_US
comment_widget.form.button_default,Schaltfläche,de_DE
comment_widget.form.edited,edited,en_US
comment_widget.form.edited,bearbeitet,de_DE
comment_widget.form.tags,Tags,en_US
comment_widget.form.tags,Tags,de_DE
comment_widget.form.placeholder.add_comment,Add a comment,en_US
comment_widget.form.placeholder.add_comment,Kommentar hinzufügen,de_DE
comment_widget.tags.all,All,en_US
comment_widget.tags.all,Alles,de_DE
comment_widget.tags.delivery,Delivery,en_US
comment_widget.tags.delivery,Lieferung,de_DE
comment_widget.tags.important,Important,en_US
comment_widget.tags.important,Wichtig,de_DE
Run the following console command to import data:
console data:import glossary
3) Enable Controllers
Controller Provider List
Register controller provider(s) in the Yves application
Provider | Namespace |
---|---|
CommentWidgetControllerProvider |
SprykerShop\Yves\CommentWidget\Plugin\Provider |
src/Pyz/Yves/ShopApplication/YvesBootstrap.php
<?php
namespace Pyz\Yves\ShopApplication;
use SprykerShop\Yves\CommentWidget\Plugin\Provider\CommentWidgetControllerProvider;
use SprykerShop\Yves\ShopApplication\YvesBootstrap as SprykerYvesBootstrap;
class YvesBootstrap extends SprykerYvesBootstrap
{
/**
* @param bool|null $isSsl
*
* @return \SprykerShop\Yves\ShopApplication\Plugin\Provider\AbstractYvesControllerProvider[]
*/
protected function getControllerProviderStack($isSsl)
{
return [
new CommentWidgetControllerProvider($isSsl),
];
}
}
Make sure that the error flash message was shown.
4) Set up Widgets
Register the following plugins to enable widgets:
Plugin | Description | Prerequisites | Namespace |
---|---|---|---|
CommentThreadWidget |
Displays comments. | None | SprykerShop\Yves\CommentWidget\Widget |
src/Pyz/Yves/ShopApplication/ShopApplicationDependencyProvider.php
<?php
namespace Pyz\Yves\ShopApplication;
use SprykerShop\Yves\CommentWidget\Widget\CommentThreadWidget;
use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider;
class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider
{
/**
* @return string[]
*/
protected function getGlobalWidgets(): array
{
return [
CommentThreadWidget::class,
];
}
}
Run the following command to enable Javascript and CSS changes:
console frontend:yves:build
Module | Test |
---|---|
`CommentThreadWidget` | You can check availability in twig `{% widget 'CommentThreadWidget' args [...] only %}{% endwidget %}` |
Thank you!
For submitting the form