upgraded FosUserBundle and Symfony 4.3 (#1005)

This commit is contained in:
Kevin Papst
2019-08-02 16:52:30 +02:00
committed by GitHub
parent 614a50ce0b
commit e11a2a6089
57 changed files with 1577 additions and 1184 deletions

View File

@@ -12,7 +12,8 @@ Perform EACH version specific task between your version and the new one, otherwi
### BC breaks
Deleted timezone conversion command. If you are still using 0.7 or below, you need to upgrade to 1.1 before upgrading to this version.
- Deleted timezone conversion command. If you are still using 0.7 or below, you need to upgrade to 1.1 before upgrading to this version.
- Minimum password length raised from 5 to 8 character (applies only for password changes and new users)
## [1.1](https://github.com/kevinpapst/kimai2/releases/tag/1.1)

View File

@@ -19,7 +19,7 @@ if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
(new Dotenv(true))->load(__DIR__.'/../.env');
}
$input = new ArgvInput();

View File

@@ -19,8 +19,8 @@
"ext-zip": "*",
"beberlei/doctrineextensions": "^1.2",
"erusev/parsedown": "^1.6",
"friendsofsymfony/rest-bundle": "^2.3",
"friendsofsymfony/user-bundle": "~2.0",
"friendsofsymfony/rest-bundle": "^2.5",
"friendsofsymfony/user-bundle": "dev-master",
"gedmo/doctrine-extensions": "^2.4",
"jms/metadata": "^2.0",
"jms/serializer-bundle": "^3.2",
@@ -43,12 +43,12 @@
"symfony/form": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/intl": "^4.0",
"symfony/monolog-bundle": "^3.1",
"symfony/monolog-bundle": "^3.4",
"symfony/orm-pack": "^1.0",
"symfony/security-bundle": "~4.2.0",
"symfony/security-bundle": "^4.0",
"symfony/security-csrf": "^4.0",
"symfony/serializer": "^4.0",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/swiftmailer-bundle": "^3.2",
"symfony/translation": "^4.0",
"symfony/twig-bundle": "^4.0",
"symfony/validator": "^4.0",
@@ -138,7 +138,7 @@
"symfony": {
"id": "01C3FWRDJJEX9K6Y3A4XDFXPBR",
"allow-contrib": true,
"require": "~4.2.0"
"require": "4.3.*"
}
}
}

1228
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
security:
encoders:
App\Entity\User: bcrypt
App\Entity\User: auto
providers:
chain_provider:

View File

@@ -4,7 +4,7 @@ security:
encoders:
# to make tests much faster, BCrypt cost is changed to its minimum allowed value (4)
# See https://symfony.com/doc/current/reference/configuration/security.html#using-the-bcrypt-password-encoder
App\Entity\User: { algorithm: bcrypt, cost: 4 }
App\Entity\User: { algorithm: auto }
firewalls:
secured_area:

View File

@@ -9,5 +9,5 @@ App\Entity\User:
- NotBlank: ~
- Email: ~
plainPassword:
- NotBlank: { groups: [registration, passwordUpdate] }
- Length: { min: 5, max: 60, groups: [registration, passwordUpdate] }
- NotBlank: { groups: [Registration, PasswordUpdate] }
- Length: { min: 8, max: 60, groups: [Registration, PasswordUpdate] }

View File

@@ -16,6 +16,7 @@ parameters:
- '#Access to an undefined property Faker\\Generator::\$stateAbbr.#'
- '#Access to an undefined property Faker\\Generator::\$catchPhrase.#'
- '#Access to an undefined property Faker\\Generator::\$bs.#'
- '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#'
excludes_analyse:
- %rootDir%/../../../src/Command/KimaiImporterCommand.php
- %rootDir%/../../../src/Ldap/LdapDriver.php

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,29 +2,29 @@
"entrypoints": {
"app": {
"js": [
"build/runtime.784b5d0d.js",
"build/0.66b5fd0b.js",
"build/1.93f0cf2b.js",
"build/app.3f742878.js"
"build/runtime.4ee6be68.js",
"build/0.a87622f3.js",
"build/1.c1bee41f.js",
"build/app.9530b7ca.js"
],
"css": [
"build/app.7f4a18a1.css"
"build/app.e8d9cb98.css"
]
},
"chart": {
"js": [
"build/runtime.784b5d0d.js",
"build/0.66b5fd0b.js",
"build/2.c06cd055.js",
"build/chart.2bb71e2e.js"
"build/runtime.4ee6be68.js",
"build/0.a87622f3.js",
"build/2.7be60d8d.js",
"build/chart.0af3f813.js"
]
},
"calendar": {
"js": [
"build/runtime.784b5d0d.js",
"build/0.66b5fd0b.js",
"build/1.93f0cf2b.js",
"build/calendar.59417f4c.js"
"build/runtime.4ee6be68.js",
"build/0.a87622f3.js",
"build/1.c1bee41f.js",
"build/calendar.e654bdd4.js"
],
"css": [
"build/calendar.b0551848.css"
@@ -32,14 +32,14 @@
}
},
"integrity": {
"build/runtime.784b5d0d.js": "sha384-+AsC7zoefPga1AkczlNSCXcbGwD0TwokkldvNISHf1nMlOpafanLjtKvlZy9cVsm",
"build/0.66b5fd0b.js": "sha384-ncT/BKhCsqH6jhxwdsSG95m1ei7ZZjeZtzH1262h+OPUU80TSFFE3dt+abcHHMok",
"build/1.93f0cf2b.js": "sha384-pmnwzvj+UJhDD3uDf+ekLARMBRtMDxWGbnJDrJvwIoRZd3MW/tOGzAW5Ybhbvw20",
"build/app.3f742878.js": "sha384-7221dBEmG8aOmSRCEjuKlrVH47VH1bdnmdEC2pb9y1d9Jtbg6d2t2HfyV3Wa34TI",
"build/app.7f4a18a1.css": "sha384-p8Dw7CP1RxxJ2K5yuaNpCw8r1lKd64DlVA2IQeEGxBAC2QxOjweafd8w9CSMk0GC",
"build/2.c06cd055.js": "sha384-txR0QG+838LKYtPQ99Gx4OU7WmgN9J3joZEyGwIskSz74EN1T4/IBVnmNaKiFN1q",
"build/chart.2bb71e2e.js": "sha384-I57c9DtU3AOG2kzKqIZkIu0hi1aGYHRZ5QG4LKC9+9slzJnAMttPGXoL2cQG3m6y",
"build/calendar.59417f4c.js": "sha384-16sOZQy1UmOaoLAVFPfHnF8nFqUxhc4URAg+ypJnnab8uqZAGHDfFFrnq0/6PXl1",
"build/runtime.4ee6be68.js": "sha384-xNNrNinl64G3nCUrIskgSjU0mUXXCB9lj6XCSInBTwxSKXk8uTMafnLHtdWdIGtd",
"build/0.a87622f3.js": "sha384-ncT/BKhCsqH6jhxwdsSG95m1ei7ZZjeZtzH1262h+OPUU80TSFFE3dt+abcHHMok",
"build/1.c1bee41f.js": "sha384-7UVWcP6Hefp2k/CrtGSITKXx4dSZqtvpAiU8WX7dClETkzMewrUjoCRtVXQ5j3KI",
"build/app.9530b7ca.js": "sha384-5ZvNe6G4j5pbJ6moYaX9Osalr1mGLdFJrLn9g7PDY2ODVzXIfHG2B+c+OWpGy4Rg",
"build/app.e8d9cb98.css": "sha384-UuTUHbhvRNk3t+1gL0JNACbAl5xXH8OhD9ah7jaXDbd32z8dNCjK+5oJSQF77rmz",
"build/2.7be60d8d.js": "sha384-txR0QG+838LKYtPQ99Gx4OU7WmgN9J3joZEyGwIskSz74EN1T4/IBVnmNaKiFN1q",
"build/chart.0af3f813.js": "sha384-I57c9DtU3AOG2kzKqIZkIu0hi1aGYHRZ5QG4LKC9+9slzJnAMttPGXoL2cQG3m6y",
"build/calendar.e654bdd4.js": "sha384-TYdXaKv0q95Z4i/TFUaFHzMOZ0N6T4iuV92ejc0BX7Rpbd0p55ZhbgriPSn5pVcK",
"build/calendar.b0551848.css": "sha384-ta519W5+NY1a8FBh7rD4zORYTfUXCYTLci0Z25nf4BfodmuXqyPVNEe7dSe2/fRd"
}
}

View File

@@ -1,13 +1,13 @@
{
"build/0.66b5fd0b.js": "build/0.66b5fd0b.js",
"build/1.93f0cf2b.js": "build/1.93f0cf2b.js",
"build/2.c06cd055.js": "build/2.c06cd055.js",
"build/app.css": "build/app.7f4a18a1.css",
"build/app.js": "build/app.3f742878.js",
"build/0.a87622f3.js": "build/0.a87622f3.js",
"build/1.c1bee41f.js": "build/1.c1bee41f.js",
"build/2.7be60d8d.js": "build/2.7be60d8d.js",
"build/app.css": "build/app.e8d9cb98.css",
"build/app.js": "build/app.9530b7ca.js",
"build/calendar.css": "build/calendar.b0551848.css",
"build/calendar.js": "build/calendar.59417f4c.js",
"build/chart.js": "build/chart.2bb71e2e.js",
"build/runtime.js": "build/runtime.784b5d0d.js",
"build/calendar.js": "build/calendar.e654bdd4.js",
"build/chart.js": "build/chart.0af3f813.js",
"build/runtime.js": "build/runtime.4ee6be68.js",
"build/fonts/fa-brands-400.eot": "build/fonts/fa-brands-400.8e49b728.eot",
"build/fonts/fa-brands-400.woff": "build/fonts/fa-brands-400.9f018d10.woff",
"build/fonts/fa-brands-400.woff2": "build/fonts/fa-brands-400.9f4ce3dc.woff2",

View File

@@ -0,0 +1 @@
!function(e){function r(r){for(var n,l,i=r[0],f=r[1],a=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var f=t[i];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={runtime:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="build/";var i=window.webpackJsonp=window.webpackJsonp||[],f=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var p=f;t()}([]);

View File

@@ -1 +0,0 @@
!function(e){function r(r){for(var n,i,l=r[0],f=r[1],a=r[2],c=0,s=[];c<l.length;c++)i=l[c],o[i]&&s.push(o[i][0]),o[i]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var f=t[l];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=i(i.s=t[0]))}return e}var n={},o={runtime:0},u=[];function i(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=e,i.c=n,i.d=function(e,r,t){i.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,r){if(1&r&&(e=i(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)i.d(t,n,function(r){return e[r]}.bind(null,n));return t},i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,"a",r),r},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.p="build/";var l=window.webpackJsonp=window.webpackJsonp||[],f=l.push.bind(l);l.push=r,l=l.slice();for(var a=0;a<l.length;a++)r(l[a]);var p=f;t()}([]);

View File

@@ -12,7 +12,7 @@ if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
(new Dotenv(true))->load(__DIR__.'/../.env');
}
$env = $_SERVER['APP_ENV'] ?? 'dev';

View File

@@ -114,17 +114,14 @@ class CreateReleaseCommand extends Command
$tar .= '.tar.gz';
$zip .= '.zip';
// this removes the current env settings, as they might differ from the release ones
// if we don't unset them, the .env file won't be read when executing bin/console commands
putenv('DATABASE_URL');
putenv('APP_ENV');
$prefix = 'APP_ENV=prod DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite';
$commands = [
'Clone repository' => $gitCmd . ' ' . $tmpDir,
'Install composer dependencies' => 'cd ' . $tmpDir . ' && composer install --no-dev --optimize-autoloader',
'Create database' => 'cd ' . $tmpDir . ' && bin/console doctrine:database:create -n',
'Create tables' => 'cd ' . $tmpDir . ' && bin/console doctrine:schema:create -n',
'Add all migrations' => 'cd ' . $tmpDir . ' && bin/console doctrine:migrations:version --add --all -n',
'Create database' => 'cd ' . $tmpDir . ' && ' . $prefix . ' bin/console doctrine:database:create -n',
'Create tables' => 'cd ' . $tmpDir . ' && ' . $prefix . ' bin/console doctrine:schema:create -n',
'Add all migrations' => 'cd ' . $tmpDir . ' && ' . $prefix . ' bin/console doctrine:migrations:version --add --all -n',
];
$filesToDelete = [

View File

@@ -106,9 +106,6 @@ class CreateUserCommand extends Command
->setRoles(explode(',', $role))
;
$pwd = $this->encoder->encodePassword($user, $user->getPlainPassword());
$user->setPassword($pwd);
$errors = $this->validator->validate($user, null, ['Registration']);
if ($errors->count() > 0) {
/** @var \Symfony\Component\Validator\ConstraintViolation $error */
@@ -126,6 +123,9 @@ class CreateUserCommand extends Command
}
try {
$pwd = $this->encoder->encodePassword($user, $user->getPlainPassword());
$user->setPassword($pwd);
$entityManager = $this->doctrine->getManager();
$entityManager->persist($user);
$entityManager->flush();

View File

@@ -197,7 +197,7 @@ class ActivityController extends AbstractController
protected function renderActivityForm(Activity $activity, Request $request)
{
$event = new ActivityMetaDefinitionEvent($activity);
$this->dispatcher->dispatch(ActivityMetaDefinitionEvent::class, $event);
$this->dispatcher->dispatch($event, ActivityMetaDefinitionEvent::class);
$editForm = $this->createEditForm($activity);
$editForm->handleRequest($request);

View File

@@ -206,7 +206,7 @@ class CustomerController extends AbstractController
protected function renderCustomerForm(Customer $customer, Request $request)
{
$event = new CustomerMetaDefinitionEvent($customer);
$this->dispatcher->dispatch(CustomerMetaDefinitionEvent::class, $event);
$this->dispatcher->dispatch($event, CustomerMetaDefinitionEvent::class);
$editForm = $this->createEditForm($customer);

View File

@@ -88,10 +88,7 @@ class DashboardController extends AbstractController
$event->addSection($row);
}
$this->eventDispatcher->dispatch(
DashboardEvent::DASHBOARD,
$event
);
$this->eventDispatcher->dispatch($event, DashboardEvent::DASHBOARD);
$sections = $event->getSections();

View File

@@ -183,7 +183,7 @@ class ProfileController extends AbstractController
{
// we need to prepare the user preferences, which is done via an EventSubscriber
$event = new PrepareUserEvent($profile);
$this->dispatcher->dispatch(PrepareUserEvent::PREPARE, $event);
$this->dispatcher->dispatch($event, PrepareUserEvent::PREPARE);
$original = [];
foreach ($profile->getPreferences() as $preference) {
@@ -288,7 +288,7 @@ class ProfileController extends AbstractController
{
// we need to prepare the user preferences, which is done via an EventSubscriber
$event = new PrepareUserEvent($user);
$this->dispatcher->dispatch(PrepareUserEvent::PREPARE, $event);
$this->dispatcher->dispatch($event, PrepareUserEvent::PREPARE);
return $this->createForm(
UserPreferencesForm::class,
@@ -343,7 +343,7 @@ class ProfileController extends AbstractController
UserPasswordType::class,
$user,
[
'validation_groups' => ['passwordUpdate'],
'validation_groups' => ['PasswordUpdate'],
'action' => $this->generateUrl('user_profile_password', ['username' => $user->getUsername()]),
'method' => 'POST'
]

View File

@@ -195,7 +195,7 @@ class ProjectController extends AbstractController
protected function renderProjectForm(Project $project, Request $request)
{
$event = new ProjectMetaDefinitionEvent($project);
$this->dispatcher->dispatch(ProjectMetaDefinitionEvent::class, $event);
$this->dispatcher->dispatch($event, ProjectMetaDefinitionEvent::class);
$editForm = $this->createEditForm($project);
$editForm->handleRequest($request);

View File

@@ -169,7 +169,7 @@ class SystemConfigurationController extends AbstractController
$types = $this->getConfigurationTypes();
$event = new SystemConfigurationEvent($types);
$this->eventDispatcher->dispatch(SystemConfigurationEvent::CONFIGURE, $event);
$this->eventDispatcher->dispatch($event, SystemConfigurationEvent::CONFIGURE);
foreach ($event->getConfigurations() as $configs) {
foreach ($configs->getConfiguration() as $config) {

View File

@@ -138,7 +138,7 @@ abstract class TimesheetAbstractController extends AbstractController
protected function edit(Timesheet $entry, Request $request, string $renderTemplate)
{
$event = new TimesheetMetaDefinitionEvent($entry);
$this->dispatcher->dispatch(TimesheetMetaDefinitionEvent::class, $event);
$this->dispatcher->dispatch($event, TimesheetMetaDefinitionEvent::class);
$editForm = $this->getEditForm($entry, $request->get('page'));
$editForm->handleRequest($request);
@@ -196,7 +196,7 @@ abstract class TimesheetAbstractController extends AbstractController
}
$event = new TimesheetMetaDefinitionEvent($entry);
$this->dispatcher->dispatch(TimesheetMetaDefinitionEvent::class, $event);
$this->dispatcher->dispatch($event, TimesheetMetaDefinitionEvent::class);
$mode = $this->getTrackingMode();
$mode->create($entry, $request);

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Entity\Activity;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event can be used, to dynamically add meta fields to activities

View File

@@ -1,57 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Event;
use KevinPapst\AdminLTEBundle\Model\MenuItemModel;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Request;
/**
* The ConfigureAdminMenuEvent is used for populating the administration navigation.
*/
final class ConfigureAdminMenuEvent extends Event
{
public const CONFIGURE = 'app.admin_menu_configure';
/**
* @var Request
*/
private $request;
/**
* @var MenuItemModel
*/
private $menu;
/**
* @param Request $request
* @param MenuItemModel $menu
*/
public function __construct(Request $request, MenuItemModel $menu)
{
$this->request = $request;
$this->menu = $menu;
}
/**
* @return Request
*/
public function getRequest()
{
return $this->request;
}
/**
* @return MenuItemModel
*/
public function getAdminMenu()
{
return $this->menu;
}
}

View File

@@ -11,8 +11,8 @@ namespace App\Event;
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
use KevinPapst\AdminLTEBundle\Model\MenuItemModel;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\EventDispatcher\Event;
/**
* The ConfigureMainMenuEvent is used for populating the main navigation.

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Entity\Customer;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event can be used, to dynamically add meta fields to customers

View File

@@ -11,7 +11,7 @@ namespace App\Event;
use App\Entity\User;
use App\Widget\WidgetContainerInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
final class DashboardEvent extends Event
{

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Entity\User;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event should be used, if a user profile is loaded and want to fill the dynamic user preferences

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Entity\Project;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event can be used, to dynamically add meta fields to projects

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Form\Model\SystemConfiguration;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event should be used, if system configurations should be changed/added dynamically.

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Entity\User;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
final class ThemeEvent extends Event
{

View File

@@ -10,7 +10,7 @@
namespace App\Event;
use App\Entity\Timesheet;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event can be used, to dynamically add meta fields to timesheets

View File

@@ -11,7 +11,7 @@ namespace App\Event;
use App\Entity\User;
use App\Entity\UserPreference;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
/**
* This event should be used, if further user preferences should added dynamically

View File

@@ -9,7 +9,6 @@
namespace App\EventSubscriber;
use App\Event\ConfigureAdminMenuEvent;
use App\Event\ConfigureMainMenuEvent;
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
use KevinPapst\AdminLTEBundle\Event\ThemeEvents;
@@ -73,16 +72,7 @@ class MenuBuilderSubscriber implements EventSubscriberInterface
new MenuItemModel('system', 'menu.system', '')
);
$this->eventDispatcher->dispatch(ConfigureMainMenuEvent::CONFIGURE, $menuEvent);
// @deprecated since 0.9, will be removed with 1.0
$this->eventDispatcher->dispatch(
ConfigureAdminMenuEvent::CONFIGURE,
new ConfigureAdminMenuEvent(
$request,
$menuEvent->getAdminMenu()
)
);
$this->eventDispatcher->dispatch($menuEvent, ConfigureMainMenuEvent::CONFIGURE);
if ($menuEvent->getAdminMenu()->hasChildren()) {
$event->addItem(new MenuItemModel('admin', 'menu.admin', ''));

View File

@@ -11,7 +11,7 @@ namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -72,9 +72,6 @@ class RedirectToLocaleSubscriber implements EventSubscriberInterface
$this->locales = array_unique($this->locales);
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
@@ -82,10 +79,7 @@ class RedirectToLocaleSubscriber implements EventSubscriberInterface
];
}
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
public function onKernelRequest(RequestEvent $event)
{
$request = $event->getRequest();

View File

@@ -11,7 +11,7 @@ namespace App\EventSubscriber;
use App\Entity\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@@ -34,7 +34,7 @@ class TimezoneSubscriber implements EventSubscriberInterface
];
}
public function setTimezone(GetResponseEvent $event)
public function setTimezone(RequestEvent $event)
{
if (!$this->canHandleEvent()) {
return;

View File

@@ -155,7 +155,7 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
}
$event = new UserPreferenceEvent($user, $this->getDefaultPreferences($user));
$this->eventDispatcher->dispatch(UserPreferenceEvent::CONFIGURE, $event);
$this->eventDispatcher->dispatch($event, UserPreferenceEvent::CONFIGURE);
foreach ($event->getPreferences() as $preference) {
/* @var UserPreference[] $prefs */

View File

@@ -62,7 +62,7 @@ class UserProfileSubscriber implements EventSubscriberInterface
$user = $this->storage->getToken()->getUser();
$event = new PrepareUserEvent($user);
$this->eventDispatcher->dispatch(PrepareUserEvent::PREPARE, $event);
$this->eventDispatcher->dispatch($event, PrepareUserEvent::PREPARE);
}
/**

View File

@@ -11,7 +11,7 @@ namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locales;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
@@ -43,7 +43,7 @@ class LanguageType extends AbstractType
{
$choices = [];
foreach ($this->locales as $key) {
$name = ucfirst(Intl::getLocaleBundle()->getLocaleName($key, $key));
$name = ucfirst(Locales::getName($key, $key));
$choices[$name] = $key;
}

View File

@@ -75,7 +75,7 @@ class EventExtensions extends AbstractExtension
$themeEvent = new ThemeEvent($this->user, $payload);
if ($this->hasListener($eventName)) {
$this->getDispatcher()->dispatch($eventName, $themeEvent);
$this->getDispatcher()->dispatch($themeEvent, $eventName);
}
return $themeEvent;

View File

@@ -14,7 +14,9 @@ use App\Entity\Timesheet;
use App\Utils\Duration;
use App\Utils\LocaleSettings;
use NumberFormatter;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Countries;
use Symfony\Component\Intl\Currencies;
use Symfony\Component\Intl\Locales;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
@@ -136,7 +138,7 @@ class Extensions extends AbstractExtension
*/
public function currency($currency)
{
return Intl::getCurrencyBundle()->getCurrencySymbol($currency);
return Currencies::getSymbol($currency);
}
/**
@@ -145,7 +147,7 @@ class Extensions extends AbstractExtension
*/
public function country($country)
{
return Intl::getRegionBundle()->getCountryName($country);
return Countries::getName($country);
}
/**
@@ -190,7 +192,7 @@ class Extensions extends AbstractExtension
{
$locales = [];
foreach ($this->localeSettings->getAvailableLanguages() as $locale) {
$locales[] = ['code' => $locale, 'name' => Intl::getLocaleBundle()->getLocaleName($locale, $locale)];
$locales[] = ['code' => $locale, 'name' => Locales::getName($locale, $locale)];
}
return $locales;

View File

@@ -528,6 +528,9 @@
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/mime": {
"version": "v4.3.3"
},
"symfony/monolog-bridge": {
"version": "v4.0.3"
},
@@ -570,6 +573,9 @@
"symfony/polyfill-php72": {
"version": "v1.6.0"
},
"symfony/polyfill-php73": {
"version": "v1.11.0"
},
"symfony/process": {
"version": "v4.0.3"
},
@@ -591,9 +597,6 @@
"ref": "cda8b550123383d25827705d05a42acf6819fe4e"
}
},
"symfony/security": {
"version": "v4.2.8"
},
"symfony/security-bundle": {
"version": "3.3",
"recipe": {
@@ -603,9 +606,18 @@
"ref": "85834af1496735f28d831489d12ab1921a875e0d"
}
},
"symfony/security-core": {
"version": "v4.3.3"
},
"symfony/security-csrf": {
"version": "v4.0.4"
},
"symfony/security-guard": {
"version": "v4.3.3"
},
"symfony/security-http": {
"version": "v4.3.3"
},
"symfony/serializer": {
"version": "v4.1.2"
},

View File

@@ -41,10 +41,19 @@ class CreateUserCommandTest extends KernelTestCase
));
}
public function testCreateUser()
public function testCreateUserFailsForShortPassword()
{
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
$output = $commandTester->getDisplay();
$this->assertContains('[ERROR] plainPassword (foobar)', $output);
$this->assertContains('The password is too short.', $output);
}
public function testCreateUser()
{
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar12');
$output = $commandTester->getDisplay();
$this->assertContains('[OK] Success! Created user: MyTestUser', $output);
@@ -69,7 +78,7 @@ class CreateUserCommandTest extends KernelTestCase
return $commandTester;
}
public function testUserWithValidationProblem()
public function testUserWithEmptyFieldsTriggersValidationProblem()
{
$commandTester = $this->createUser('xx', '', 'ROLE_USER', '');
$output = $commandTester->getDisplay();
@@ -81,7 +90,7 @@ class CreateUserCommandTest extends KernelTestCase
public function testUserAlreadyExisting()
{
$this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
$this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar12');
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
$output = $commandTester->getDisplay();
@@ -91,7 +100,7 @@ class CreateUserCommandTest extends KernelTestCase
public function testUserEmail()
{
$commandTester = $this->createUser('MyTestUser', 'ROLE_USER', 'ROLE_USER', 'foobar');
$commandTester = $this->createUser('MyTestUser', 'ROLE_USER', 'ROLE_USER', 'foobar12');
$output = $commandTester->getDisplay();
$this->assertContains('[ERROR] email (ROLE_USER)', $output);

View File

@@ -220,8 +220,8 @@ class ProfileControllerTest extends ControllerBaseTest
$client->submit($form, [
'user_password' => [
'plainPassword' => [
'first' => 'test123',
'second' => 'test123',
'first' => 'test1234',
'second' => 'test1234',
]
]
]);
@@ -236,7 +236,7 @@ class ProfileControllerTest extends ControllerBaseTest
$user = $this->getUserByRole($em, User::ROLE_USER);
$this->assertFalse($passwordEncoder->getEncoder($user)->isPasswordValid($user->getPassword(), UserFixtures::DEFAULT_PASSWORD, $user->getSalt()));
$this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getPassword(), 'test123', $user->getSalt()));
$this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getPassword(), 'test1234', $user->getSalt()));
}
public function testApiTokenAction()

View File

@@ -85,8 +85,8 @@ class SecurityControllerTest extends ControllerBaseTest
'email' => 'test@example.com',
'username' => 'example',
'plainPassword' => [
'first' => 'test123',
'second' => 'test123',
'first' => 'test1234',
'second' => 'test1234',
],
]
]);

View File

@@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Event;
use App\Event\ConfigureAdminMenuEvent;
use KevinPapst\AdminLTEBundle\Model\MenuItemModel;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* @covers \App\Event\ConfigureAdminMenuEvent
*/
class ConfigureAdminMenuEventTest extends TestCase
{
public function testGetterAndSetter()
{
$request = new Request();
$request->setLocale('de');
$admin = new MenuItemModel('admin', 'foo', 'bar');
$sut = new ConfigureAdminMenuEvent($request, $admin);
$this->assertEquals($request, $sut->getRequest());
$this->assertEquals($admin, $sut->getAdminMenu());
}
}

View File

@@ -10,3 +10,4 @@ parameters:
- '#Access to an undefined property Faker\\Generator::\$bs.#'
excludes_analyse:
- %rootDir%/../../../tests/Ldap/LdapDriverTest.php
inferPrivatePropertyTypeFromConstructor: true

1195
yarn.lock

File diff suppressed because it is too large Load Diff