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

heimrichhannot / contao-utils-bundle / 8647844091

11 Apr 2024 01:49PM UTC coverage: 71.88% (+1.1%) from 70.826%
8647844091

push

github

koertho
adjust #83 for v3 and php8

5 of 5 new or added lines in 1 file covered. (100.0%)

17 existing lines in 2 files now uncovered.

887 of 1234 relevant lines covered (71.88%)

3.37 hits per line

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

82.35
/src/EventListener/DcaField/AbstractDcaFieldListener.php
1
<?php
2

3
namespace HeimrichHannot\UtilsBundle\EventListener\DcaField;
4

5
use Contao\CoreBundle\Framework\ContaoFramework;
6
use Contao\Model;
7
use HeimrichHannot\UtilsBundle\Dca\DcaFieldConfiguration;
8
use Psr\Container\ContainerInterface;
9
use Symfony\Contracts\Service\ServiceSubscriberInterface;
10

11
abstract class AbstractDcaFieldListener implements ServiceSubscriberInterface
12
{
13
    public function __construct(protected ContainerInterface $container)
14
    {
15
    }
10✔
16

17
    protected function getModelInstance(string $table, int $id): ?Model
18
    {
19
        $framework = $this->container->get('contao.framework');
1✔
20
        $modelClass = $framework->getAdapter(Model::class)->getClassFromTable($table);
1✔
21
        return $framework->getAdapter($modelClass)->findByPk($id);
1✔
22
    }
23

24
    protected function applyDefaultFieldAdjustments(array &$field, DcaFieldConfiguration $configuration)
25
    {
26
        if ($configuration->isFilter()) {
7✔
27
            $field['filter'] = true;
2✔
28
        }
29

30
        if ($configuration->isSearch()) {
7✔
31
            $field['search'] = true;
2✔
32
        }
33

34
        if ($configuration->isExclude()) {
7✔
35
            $field['exclude'] = true;
2✔
36
        }
37

38
        if ($configuration->isSorting()) {
7✔
39
            $field['sorting'] = true;
2✔
40
        }
41

42
        if ($configuration->getFlag() !== null) {
7✔
43
            $field['flag'] = $configuration->getFlag();
2✔
44
        }
45
    }
46

47
    public static function getSubscribedServices(): array
48
    {
UNCOV
49
        return [
×
UNCOV
50
            'contao.framework' => ContaoFramework::class,
×
UNCOV
51
        ];
×
52
    }
53
}
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