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

Add compatibility with Prestashop 8.0.0 on demodoctrine module #109

Merged
merged 1 commit into from
Oct 14, 2022
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
2 changes: 1 addition & 1 deletion demodoctrine/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Demo Doctrine
=====================

This module demonstrates how to use Doctrine entities in PrestaShop 1.7.7 and 1.7.8 versions.
This module demonstrates how to use Doctrine entities in PrestaShop 1.7.7 and above.

Please note this module is an example only, not a mandatory structure.

Expand Down
2 changes: 1 addition & 1 deletion demodoctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"autoload": {
"psr-4": {
"PrestaShop\\Module\\DemoDoctrine\\": "src/"
"Module\\DemoDoctrine\\": "src/"
},
"config": {
"prepend-autoloader": false
Expand Down
7 changes: 4 additions & 3 deletions demodoctrine/config/common.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
services:
prestashop.module.demodoctrine.repository.quote_repository:
class: PrestaShop\Module\DemoDoctrine\Repository\QuoteRepository
class: Module\DemoDoctrine\Repository\QuoteRepository
public: true
factory: ['@doctrine.orm.default_entity_manager', getRepository]
arguments:
- PrestaShop\Module\DemoDoctrine\Entity\Quote
- Module\DemoDoctrine\Entity\Quote

prestashop.module.demodoctrine.quotes.install:
class: PrestaShop\Module\DemoDoctrine\Database\QuoteInstaller
class: Module\DemoDoctrine\Database\QuoteInstaller
arguments:
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
14 changes: 7 additions & 7 deletions demodoctrine/config/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ ps_demodoctrine_quote_index:
path: /demo-doctrine/quotes
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::indexAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::indexAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote'

ps_demodoctrine_quote_search:
path: /demo-doctrine/quotes
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::searchAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::searchAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote:search'

ps_demodoctrine_quote_generate:
path: /demo-doctrine/generate
methods: [GET, POST]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::generateAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::generateAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote:generate'

ps_demodoctrine_quote_create:
path: /demo-doctrine/quotes/new
methods: [GET, POST]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::createAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::createAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote:add'

ps_demodoctrine_quote_edit:
path: /demo-doctrine/quotes/{quoteId}/edit
methods: [GET, POST]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::editAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::editAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote:update'
requirements:
Expand All @@ -45,7 +45,7 @@ ps_demodoctrine_quote_delete:
path: /demo-doctrine/quotes/{quoteId}/delete
methods: [DELETE]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::deleteAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::deleteAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote:deletequote'
requirements:
Expand All @@ -55,6 +55,6 @@ ps_demodoctrine_quote_bulk_delete:
path: /demo-doctrine/quotes/bulkDelete
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\DemoDoctrine\Controller\Admin\QuotesController::deleteBulkAction'
_controller: 'Module\DemoDoctrine\Controller\Admin\QuotesController::deleteBulkAction'
_legacy_controller: 'AdminDemodoctrineQuote'
_legacy_link: 'AdminDemodoctrineQuote:submitBulkdeletequote'
18 changes: 11 additions & 7 deletions demodoctrine/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ imports:
services:
# Form services
prestashop.module.demodoctrine.type.quote:
class: 'PrestaShop\Module\DemoDoctrine\Form\QuoteType'
class: 'Module\DemoDoctrine\Form\QuoteType'
parent: 'form.type.translatable.aware'
public: true
arguments:
Expand All @@ -13,37 +13,39 @@ services:
- { name: form.type }

prestashop.module.demodoctrine.form.identifiable_object.data_provider.quote_form_data_provider:
class: 'PrestaShop\Module\DemoDoctrine\Form\QuoteFormDataProvider'
class: 'Module\DemoDoctrine\Form\QuoteFormDataProvider'
arguments:
- '@prestashop.module.demodoctrine.repository.quote_repository'

prestashop.module.demodoctrine.form.identifiable_object.builder.quote_form_builder:
class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder'
public: true
factory: 'prestashop.core.form.builder.form_builder_factory:create'
arguments:
- 'PrestaShop\Module\DemoDoctrine\Form\QuoteType'
- 'Module\DemoDoctrine\Form\QuoteType'
- '@prestashop.module.demodoctrine.form.identifiable_object.data_provider.quote_form_data_provider'

prestashop.module.demodoctrine.form.identifiable_object.data_handler.quote_form_data_handler:
class: 'PrestaShop\Module\DemoDoctrine\Form\QuoteFormDataHandler'
class: 'Module\DemoDoctrine\Form\QuoteFormDataHandler'
arguments:
- '@prestashop.module.demodoctrine.repository.quote_repository'
- '@prestashop.core.admin.lang.repository'
- '@doctrine.orm.default_entity_manager'

prestashop.module.demodoctrine.form.identifiable_object.handler.quote_form_handler:
class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler'
public: true
factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create'
arguments:
- '@prestashop.module.demodoctrine.form.identifiable_object.data_handler.quote_form_data_handler'

# Grid services
prestashop.module.demodoctrine.grid.definition.factory.quotes:
class: 'PrestaShop\Module\DemoDoctrine\Grid\Definition\Factory\QuoteGridDefinitionFactory'
class: 'Module\DemoDoctrine\Grid\Definition\Factory\QuoteGridDefinitionFactory'
parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition'

prestashop.module.demodoctrine.grid.query_builder.quote:
class: 'PrestaShop\Module\DemoDoctrine\Grid\Query\QuoteQueryBuilder'
class: 'Module\DemoDoctrine\Grid\Query\QuoteQueryBuilder'
parent: 'prestashop.core.grid.abstract_query_builder'
public: true
arguments:
Expand All @@ -60,6 +62,7 @@ services:

prestashop.module.demodoctrine.grid.factory.quotes:
class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory'
public: true
arguments:
- '@prestashop.module.demodoctrine.grid.definition.factory.quotes'
- '@prestashop.module.demodoctrine.grid.data_provider.quotes'
Expand All @@ -68,7 +71,8 @@ services:

# Generator service
prestashop.module.demodoctrine.quotes.generator:
class: 'PrestaShop\Module\DemoDoctrine\Database\QuoteGenerator'
class: 'Module\DemoDoctrine\Database\QuoteGenerator'
public: true
arguments:
- '@prestashop.module.demodoctrine.repository.quote_repository'
- '@prestashop.core.admin.lang.repository'
Expand Down
2 changes: 1 addition & 1 deletion demodoctrine/demodoctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

use PrestaShop\Module\DemoDoctrine\Database\QuoteInstaller;
use Module\DemoDoctrine\Database\QuoteInstaller;

if (!defined('_PS_VERSION_')) {
exit;
Expand Down
10 changes: 5 additions & 5 deletions demodoctrine/src/Controller/Admin/QuotesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Controller\Admin;
namespace Module\DemoDoctrine\Controller\Admin;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityNotFoundException;
use PrestaShop\Module\DemoDoctrine\Entity\Quote;
use PrestaShop\Module\DemoDoctrine\Entity\QuoteLang;
use PrestaShop\Module\DemoDoctrine\Grid\Definition\Factory\QuoteGridDefinitionFactory;
use PrestaShop\Module\DemoDoctrine\Grid\Filters\QuoteFilters;
use Module\DemoDoctrine\Entity\Quote;
use Module\DemoDoctrine\Entity\QuoteLang;
use Module\DemoDoctrine\Grid\Definition\Factory\QuoteGridDefinitionFactory;
use Module\DemoDoctrine\Grid\Filters\QuoteFilters;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Entity\Lang;
use PrestaShopBundle\Entity\Repository\LangRepository;
Expand Down
8 changes: 4 additions & 4 deletions demodoctrine/src/Database/QuoteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Database;
namespace Module\DemoDoctrine\Database;

use Doctrine\ORM\EntityManagerInterface;
use PrestaShop\Module\DemoDoctrine\Entity\Quote;
use PrestaShop\Module\DemoDoctrine\Entity\QuoteLang;
use PrestaShop\Module\DemoDoctrine\Repository\QuoteRepository;
use Module\DemoDoctrine\Entity\Quote;
use Module\DemoDoctrine\Entity\QuoteLang;
use Module\DemoDoctrine\Repository\QuoteRepository;
use PrestaShopBundle\Entity\Lang;
use PrestaShopBundle\Entity\Repository\LangRepository;

Expand Down
2 changes: 1 addition & 1 deletion demodoctrine/src/Database/QuoteInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Database;
namespace Module\DemoDoctrine\Database;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
Expand Down
6 changes: 3 additions & 3 deletions demodoctrine/src/Entity/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Entity;
namespace Module\DemoDoctrine\Entity;

use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="PrestaShop\Module\DemoDoctrine\Repository\QuoteRepository")
* @ORM\Entity(repositoryClass="Module\DemoDoctrine\Repository\QuoteRepository")
* @ORM\HasLifecycleCallbacks
*/
class Quote
Expand All @@ -39,7 +39,7 @@ class Quote
private $author;

/**
* @ORM\OneToMany(targetEntity="PrestaShop\Module\DemoDoctrine\Entity\QuoteLang", cascade={"persist", "remove"}, mappedBy="quote")
* @ORM\OneToMany(targetEntity="Module\DemoDoctrine\Entity\QuoteLang", cascade={"persist", "remove"}, mappedBy="quote")
*/
private $quoteLangs;

Expand Down
4 changes: 2 additions & 2 deletions demodoctrine/src/Entity/QuoteLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Entity;
namespace Module\DemoDoctrine\Entity;

use Doctrine\ORM\Mapping as ORM;
use PrestaShopBundle\Entity\Lang;
Expand All @@ -23,7 +23,7 @@ class QuoteLang
/**
* @var Quote
* @ORM\Id
* @ORM\ManyToOne(targetEntity="PrestaShop\Module\DemoDoctrine\Entity\Quote", inversedBy="quoteLangs")
* @ORM\ManyToOne(targetEntity="Module\DemoDoctrine\Entity\Quote", inversedBy="quoteLangs")
* @ORM\JoinColumn(name="id_quote", referencedColumnName="id_quote", nullable=false)
*/
private $quote;
Expand Down
8 changes: 4 additions & 4 deletions demodoctrine/src/Form/QuoteFormDataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Form;
namespace Module\DemoDoctrine\Form;

use Doctrine\ORM\EntityManagerInterface;
use PrestaShop\Module\DemoDoctrine\Entity\Quote;
use PrestaShop\Module\DemoDoctrine\Entity\QuoteLang;
use PrestaShop\Module\DemoDoctrine\Repository\QuoteRepository;
use Module\DemoDoctrine\Entity\Quote;
use Module\DemoDoctrine\Entity\QuoteLang;
use Module\DemoDoctrine\Repository\QuoteRepository;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FormDataHandlerInterface;
use PrestaShopBundle\Entity\Repository\LangRepository;

Expand Down
8 changes: 4 additions & 4 deletions demodoctrine/src/Form/QuoteFormDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Form;
namespace Module\DemoDoctrine\Form;

use PrestaShop\Module\DemoDoctrine\Entity\Quote;
use PrestaShop\Module\DemoDoctrine\Entity\QuoteLang;
use PrestaShop\Module\DemoDoctrine\Repository\QuoteRepository;
use Module\DemoDoctrine\Entity\Quote;
use Module\DemoDoctrine\Entity\QuoteLang;
use Module\DemoDoctrine\Repository\QuoteRepository;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface;

class QuoteFormDataProvider implements FormDataProviderInterface
Expand Down
2 changes: 1 addition & 1 deletion demodoctrine/src/Form/QuoteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Form;
namespace Module\DemoDoctrine\Form;

use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage;
use PrestaShopBundle\Form\Admin\Type\TranslatableType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Grid\Definition\Factory;
namespace Module\DemoDoctrine\Grid\Definition\Factory;

use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection;
use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction;
Expand Down
4 changes: 2 additions & 2 deletions demodoctrine/src/Grid/Filters/QuoteFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Grid\Filters;
namespace Module\DemoDoctrine\Grid\Filters;

use PrestaShop\Module\DemoDoctrine\Grid\Definition\Factory\QuoteGridDefinitionFactory;
use Module\DemoDoctrine\Grid\Definition\Factory\QuoteGridDefinitionFactory;
use PrestaShop\PrestaShop\Core\Search\Filters;

class QuoteFilters extends Filters
Expand Down
2 changes: 1 addition & 1 deletion demodoctrine/src/Grid/Query/QuoteQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Grid\Query;
namespace Module\DemoDoctrine\Grid\Query;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Query\QueryBuilder;
Expand Down
2 changes: 1 addition & 1 deletion demodoctrine/src/Repository/QuoteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
declare(strict_types=1);

namespace PrestaShop\Module\DemoDoctrine\Repository;
namespace Module\DemoDoctrine\Repository;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
Expand Down
4 changes: 3 additions & 1 deletion demodoctrine/views/templates/admin/create.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* It is also available through the world-wide-web at this URL: https://opensource.org/licenses/AFL-3.0
*#}

{% extends 'PrestaShopBundle:Admin:layout.html.twig' %}
{% extends '@!PrestaShop/Admin/layout.html.twig' %}
{# Since PS 8.0.0 you can use @PrestaShopCore instead of @!Prestashop
(https://devdocs.prestashop-project.org/8/modules/concepts/templating/admin-views/#override-templates) #}

{% block content %}
<div class="row justify-content-center">
Expand Down
4 changes: 3 additions & 1 deletion demodoctrine/views/templates/admin/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* It is also available through the world-wide-web at this URL: https://opensource.org/licenses/AFL-3.0
*#}

{% extends 'PrestaShopBundle:Admin:layout.html.twig' %}
{% extends '@!PrestaShop/Admin/layout.html.twig' %}
{# Since PS 8.0.0 you can use @PrestaShopCore instead of @!Prestashop
(https://devdocs.prestashop-project.org/8/modules/concepts/templating/admin-views/#override-templates) #}

{% block content %}
<div class="row justify-content-center">
Expand Down
4 changes: 2 additions & 2 deletions demodoctrine/views/templates/admin/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<i class="material-icons">mail_outline</i>
{{ 'Quotes'|trans({}, 'Modules.Demodoctrine.Admin') }}
</h3>
<div class="card-block row">
<div class="card-text">
<div class="card-body card-block">
<div class="form-wrapper card-text">
{{ form_errors(quoteForm) }}

{% block quote_form_rest %}
Expand Down
4 changes: 3 additions & 1 deletion demodoctrine/views/templates/admin/generate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* It is also available through the world-wide-web at this URL: https://opensource.org/licenses/AFL-3.0
*#}

{% extends '@PrestaShop/Admin/layout.html.twig' %}
{% extends '@!PrestaShop/Admin/layout.html.twig' %}
{# Since PS 8.0.0 you can use @PrestaShopCore instead of @!Prestashop
(https://devdocs.prestashop-project.org/8/modules/concepts/templating/admin-views/#override-templates) #}

{% block content %}
<div class="row justify-content-center">
Expand Down
Loading