定制 monsieurbiz/sylius-no-commerce-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

monsieurbiz/sylius-no-commerce-plugin

最新稳定版本:v1.15.0

Composer 安装命令:

composer require monsieurbiz/sylius-no-commerce-plugin

包简介

Disable the e-commerce on your Sylius.

README 文档

README

Banner of Sylius No Commerce plugin

No Commerce for Sylius

No Commerce Plugin license Tests Status Recipe Status Security Status

This plugin disables the e-commerce parts of Sylius.
Basically it disables the routes and updates the admin and frontend templates.

Compatibility

Sylius Version PHP Version
1.12 8.1 - 8.2 - 8.3
1.13 8.1 - 8.2 - 8.3
1.14 8.1 - 8.2 - 8.3

Installation

If you want to use our recipes, you can configure your composer.json by running:

composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
composer require monsieurbiz/sylius-no-commerce-plugin
For the installation without flex, follow these additional steps

Change your config/bundles.php file to add this line for the plugin declaration:

<?php

return [
    //..
    MonsieurBiz\SyliusNoCommercePlugin\MonsieurBizSyliusNoCommercePlugin::class => ['all' => true],
];

Then create the config file in config/packages/monsieurbiz_sylius_nocommerce_plugin.yaml:

imports:
    - { resource: "@MonsieurBizSyliusNoCommercePlugin/Resources/config/config.yaml" }

Add some annotations to your src/Entity/Channel/Channel.php entity to prevent error during Channel saving:

  /**
   * @ORM\Entity
   * @ORM\Table(name="sylius_channel")
+  * @ORM\AssociationOverrides({
+  *     @ORM\AssociationOverride(name="baseCurrency",
+  *         joinColumns=@ORM\JoinColumn(
+  *             name="base_currency_id", referencedColumnName="id", nullable=true
+  *         )
+  *     )
+  * })
   */
  #[ORM\Entity]
  #[ORM\Table(name: 'sylius_channel')]
+  #[ORM\AssociationOverrides([
+      new ORM\AssociationOverride(
+          name: 'baseCurrency',
+          joinColumns: new ORM\JoinColumn(name: 'base_currency_id', referencedColumnName: 'id', nullable: true)
+      )]
+  )]
  class Channel extends BaseChannel

Use a different trait for your src/Kernel.php:

-     use MicroKernelTrait;
+     use SyliusNoCommerceKernelTrait;

(don't forget the use MonsieurBiz\SyliusNoCommercePlugin\Kernel\SyliusNoCommerceKernelTrait; statement or course).

Copy the templates we override:

cp -Rv vendor/monsieurbiz/sylius-no-commerce-plugin/src/Resources/templates/* templates/

Create the new migrations, and run them:

./bin/console doctrine:migrations:diff
./bin/console doctrine:migrations:migrate

Re-enable features

In the config file config/packages/monsieurbiz_sylius_nocommerce_plugin.yaml, add this lines:

# ...
monsieurbiz_sylius_nocommerce:
    config:
        allow_countries: false
        allow_customers: false
        allow_zones: false

You can allow different sections by changing the parameters to true.

Ignore routes

By default, the disable firewall listener will ignore the following routes for the developer toolbar.

You can ignore additional routes, such as the preview route for error pages, by adding them to the config/packages/monsieurbiz_sylius_nocommerce_plugin.yaml file:

parameters:
    monsieurbiz_sylius_nocommerce.disable_firewall.ignored_routes:
        - "_preview_error"

Contributing

You can open an issue or a Pull Request if you want! 😘
Thank you!

统计信息

  • 总下载量: 20.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 4
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-26