Browse Source

cookie in sov

feature/symfony6.1
Charly 2 years ago
parent
commit
c30189c1db
12 changed files with 126 additions and 4961 deletions
  1. +1
    -0
      Controller/Dashboard/DashboardAdminController.php
  2. +21
    -16
      DependencyInjection/LcSovExtension.php
  3. +70
    -0
      Form/Common/CookieConsentTypeExtension.php
  4. +4
    -4
      LcSovBundle.php
  5. +4
    -0
      Resources/assets/app/adminlte/main/scss/_common.scss
  6. +7
    -0
      Resources/config/packages/ch_cookie_consent.yaml
  7. +4
    -1
      Resources/config/routes.yaml
  8. +14
    -4
      Resources/config/services.yaml
  9. +1
    -1
      Resources/views/adminlte/layout.html.twig
  10. +0
    -8
      package.json
  11. +0
    -74
      webpack.config.js
  12. +0
    -4853
      yarn.lock

+ 1
- 0
Controller/Dashboard/DashboardAdminController.php View File

@@ -50,6 +50,7 @@ class DashboardAdminController extends AbstractDashboardController
$assets->addWebpackEncoreEntry('adminlte-field-filemanager');
$assets->addWebpackEncoreEntry('adminlte-main');
$assets->addWebpackEncoreEntry('sov-reminder');
$assets->addWebpackEncoreEntry('app-backend');

return $assets;
}

+ 21
- 16
DependencyInjection/LcSovExtension.php View File

@@ -9,26 +9,31 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;


class LcSovExtension extends Extension implements PrependExtensionInterface
class LcSovExtension extends Extension implements PrependExtensionInterface
{


public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

foreach ($config as $parameter => $value)
$container->setParameter(sprintf('lc_sov.%s', $parameter), $value);

$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
foreach ($config as $parameter => $value) {
$container->setParameter(sprintf('lc_sov.%s', $parameter), $value);
}

public function prepend(ContainerBuilder $container)
{
/*$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/easy_admin'));
$loader->load('base.yaml');
$loader->load('entities/merchant.yaml');*/
}
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));

$loader->load('services.yaml');
}

public function prepend(ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/packages'));
$loader->load('ch_cookie_consent.yaml');

/*$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/easy_admin'));
$loader->load('base.yaml');
$loader->load('entities/merchant.yaml');*/
}
}

+ 70
- 0
Form/Common/CookieConsentTypeExtension.php View File

@@ -0,0 +1,70 @@
<?php

namespace Lc\SovBundle\Form\Common;

use ConnectHolland\CookieConsentBundle\Cookie\CookieChecker;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use ConnectHolland\CookieConsentBundle\Form\CookieConsentType as BaseCookieConsentType;

class CookieConsentTypeExtension extends AbstractTypeExtension
{
/**
* @var CookieChecker
*/
protected $cookieChecker;

/**
* @var array
*/
protected $cookieCategories;

/**
* @var bool
*/
protected $cookieConsentSimplified;

public function __construct(
CookieChecker $cookieChecker,
array $cookieCategories = [],
bool $cookieConsentSimplified = null
) {
$this->cookieChecker = $cookieChecker;
$this->cookieCategories = $cookieCategories;
$this->cookieConsentSimplified = $cookieConsentSimplified;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($this->cookieCategories as $category) {
$builder->remove($category);

$data = 'true';
if ($this->cookieChecker->isCookieConsentSavedByUser() && !$this->cookieChecker->isCategoryAllowedByUser(
$category
)) {
$data = 'false';
}

$builder->add(
$category,
ChoiceType::class,
[
'expanded' => true,
'multiple' => false,
'data' => $data,
'choices' => [
['ch_cookie_consent.yes' => 'true'],
['ch_cookie_consent.no' => 'false'],
],
]
);
}
}

public static function getExtendedTypes(): iterable
{
return [BaseCookieConsentType::class];
}
}

+ 4
- 4
LcSovBundle.php View File

@@ -8,8 +8,8 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;

class LcSovBundle extends Bundle
{
public function getContainerExtension()
{
return new LcSovExtension();
}
public function getContainerExtension()
{
return new LcSovExtension();
}
}

+ 4
- 0
Resources/assets/app/adminlte/main/scss/_common.scss View File

@@ -1,3 +1,7 @@
.logo-admin {
max-width: 100%;
}

nav.main-header {
ul.navbar-nav {
li.nav-item-user-menu {

+ 7
- 0
Resources/config/packages/ch_cookie_consent.yaml View File

@@ -0,0 +1,7 @@
ch_cookie_consent:
theme: 'light' # light, dark
categories: # Below are the default supported categories
- 'piwik'
use_logger: true # Logs user actions to database
position: 'bottom' # top, bottom
simplified: false # When set to true the user can only deny or accept all cookies at once

+ 4
- 1
Resources/config/routes.yaml View File

@@ -8,4 +8,7 @@ artgris_bundle_file_manager:

lc_sov_bundle:
resource: "@LcSovBundle/Controller"
type: annotation
type: annotation

ch_cookie_consent:
resource: "@CHCookieConsentBundle/Resources/config/routing.yaml"

+ 14
- 4
Resources/config/services.yaml View File

@@ -1,3 +1,8 @@
parameters:
app.admin.logo: 'laclic.png'
app.site_name: 'laclic-sov'
app.mail_debug: ''

services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
@@ -40,7 +45,12 @@ services:
tags:
- { name: kernel.event_listener, event: kernel.exception }

parameters:
app.admin.logo: 'laclic.png'
app.site_name: 'laclic-sov'
app.mail_debug: ''
#Form par défaut du cookie consent
app.form.extension.type.cookie_consent:
class: Lc\SovBundle\Form\Common\CookieConsentTypeExtension
tags:
- { name: form.type_extension, extended_type: ConnectHolland\CookieConsentBundle\Form\CookieConsentType }
arguments:
- '@ConnectHolland\CookieConsentBundle\Cookie\CookieChecker'
- '%ch_cookie_consent.categories%'
- '%ch_cookie_consent.simplified%'

+ 1
- 1
Resources/views/adminlte/layout.html.twig View File

@@ -26,7 +26,7 @@
{% for css_asset in ea.assets.cssFiles ?? [] %}
<link rel="stylesheet" href="{{ asset(css_asset) }}">
{% endfor %}
{{ dump(ea.assets.webpackEncoreAssets) }}
{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %}
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }}
{% endfor %}

+ 0
- 8
package.json View File

@@ -1,8 +0,0 @@
{
"devDependencies": {
"@symfony/webpack-encore": "^1.3.0",
"sass": "^1.32.12",
"sass-loader": "^11.0.0",
"webpack-notifier": "^1.6.0"
}
}

+ 0
- 74
webpack.config.js View File

@@ -1,74 +0,0 @@
const Encore = require('@symfony/webpack-encore');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
// directory where compiled assets will be stored
.setOutputPath('Resources/public/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')
// only needed for CDN's or sub-directory deploy
//.setManifestKeyPrefix('build/')
.enableSassLoader()
/*
* ENTRY CONFIG
*
* Add 1 entry for each "page" of your app
* (including one that's included on every page - e.g. "app")
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('backend-common', './Resources/assets/apps/backend/common/app.common.js')
//.addEntry('page1', './assets/page1.js')
//.addEntry('page2', './assets/page2.js')

// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()

// will require an extra script tag for runtime.js
// but, you probably want this, unless you're building a single-page app
.enableSingleRuntimeChunk()

/*
* FEATURE CONFIG
*
* Enable & configure other features below. For a full
* list of features, see:
* https://symfony.com/doc/current/frontend.html#adding-more-features
*/
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())

// enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})

// enables Sass/SCSS support
//.enableSassLoader()

// uncomment if you use TypeScript
//.enableTypeScriptLoader()

// uncomment to get integrity="..." attributes on your script & link tags
// requires WebpackEncoreBundle 1.4 or higher
//.enableIntegrityHashes(Encore.isProduction())

// uncomment if you're having problems with a jQuery plugin
//.autoProvidejQuery()

// uncomment if you use API Platform Admin (composer require api-admin)
//.enableReactPreset()
//.addEntry('admin', './assets/admin.js')
;

module.exports = Encore.getWebpackConfig();

+ 0
- 4853
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save