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

sulu / SuluContentBundle / 12008183499

25 Nov 2024 10:35AM UTC coverage: 97.468% (-2.5%) from 100.0%
12008183499

push

github

web-flow
Add Base implementation of website content resolving (#271)

* Add own implementation of Controller

* Add PropertyResolver and MediaResourceLoader

* Add review suggestions

* Add unit tests

* Add sulu/sulu fork

* Keep required sulu version

* Update Content/Application/ContentResolver/Value/ContentView.php

Co-authored-by: Alexander Schranz <alexander@sulu.io>

* Update Content/Application/ResourceLoader/ResourceLoaderInterface.php

Co-authored-by: Alexander Schranz <alexander@sulu.io>

* Remove sulu fork

* Fix tests for php 8.1

* Fix tests for php 8.0

* Enhance content resolver test

* Refactor contentResolver and add LinkPropertyProvider

* Add tests

* Add TeaserSelectionPropertyResolver

* Move interfaces and adjust namespaces

* Define COMPOSER_TOKEN to fix issues with using forks

* Use automation bundle 3.0

* Update Sulu required version

* Define composer requirements for Sulu 3.0

* Fix failings tests

* Add debug line

* Skip resolver tests for now

* Trigger CI

* Ignore skipped tests

---------

Co-authored-by: Alexander Schranz <alexander@sulu.io>

280 of 353 new or added lines in 17 files covered. (79.32%)

2810 of 2883 relevant lines covered (97.47%)

10.45 hits per line

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

95.83
/Content/Application/PropertyResolver/Resolver/LinkPropertyResolver.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Sulu.
7
 *
8
 * (c) Sulu GmbH
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13

14
namespace Sulu\Bundle\ContentBundle\Content\Application\PropertyResolver\Resolver;
15

16
use Sulu\Bundle\ContentBundle\Content\Application\ContentResolver\Value\ContentView;
17
use Sulu\Bundle\ContentBundle\Content\Application\ResourceLoader\Loader\LinkResourceLoader;
18
use Sulu\Bundle\MarkupBundle\Markup\Link\LinkItem;
19

20
class LinkPropertyResolver implements PropertyResolverInterface
21
{
22
    /**
23
     * @param array{
24
     *    rel?: string,
25
     *    href: string,
26
     *    query?: string,
27
     *    title?: string,
28
     *    anchor?: string,
29
     *    target?: string,
30
     *    provider?: string
31
     * }|mixed $data
32
     * @param mixed[] $params
33
     */
34
    public function resolve(mixed $data, string $locale, array $params = []): ContentView
35
    {
36
        if (
37
            !\is_array($data)
11✔
38
            || !\array_key_exists('href', $data)
11✔
39
            || !\array_key_exists('provider', $data)
11✔
40
        ) {
41
            return ContentView::create($data, [...$params]);
8✔
42
        }
43

44
        /** @var string $resourceLoaderKey */
45
        $resourceLoaderKey = $params['resourceLoader'] ?? LinkResourceLoader::getKey();
3✔
46

47
        return ContentView::createResolvable(
3✔
48
            $data['provider'] . '::' . $data['href'],
3✔
49
            $resourceLoaderKey,
3✔
50
            [
3✔
51
                ...$data,
3✔
52
                ...$params,
3✔
53
            ],
3✔
54
            // external links are not passed as a LinkItem
55
            static function(string|LinkItem $linkItem) use ($data) {
3✔
56
                if (\is_string($linkItem)) {
1✔
NEW
57
                    return $linkItem;
×
58
                }
59

60
                $url = $linkItem->getUrl();
1✔
61
                if (isset($data['query'])) {
1✔
62
                    $url = \sprintf('%s?%s', $url, \ltrim($data['query'], '?'));
1✔
63
                }
64
                if (isset($data['anchor'])) {
1✔
65
                    $url = \sprintf('%s#%s', $url, \ltrim($data['anchor'], '#'));
1✔
66
                }
67

68
                return $url;
1✔
69
            }
3✔
70
        );
3✔
71
    }
72

73
    public static function getType(): string
74
    {
75
        return 'link';
1✔
76
    }
77
}
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

© 2026 Coveralls, Inc