From d5e689e3073c2cd9393baa190844db6930ba62ab Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Sat, 13 Jan 2018 00:20:41 +0100 Subject: [PATCH] code cleanup --- config/services.yaml | 4 +- src/DataFixtures/AppFixtures.php | 1 - src/Form/Type/DateTimePickerType.php | 66 --------------------------- src/Form/Type/LanguageType.php | 3 +- src/Form/Type/UserType.php | 2 +- src/Repository/CustomerRepository.php | 2 - translations/messages.de.xliff | 6 ++- translations/messages.en.xliff | 4 ++ 8 files changed, 14 insertions(+), 74 deletions(-) delete mode 100644 src/Form/Type/DateTimePickerType.php diff --git a/config/services.yaml b/config/services.yaml index 94cec1a1..be004bf9 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -95,8 +95,8 @@ services: # FORMS # ================================================================================ - # form to edit user roles - app.admin.user_role: + # form type to edit user roles + App\Form\Type\UserRoleType: class: App\Form\Type\UserRoleType arguments: ["%security.role_hierarchy.roles%"] tags: diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index 691a90c4..d1690dde 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -59,7 +59,6 @@ class AppFixtures extends Fixture ->setPassword($passwordEncoder->encodePassword($claraCustomer, self::DEFAULT_PASSWORD)) ; $manager->persist($claraCustomer); - var_dump($passwordEncoder->encodePassword($claraCustomer, self::DEFAULT_PASSWORD)); $johnUser = new User(); $johnUser diff --git a/src/Form/Type/DateTimePickerType.php b/src/Form/Type/DateTimePickerType.php deleted file mode 100644 index 809ee076..00000000 --- a/src/Form/Type/DateTimePickerType.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace App\Form\Type; - -use App\Utils\MomentFormatConverter; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\DateTimeType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Defines the custom form field type used to manipulate datetime values across - * Bootstrap Date\Time Picker javascript plugin. - * See http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html - * - * @author Yonel Ceruto - */ -class DateTimePickerType extends AbstractType -{ - /** - * @var MomentFormatConverter - */ - private $formatConverter; - - public function __construct() - { - $this->formatConverter = new MomentFormatConverter(); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['attr']['data-date-format'] = $this->formatConverter->convert($options['format']); - $view->vars['attr']['data-date-locale'] = \Locale::getDefault(); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'widget' => 'single_text', - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return DateTimeType::class; - } -} diff --git a/src/Form/Type/LanguageType.php b/src/Form/Type/LanguageType.php index 4b3d3429..c8ea3d6e 100644 --- a/src/Form/Type/LanguageType.php +++ b/src/Form/Type/LanguageType.php @@ -31,7 +31,8 @@ class LanguageType extends AbstractType { $resolver->setDefaults([ 'choices' => array( - Intl::getLocaleBundle()->getLocaleName('de', 'de') => 'de' + Intl::getLocaleBundle()->getLocaleName('de', \Locale::getDefault()) => 'de', + Intl::getLocaleBundle()->getLocaleName('en', \Locale::getDefault()) => 'en', ) ]); } diff --git a/src/Form/Type/UserType.php b/src/Form/Type/UserType.php index 3da6df10..32175971 100644 --- a/src/Form/Type/UserType.php +++ b/src/Form/Type/UserType.php @@ -30,7 +30,7 @@ class UserType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'class' => 'Kimai:User', + 'class' => User::class, 'choice_label' => function (User $user) { if (!empty($user->getAlias())) { return $user->getAlias() . ' (' . $user->getUsername() . ')'; diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php index aed56640..157fe6ed 100644 --- a/src/Repository/CustomerRepository.php +++ b/src/Repository/CustomerRepository.php @@ -74,8 +74,6 @@ class CustomerRepository extends AbstractRepository ->andWhere('c.id = :customer') ; -// dump($qb->getQuery()->getSQL());exit; - $result = $qb->getQuery()->execute(['customer' => $customer], Query::HYDRATE_ARRAY); $stats = new CustomerStatistic(); diff --git a/translations/messages.de.xliff b/translations/messages.de.xliff index 412b27b8..13ba9799 100644 --- a/translations/messages.de.xliff +++ b/translations/messages.de.xliff @@ -181,9 +181,13 @@ label.duration Dauer + + label.user + Benutzer + label.username - Benutzer + Benutzername label.description diff --git a/translations/messages.en.xliff b/translations/messages.en.xliff index 04ecff04..6ecabb7b 100644 --- a/translations/messages.en.xliff +++ b/translations/messages.en.xliff @@ -183,6 +183,10 @@ label.duration Duration + + label.user + User + label.username Username