black/sylius-banner-plugin

Show Banner/slider/carousel in your shop

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 3

Open Issues: 0

Type:sylius-plugin

This package is auto-updated.

Last update: 2022-06-09 11:06:27 UTC


README

68747470733a2f2f64656d6f2e73796c6975732e636f6d2f6173736574732f73686f702f696d672f6c6f676f2e706e67

Banner Plugin

Add banner/carousel to your shop

Warning

The following instructions are compatible with Bootstrap and Webpack Encore. This plugin is in beta.

Installation

  1. Install Sylius
  2. Import the configuration
# config/packages/sylius_banner.yaml
imports:
    - { resource: "@BlackSyliusBannerPlugin/config/app/config.php" }
  1. Import routing
# 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. Register the bundle:
<?php

// config/bundles.php

return [
    // ...
    Black\SyliusBannerPlugin\BlackSyliusBannerPlugin::class => ['all' => true],
];
  1. Add the bundle and dependencies in your composer.json

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

  1. Execute migration
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
  1. Render the template
# In the desired twig file

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

Tip: Replace the content of Homepage/_banner.html.twig with this snippet and use template events!

Quickstart Installation (docker)

  1. Run composer create-project pocky/modern-plugin-skeleton ProjectName or clone this project

  2. From the plugin skeleton root directory, run the following commands:

$ 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

Quality tools

$ 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

ProTip use Makefile ;)

Override

This plugin use the default bootstrap carousel. You don't need any configuration.

If you want to use another carousel, feel free to override.

Complete configuration

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

License and Copyright

tl;dr:

  • Modifications must be shared,
  • It's possible to use this plugin in a commercial project,
  • A commercial license is available.

This project is licensed under EUPL-1.2. This license implies that if you modify this plugin, you must share those modifications (like AGPL). However, the EUPL-1.2 license applies only on this plugin and this is not viral (like LGPL).

If you don't want to follow this or do not want to use EUPL-1.2 licensed software, you must buy commercial license. Contact us for more information.

Credits

Created by Alexandre Balmes. Some files related to slide upload are 99% from Sylius Core. We will see if it was a realy good idea to not use the default ImageInterface ;)

Sponsors

This project was made possible thanks to the support of:

Vanoix.com