-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../Infrastructure/Sulu/Content/PropertyResolver/SingleCategorySelectionPropertyResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\CategoryBundle\Infrastructure\Sulu\Content\PropertyResolver; | ||
|
||
use Sulu\Bundle\CategoryBundle\Infrastructure\Sulu\Content\ResourceLoader\CategoryResourceLoader; | ||
use Sulu\Bundle\ContentBundle\Content\Application\ContentResolver\Value\ContentView; | ||
use Sulu\Bundle\ContentBundle\Content\Application\PropertyResolver\PropertyResolverInterface; | ||
|
||
/** | ||
* @internal if you need to override this service, create a new service with based on PropertyResolverInterface instead of extending this class | ||
* | ||
* @final | ||
*/ | ||
class SingleCategorySelectionPropertyResolver implements PropertyResolverInterface | ||
{ | ||
public function resolve(mixed $data, string $locale, array $params = []): ContentView | ||
{ | ||
if (!\is_string($data) || '' === $data) { | ||
return ContentView::create([], $params); | ||
} | ||
|
||
/** @var string $resourceLoaderKey */ | ||
$resourceLoaderKey = $params['resourceLoader'] ?? CategoryResourceLoader::getKey(); | ||
|
||
return ContentView::createResolvables( | ||
$data, | ||
$resourceLoaderKey, | ||
$params, | ||
); | ||
} | ||
|
||
public static function getType(): string | ||
{ | ||
return 'single_category_selection'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Sulu/Bundle/TagBundle/Resources/config/services_content.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<!-- Content Property Resolvers --> | ||
<service id="sulu_tag.tag_selection_property_resolver" class="Sulu\Bundle\TagBundle\Infrastructure\Sulu\Content\PropertyResolver\TagSelectionPropertyResolver"> | ||
<tag name="sulu_content.property_resolver"/> | ||
</service> | ||
|
||
<!-- Content Resource Loaders --> | ||
<service id="sulu_tag.tag_resource_loader" class="Sulu\Bundle\TagBundle\Infrastructure\Sulu\Content\ResourceLoader\TagResourceLoader"> | ||
<argument type="service" id="sulu.repository.tag"/> | ||
|
||
<tag name="sulu_content.resource_loader"/> | ||
</service> | ||
</services> | ||
</container> |