black/sylius-banner-plugin

在您的商店中展示横幅/滑块/轮播图

安装: 12

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 6

公开问题: 0

类型:sylius-plugin

This package is auto-updated.

Last update: 2024-09-09 15:48:57 UTC


README

横幅插件

将横幅/轮播图添加到您的商店

警告

以下说明与Bootstrap和Webpack Encore兼容。此插件处于测试阶段。

安装

  1. 安装Sylius
  2. 导入配置
# config/packages/sylius_banner.yaml
imports:
    - { resource: "@BlackSyliusBannerPlugin/config/app/config.php" }
  1. 导入路由
# config/routes/sylius_banner.yaml
black_sylius_banner_shop:
    resource: "@BlackSyliusBannerPlugin/config/routes/shop.yaml"

black_sylius_banner_admin:
    resource: "@BlackSyliusBannerPlugin/config/routes/admin.yaml"
    prefix: '/%sylius_admin.path_name%'
  1. 注册包
<?php

// config/bundles.php

return [
    // ...
    Black\SyliusBannerPlugin\BlackSyliusBannerPlugin::class => ['all' => true],
];
  1. 在您的 composer.json 中添加包及其依赖

composer require black/sylius-banner-plugin:^1.0.0@dev

  1. 执行迁移
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
  1. 渲染模板
# In the desired twig file

{{ render(url('black_sylius_banner_shop_banner_partial', {
    'code': 'banner1',
    'template': '@BlackSyliusBannerPlugin/_banner.html.twig' // optional (default template)
})) }}

提示:用此片段替换 Homepage/_banner.html.twig 的内容,并使用模板事件!

快速安装(docker)

  1. 运行 composer create-project pocky/modern-plugin-skeleton ProjectName 或克隆此项目

  2. 从插件骨架根目录,运行以下命令

$ sudo chmod -Rf 777 tests/Application/var
$	docker-compose exec php php -d memory_limit=-1 /usr/bin/composer install
$	docker-compose exec nodejs yarn --cwd tests/Application install
$	docker-compose exec php tests/Application/bin/console doctrine:database:create --if-not-exists -vvv
$	docker-compose exec php tests/Application/bin/console doctrine:schema:create -vvv
$	docker-compose exec php tests/Application/bin/console assets:install tests/Application/public -vvv
$	docker-compose exec nodejs yarn --cwd tests/Application build
$	docker-compose exec php tests/Application/bin/console cache:warmup -vvv
$	docker-compose exec php tests/Application/bin/console sylius:fixtures:load -n

质量工具

$ docker-compose exec php composer validate --ansi --strict
$ docker-compose exec php vendor/bin/phpstan analyse -c phpstan.neon -l max src/
$ docker-compose exec php vendor/bin/psalm
$ docker-compose exec php vendor/bin/phpspec run --ansi -f progress --no-interaction
$ docker-compose exec php vendor/bin/phpunit --colors=always
$ docker-compose exec php vendor/bin/behat --profile docker --colors --strict -vvv --no-interaction

专业提示 使用 Makefile ;)

覆盖

此插件使用默认的 bootstrap 轮播图。您无需进行任何配置。

如果您想使用其他轮播图,请随意覆盖。

完整配置

parameters:
    black_banner.uploader.filesystem: "black_sylius_banner"
        
doctrine:
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                auto_mapping: true

knp_gaufrette:
    adapters:
        black_sylius_banner:
            safe_local:
                directory: "%sylius_core.public_dir%/media/banner/"
                create: true
    filesystems:
        black_sylius_banner:
            adapter: "%black_banner.uploader.filesystem%"
    stream_wrapper: ~

liip_imagine:
    loaders:
        black_sylius_banner:
            stream:
                wrapper: gaufrette://black_sylius_banner/
    filter_sets:
        black_sylius_banner:
            data_loader: black_sylius_banner
            filters:
                upscale: { min: [1200, 400] }
                thumbnail: { size: [1200, 400], mode: inbound }
                
sylius_grid:
    templates:
        filter:
            banner_channel: '@BlackSyliusBannerPlugin/Admin/Grid/Filter/channel.html.twig'
    grids:
        black_sylius_banner:
            driver:
                name: doctrine/orm
                options:
                    class: 'expr:parameter("black_sylius_banner.model.banner.class")'
            fields:
                code:
                    type: string
                    label: sylius.ui.code
                name:
                    type: string
                    label: sylius.ui.name
            filters:
                code:
                    label: sylius.ui.code
                    type: string
                name:
                    label: sylius.ui.name
                    type: string
                channel:
                    type: banner_channel
                    label: sylius.ui.channel
            actions:
                main:
                    create:
                        type: create
                item:
                    update:
                        type: update
                    delete:
                        type: delete

许可证和版权

tl;dr

  • 修改必须共享,
  • 可以在商业项目中使用此插件,
  • 提供商业许可证。

本项目受EUPL-1.2许可证保护。此许可证意味着如果您修改此插件,则必须共享这些修改(如AGPL)。但是,EUPL-1.2许可证仅适用于此插件,且不是病毒式(如LGPL)。

如果您不想遵守此条款或不希望使用EUPL-1.2许可证的软件,则必须购买商业许可证。联系我们 了解更多信息。

致谢

Alexandre Balmes创建。一些与幻灯片上传相关的文件有99%来自Sylius Core。我们将看看不使用默认的ImageInterface是否真的是一个好主意;)

赞助商

本项目得以实现,得益于以下机构的支持:

Vanoix.com