use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | 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');*/ | |||||
} | |||||
} | } |
<?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]; | |||||
} | |||||
} |
class LcSovBundle extends Bundle | class LcSovBundle extends Bundle | ||||
{ | { | ||||
public function getContainerExtension() | |||||
{ | |||||
return new LcSovExtension(); | |||||
} | |||||
public function getContainerExtension() | |||||
{ | |||||
return new LcSovExtension(); | |||||
} | |||||
} | } |
.logo-admin { | |||||
max-width: 100%; | |||||
} | |||||
nav.main-header { | nav.main-header { | ||||
ul.navbar-nav { | ul.navbar-nav { | ||||
li.nav-item-user-menu { | li.nav-item-user-menu { |
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 |
lc_sov_bundle: | lc_sov_bundle: | ||||
resource: "@LcSovBundle/Controller" | resource: "@LcSovBundle/Controller" | ||||
type: annotation | |||||
type: annotation | |||||
ch_cookie_consent: | |||||
resource: "@CHCookieConsentBundle/Resources/config/routing.yaml" |
parameters: | |||||
app.admin.logo: 'laclic.png' | |||||
app.site_name: 'laclic-sov' | |||||
app.mail_debug: '' | |||||
services: | services: | ||||
_defaults: | _defaults: | ||||
autowire: true # Automatically injects dependencies in your services. | autowire: true # Automatically injects dependencies in your services. | ||||
tags: | tags: | ||||
- { name: kernel.event_listener, event: kernel.exception } | - { 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%' |
{% for css_asset in ea.assets.cssFiles ?? [] %} | {% for css_asset in ea.assets.cssFiles ?? [] %} | ||||
<link rel="stylesheet" href="{{ asset(css_asset) }}"> | <link rel="stylesheet" href="{{ asset(css_asset) }}"> | ||||
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %} | {% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %} | ||||
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | ||||
{% endfor %} | {% endfor %} |
{ | |||||
"devDependencies": { | |||||
"@symfony/webpack-encore": "^1.3.0", | |||||
"sass": "^1.32.12", | |||||
"sass-loader": "^11.0.0", | |||||
"webpack-notifier": "^1.6.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(); |