Skip to content

Commit

Permalink
[CookieBundle] Move cookie-bundle source to monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Oct 28, 2021
1 parent 4aa1805 commit 84715d7
Show file tree
Hide file tree
Showing 162 changed files with 8,297 additions and 1 deletion.
42 changes: 42 additions & 0 deletions groundcontrol/cookie-bundle.tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-env node */

import consoleArguments from './console-arguments';

import createScriptsTask from './tasks/scripts';
import createBundleTask, { getBabelLoaderOptions } from './tasks/bundle';
import path from 'path';
import { adminBundle } from './admin-bundle.tasks';
import TerserPlugin from 'terser-webpack-plugin';

export const cookieBundle = {
config: {
srcPath: './src/Kunstmaan/CookieBundle/Resources/ui/',
distPath: './src/Kunstmaan/CookieBundle/Resources/public/',
publicPath: '/bundles/kunstmaancookie'
},
tasks: {}
};

cookieBundle.tasks.bundleOptimized = createBundleTask({
config: {
mode: 'production',
entry: `${cookieBundle.config.srcPath}js/index.js`,
output: {
filename: 'cookie-bundle.min.js',
path: path.resolve(__dirname, `.${cookieBundle.config.distPath}js`)
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: getBabelLoaderOptions({
optimize: true
})
},
],
},
},
logStats: true
});
6 changes: 6 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gulp from 'gulp';
import {adminBundle} from './groundcontrol/admin-bundle.tasks';
import {dashboardBundle} from './groundcontrol/dashboard-bundle.tasks';
import {cookieBundle} from './groundcontrol/cookie-bundle.tasks';
import {mediaBundle} from './groundcontrol/media-bundle.tasks';
import {translatorBundle} from './groundcontrol/translator-bundle.tasks';
import startLocalTask, { buildOnChange, testOnChange } from './groundcontrol/start-local.task';
Expand Down Expand Up @@ -39,6 +40,10 @@ const buildLocalDashboardBundle = gulp.series(
dashboardBundle.tasks.scriptsSetup
);

const buildOptimizedCookieBundle = gulp.series(
cookieBundle.tasks.bundleOptimized
);

const buildOptimizedDashboardBundle = gulp.series(
dashboardBundle.tasks.cssOptimized,
dashboardBundle.tasks.scripts,
Expand Down Expand Up @@ -84,6 +89,7 @@ const buildLocal = gulp.series(

const buildOptimized = gulp.series(
buildOptimizedAdminBundle,
buildOptimizedCookieBundle,
buildOptimizedDashboardBundle,
buildOptimizedMediaBundle,
buildOptimizedTranslatorBundle
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"select2": "^4.0.3",
"sortablejs": "^1.8.1",
"velocity-animate": "^1.5.2",
"x-editable": "^1.5.1"
"x-editable": "^1.5.1",
"smoothscroll-polyfill": "^0.4.2"
}
}
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ parameters:
- src/Kunstmaan/*/vendor/*
- src/Kunstmaan/BehatBundle
- src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle
- src/Kunstmaan/CookieBundle/Resources/skeleton
- src/Kunstmaan/CacheBundle # Temporary excluded for full rework
# Excluded deprecated classes/files
- src/Kunstmaan/AdminBundle/Composer/ScriptHandler.php
Expand Down
2 changes: 2 additions & 0 deletions src/Kunstmaan/CookieBundle/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gitattributes export-ignore
.gitignore export-ignore
2 changes: 2 additions & 0 deletions src/Kunstmaan/CookieBundle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer.lock
vendor/*
130 changes: 130 additions & 0 deletions src/Kunstmaan/CookieBundle/AdminList/CookieAdminListConfigurator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php

namespace Kunstmaan\CookieBundle\AdminList;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface;
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
use Kunstmaan\AdminListBundle\AdminList\FieldAlias;
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\EnumerationFilterType;
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\StringFilterType;
use Kunstmaan\AdminListBundle\Entity\OverviewNavigationInterface;
use Kunstmaan\CookieBundle\Form\CookieAdminType;

/**
* Class CookieAdminListConfigurator
*/
class CookieAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator implements OverviewNavigationInterface
{
/**
* @var DomainConfigurationInterface
*/
private $domainConfiguration;

/**
* @param EntityManager $em The entity manager
* @param AclHelper $aclHelper The acl helper
* @param DomainConfigurationInterface $domainConfiguration
*/
public function __construct(EntityManager $em, AclHelper $aclHelper = null, DomainConfigurationInterface $domainConfiguration = null)
{
parent::__construct($em, $aclHelper);

$this->domainConfiguration = $domainConfiguration;

$this->setAdminType(CookieAdminType::class);
$this->setAdminTypeOptions(['domainConfiguration' => $domainConfiguration]);
}

/**
* Configure the visible columns
*/
public function buildFields()
{
$this->addField('name', 'kuma.cookie.adminlists.cookie.name', true);
$this->addField('t.name', 'kuma.cookie.adminlists.cookie.type', true, null, new FieldAlias('t', 'type'));
if ($this->domainConfiguration->isMultiDomainHost()) {
$this->addField('domain', 'kuma.cookie.adminlists.header.domain', true);
}
}

/**
* Build filters for admin list
*/
public function buildFilters()
{
$this->addFilter('name', new StringFilterType('name'), 'kuma.cookie.adminlists.cookie.name');
$this->addFilter('type', new EnumerationFilterType('id', 't'), 'kuma.cookie.adminlists.cookie.type', $this->getCookieTypes());
if ($this->domainConfiguration->isMultiDomainHost()) {
$hosts = $this->domainConfiguration->getHosts();
$domains = array_combine($hosts, $hosts);
$domains = array_merge(['' => 'kuma.cookie.adminlists.filter.all'], $domains);
$this->addFilter('domain', new EnumerationFilterType('domain'), 'kuma.cookie.adminlist.filter.domain', $domains);
}
}

public function adaptQueryBuilder(QueryBuilder $queryBuilder)
{
$queryBuilder
->addSelect('t')
->innerJoin('b.type', 't');
}

/**
* @return array
*/
private function getCookieTypes()
{
$cookieTypes = [];
foreach ($this->em->getRepository('KunstmaanCookieBundle:CookieType')->findAll() as $cookieType) {
$cookieTypes[$cookieType->getId()] = $cookieType->getName();
}

return $cookieTypes;
}

/**
* @param array|object $item The item
* @param string $columnName The column name
*
* @return string
*/
public function getValue($item, $columnName)
{
if ($columnName == 'domain' && !$item->getDomain()) {
return 'All domains';
}

return parent::getValue($item, $columnName);
}

/**
* Get bundle name
*
* @return string
*/
public function getBundleName()
{
return 'KunstmaanCookieBundle';
}

/**
* Get entity name
*
* @return string
*/
public function getEntityName()
{
return 'Cookie';
}

/**
* @return string
*/
public function getOverViewRoute()
{
return 'kunstmaancookiebundle_admin_cookie';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Kunstmaan\CookieBundle\AdminList;

use Doctrine\ORM\EntityManager;
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;
use Kunstmaan\AdminListBundle\AdminList\SortableInterface;
use Kunstmaan\CookieBundle\Form\CookieTypeAdminType;

/**
* Class CookieTypeAdminListConfigurator
*/
class CookieTypeAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator implements SortableInterface
{
/**
* @param EntityManager $em The entity manager
* @param AclHelper $aclHelper The acl helper
*/
public function __construct(EntityManager $em, AclHelper $aclHelper = null)
{
parent::__construct($em, $aclHelper);
$this->setAdminType(CookieTypeAdminType::class);
}

/**
* Configure the visible columns
*/
public function buildFields()
{
$this->addField('name', 'kuma.cookie.adminlists.cookie_type.name', true);
$this->addField('internalName', 'kuma.cookie.adminlists.cookie_type.internal_name', true);
}

/**
* Build filters for admin list
*/
public function buildFilters()
{
$this->addFilter('name', new ORM\StringFilterType('name'), 'kuma.cookie.adminlists.cookie_type.name');
$this->addFilter('internalName', new ORM\StringFilterType('internalName'), 'kuma.cookie.adminlists.cookie_type.internal_name');
}

/**
* Get bundle name
*
* @return string
*/
public function getBundleName()
{
return 'KunstmaanCookieBundle';
}

/**
* Get entity name
*
* @return string
*/
public function getEntityName()
{
return 'CookieType';
}

/**
* Get sortable field name
*
* @return string
*/
public function getSortableField()
{
return 'weight';
}
}
Loading

0 comments on commit 84715d7

Please sign in to comment.