Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy demoextendsymfonyform1 into demoextendsymfonyform3 #33

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions demoextendsymfonyform3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock
.idea
js/node_modules
37 changes: 37 additions & 0 deletions demoextendsymfonyform3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Demonstration of how to use CQRS in a module

## About

This module adds a new field to Customer: a yes/no field "is allowed to review".
This new field appears:
- in the Customers listing as a new column
- in the Customers Add/Edit form as a new field you can manage

This modules demonstrates
- how to add this field, manage its content and its
properties using modern hooks in Symfony pages
- how to use custom [CQRS](https://devdocs.prestashop.com/1.7/development/architecture/domain/cqrs/) Commands and Queries to separate your domain from your application
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- how to use custom [CQRS](https://devdocs.prestashop.com/1.7/development/architecture/domain/cqrs/) Commands and Queries to separate your domain from your application
- how to use custom [CQRS](https://devdocs.prestashop.com/1.7/development/architecture/domain/cqrs/) Commands and Queries to separate your domain from your application *

- how to use Translator inside modern Symfony module

*This part is demonstrated as a possibility for your module, this is
not mandatory to be done this way.

### Supported PrestaShop versions

This module is compatible with and 1.7.6.0 and above versions.

### Requirements

1. Composer, see [Composer](https://getcomposer.org/) to learn more

### How to install

1. Download or clone module into `modules` directory of your PrestaShop installation
2. Rename the directory to make sure that module directory is named `demoextendsymfonyform3`*
3. `cd` into module's directory and run following commands:
- `composer install` - to download dependencies into vendor folder
4. Install module from Back Office

*Because the name of the directory and the name of the main module file must match.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*Because the name of the directory and the name of the main module file must match.
**Because the name of the directory and the name of the main module file must match.**



11 changes: 11 additions & 0 deletions demoextendsymfonyform3/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "prestashop/demoextendsymfonyform3",
"description": "Help developers to understand how to create module using new hooks and apply best practices when using CQRS",
"autoload": {
"psr-4": {
"DemoCQRSHooksUsage\\": "src/"
}
},
"license": "MIT",
"type": "prestashop-module"
}
8 changes: 8 additions & 0 deletions demoextendsymfonyform3/config/routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @see https://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/#how-to-map-an-action-of-your-controller-to-a-uri
ps_democqrshooksusage_toggle_is_allowed_for_review:
path: demo-cqrs-hook-usage/{customerId}/toggle-is-allowed-for-review
methods: [POST]
defaults:
_controller: 'DemoCQRSHooksUsage\Controller\Admin\CustomerReviewController::toggleIsAllowedForReviewAction'
requirements:
customerId: \d+
33 changes: 33 additions & 0 deletions demoextendsymfonyform3/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
_defaults:
public: true
# @see https://devdocs.prestashop.com/1.7/development/architecture/migration-guide/forms/cqrs-usage-in-forms/ for CQRS pattern usage examples.
democqrshooksusage.domain.reviewer.command_handler.toggle_is_allowed_to_review_handler:
class: 'DemoCQRSHooksUsage\Domain\Reviewer\CommandHandler\ToggleIsAllowedToReviewHandler'
arguments:
- '@democqrshooksusage.repository.reviewer'
tags:
- name: tactician.handler
command: 'DemoCQRSHooksUsage\Domain\Reviewer\Command\ToggleIsAllowedToReviewCommand'

democqrshooksusage.domain.reviewer.query_handler.get_reviewer_settings_for_form_handler:
class: 'DemoCQRSHooksUsage\Domain\Reviewer\QueryHandler\GetReviewerSettingsForFormHandler'
arguments:
- '@democqrshooksusage.repository.reviewer'
tags:
- name: tactician.handler
command: 'DemoCQRSHooksUsage\Domain\Reviewer\Query\GetReviewerSettingsForForm'

democqrshooksusage.domain.reviewer.command_handler.update_is_allowed_to_review_handler:
class: 'DemoCQRSHooksUsage\Domain\Reviewer\CommandHandler\UpdateIsAllowedToReviewHandler'
arguments:
- '@democqrshooksusage.repository.reviewer'
tags:
- name: tactician.handler
command: 'DemoCQRSHooksUsage\Domain\Reviewer\Command\UpdateIsAllowedToReviewCommand'

democqrshooksusage.repository.reviewer:
class: 'DemoCQRSHooksUsage\Repository\ReviewerRepository'
arguments:
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
Loading