Skip to content

Commit

Permalink
Merge branch 'release/0.0.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu2607 committed Oct 1, 2024
2 parents 50e64ae + 8c9e38b commit 624013d
Show file tree
Hide file tree
Showing 52 changed files with 2,882 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Flash Info Bundle code review

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]

jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, zip

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --no-interaction --no-progress

- name: Check for vulnerabilities
uses: symfonycorp/security-checker-action@v4

- name: Run Easy Coding Standard
run: vendor/bin/ecs check src
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
var
composer.lock
164 changes: 164 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Sulu Flash Info Bundle

![GitHub release (with filter)](https://img.shields.io/github/v/release/Pixel-Developpement/sulu-flashinfobundle)
[![Dependency](https://img.shields.io/badge/sulu-2.5-cca000.svg)](https://sulu.io/)

## Presentation

A bundle for the Sulu CMS that allows you to manage flash information displayed with a modal.

![](src/Resources/documentation/presentation.jpg)

## Features

- program your newsflashes
- modal in vanilla js (thank you Tingle https://tingle.robinparisi.com/)
- twig functions to display news flashes

## Requirement

* PHP >= 8.0
* Sulu >= 2.5
* Symfony >= 5.4
* Composer

## Installation

### Install the bundle

Execute the following [composer](https://getcomposer.org/) command to add the bundle to the dependencies of your
project:

```bash
composer require pixelopen/sulu-flashinfobundle
```

### Enable the bundle

Enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```php
return [
/* ... */
Pixel\FlashInfoBundle\FlashInfoBundle::class => ['all' => true],
];
```

### Update schema

For the development environment:

```shell script
bin/console do:sch:up --force
```

For the production environment: use doctrine migration

## Bundle Config

Define the Admin Api Route in `routes_admin.yaml`
```yaml
flash_info.flash_infos_api:
type: rest
prefix: /admin/api
resource: pixel_flashinfo.flash-infos_route_controller
name_prefix: flashinfo.

flash_info.setting_api:
type: rest
prefix: /admin/api
resource: pixel_flashinfo.setting_route_controller
name_prefix: flashinfo.
```
## Use
### Add/Edit a news flash
To add a news flash, go to the "News flash" section and then, click on Add on the top of the page.
Once on the form, fill the following fields:
- Title (mandatory)
- Image
- Documents
- Start date (mandatory)
- End date (mandatory)
- Description (mandatory)
- Button label
- Link
![](src/Resources/documentation/form_add.png)
Click on "Save" to save your news flash. To enable it, click on the "Active?" button on the top of the page.
To edit a news flash, click on the pencil of the news flash you wish to edit. This will take you to the same form as the add one.
![](src/Resources/documentation/list.png)
### Remove/Restore
There are 2 ways to delete a news flash:
- Go the edit form and click on the "Delete" button on the top of the page
- Check the news flash you want to delete and click on "Delete" on the top if the page
In both cases, the deleted news flash will be placed in the trash.
To restore a news flash, go to Settings > Trash and select the news flash you want to restore (by clicking on the reverse clock on the left).
After the restoration, you will be redirected to the edit for.
![](src/Resources/documentation/trash.png)
To permanently delete a news flash, select it and click on the "Delete" button on the top of the page.
### Settings
The settings allow you to set up how the news flash modal should be displayed.
To access it, go to Settings > Newsflash management. You will have a select with the following options:
- Do not open: the modal is never opened automatically
- Open once: the modal is open on the first visit of the site (stored in a cookie)
- Open every time: the modal is opened each time during the user's visit
![](src/Resources/documentation/settings.png)
## Display modal
The modal will display the news flashes that are active with the current date in the period defined by the news flash.
The modal can be displayed automatically or by clicking a button.
### Add the automatic modal opening
To use the automatic opening news flash modal, add the auto_display_flash_info_modal function to the head tag.
This function don't take any parameter.
```twig
<head>
{{ auto_display_flash_info_modal() }}
</head>
```

This Twig function will automatically display the modal according to the modal display policy (set in the settings) if there are published news flashes.

### Add the modal opening on click

To use the modal opening on click, you need to use the display_flash_info_modal_on_click function.

This function must be placed in the head tag and takes one parameter:
- elementId: the id of the element that open the modal

```twig
<head>
{{ display_flash_info_modal_on_click('flashInfo') }}
</head>
<body>
<button id="flashInfo">Open the news flashes</button>
</body>
```

This will display the modal no matter what the modal display policy is.

If there is no active news flash, an empty message will be shown.

## Contributing
You can contribute to this bundle. The only thing you must do is respect the coding standard we implement.
You can find them in the `ecs.php` file.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
44 changes: 44 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "pixelopen/sulu-flashinfobundle",
"type": "sulu-bundle",
"description": "Flash info bundle for Sulu",
"keywords": [
"sulu",
"suluCms"
],
"homepage": "https://github.com/Pixel-Open/sulu-flashinfobundle",
"license": "MIT",
"authors": [
{
"name": "Pixel Developpement"
}
],
"require": {
"php": "^8.0",
"sulu/sulu": "^2.5",
"symfony/config": "^5.0 || ^6.0",
"symfony/dependency-injection": "^5.0 || ^6.0",
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/http-foundation": "^5.0 || ^6.0",
"symfony/http-kernel": "^5.0 || ^6.0"
},
"require-dev": {
"dantleech/phpcr-migrations-bundle": "^1.3",
"jackalope/jackalope-doctrine-dbal": "^1.3.2",
"phpstan/phpstan": "^1.11",
"symplify/easy-coding-standard": "^12.3"
},
"scripts": {
},
"autoload": {
"psr-4": {
"Pixel\\FlashInfoBundle\\": "src"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true
}
}
}
22 changes: 22 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([__DIR__ . '/src']);
$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
'syntax' => 'short',
]);

$ecsConfig->sets([
// run and fix, one by one
//SetList::SPACES,
SetList::ARRAY,
SetList::DOCBLOCK,
SetList::PSR_12,
]);
};
11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
level: 6

treatPhpDocTypesAsCertain: false

paths:
- src

ignoreErrors:
-
identifier: missingType.generics
Loading

0 comments on commit 624013d

Please sign in to comment.