GenreAdmin   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A configureRoutes() 0 7 1
A configureShowFields() 0 9 1
A configureDatagridFilters() 0 6 1
A configureListFields() 0 11 1
A configureFormFields() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\IgdbBundle\Admin;
6
7
use Sonata\AdminBundle\Admin\AbstractAdmin;
8
use Sonata\AdminBundle\Datagrid\DatagridMapper;
9
use Sonata\AdminBundle\Datagrid\ListMapper;
10
use Sonata\AdminBundle\Form\FormMapper;
11
use Sonata\AdminBundle\Route\RouteCollectionInterface;
12
use Sonata\AdminBundle\Show\ShowMapper;
13
use VideoGamesRecords\IgdbBundle\Entity\Genre;
14
15
/**
16
 * @extends AbstractAdmin<Genre>
17
 */
18
final class GenreAdmin extends AbstractAdmin
19
{
20
    protected function configureRoutes(RouteCollectionInterface $collection): void
21
    {
22
        $collection
23
            ->remove('create')
24
            ->remove('edit')
25
            ->remove('delete')
26
            ->remove('export');
27
    }
28
29
    protected function configureFormFields(FormMapper $form): void
30
    {
31
        // Read-only admin - no form fields needed as data comes from IGDB API
32
    }
33
34
    protected function configureDatagridFilters(DatagridMapper $filter): void
35
    {
36
        $filter
37
            ->add('id', null, ['label' => 'field.id'])
38
            ->add('name', null, ['label' => 'field.name'])
39
            ->add('slug', null, ['label' => 'field.slug']);
40
    }
41
42
    protected function configureListFields(ListMapper $list): void
43
    {
44
        $list
45
            ->add('id', null, ['label' => 'field.id'])
46
            ->add('name', null, ['label' => 'field.name'])
47
            ->add('slug', null, ['label' => 'field.slug'])
48
            ->add('createdAt', null, ['label' => 'field.created_at'])
49
            ->add('updatedAt', null, ['label' => 'field.updated_at'])
50
            ->add(ListMapper::NAME_ACTIONS, null, [
51
                'actions' => [
52
                    'show' => ['template' => null],
53
                ],
54
            ]);
55
    }
56
57
    protected function configureShowFields(ShowMapper $show): void
58
    {
59
        $show
60
            ->add('id', null, ['label' => 'field.id'])
61
            ->add('name', null, ['label' => 'field.name'])
62
            ->add('slug', null, ['label' => 'field.slug'])
63
            ->add('url', null, ['label' => 'field.url'])
64
            ->add('createdAt', null, ['label' => 'field.created_at'])
65
            ->add('updatedAt', null, ['label' => 'field.updated_at']);
66
    }
67
}
68