• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

php-bug-catcher / bug-catcher / 11534267277

26 Oct 2024 07:05PM UTC coverage: 87.486% (-3.3%) from 90.754%
11534267277

push

github

tito10047
fixed timezone in tests

804 of 919 relevant lines covered (87.49%)

6.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.29
/src/Controller/Admin/UserCrudController.php
1
<?php
2

3
namespace BugCatcher\Controller\Admin;
4

5
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
6
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
7
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
8
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
9
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
10
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
11
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
12
use BugCatcher\Controller\AbstractCrudController;
13
use BugCatcher\Entity\Client\Client;
14
use BugCatcher\Entity\Role;
15
use BugCatcher\Entity\User;
16
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
17
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
18
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
19

20
final class UserCrudController extends AbstractCrudController
21
{
22
        public function __construct(
23
                public UserPasswordHasherInterface $userPasswordHasher,
24
                public array                       $roles
25
        ) {}
2✔
26

27
        public static function getEntityFqcn(): string {
28
                return User::class;
×
29
        }
30

31
        public function configureActions(Actions $actions): Actions {
32
                $update = function (Action $action) {
2✔
33
                        return $action->displayIf(function (User $user) {
2✔
34
                                return $user !== $this->getUser();
×
35
                        });
2✔
36
                };
2✔
37

38
                return $actions
2✔
39
                        ->update(Crud::PAGE_INDEX, Action::DELETE, $update);
2✔
40
        }
41

42

43
        public function configureFields(string $pageName): iterable {
44
                $parameterBag = $this->container->get(ParameterBagInterface::class);
2✔
45
                $password = TextField::new('plainPassword')
2✔
46
                        ->setFormType(PasswordType::class)
2✔
47
                        ->setFormTypeOptions([
2✔
48
                                'mapped'             => false,
2✔
49
                                'hash_property_path' => "password",
2✔
50
                        ])
2✔
51
                        ->setLabel("New password")
2✔
52
                        ->setRequired($pageName === Crud::PAGE_NEW)
2✔
53
                        ->onlyOnForms();
2✔
54

55

56
                return [
2✔
57
                        TextField::new('email')->setColumns(8),
2✔
58
                        BooleanField::new("enabled")->setColumns(4),
2✔
59
                        TextField::new('fullname')->setColumns(4),
2✔
60
                        ChoiceField::new('roles')
2✔
61
                                ->setChoices($this->roles)
2✔
62
                                ->allowMultipleChoices()
2✔
63
                                ->setRequired(true)
2✔
64
                                ->onlyOnForms(),
2✔
65
                        AssociationField::new('projects')->setColumns(6)->onlyOnForms(),
2✔
66
                        $password,
2✔
67
                ];
2✔
68

69

70
        }
71

72

73
        public static function getSubscribedServices(): array {
74
                $services                               = parent::getSubscribedServices();
×
75
                $services[ParameterBagInterface::class] = ParameterBagInterface::class;
×
76

77
                return $services;
×
78
        }
79

80

81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc