-
Notifications
You must be signed in to change notification settings - Fork 16
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
Bertrand Dunogier
committed
Nov 25, 2020
1 parent
35c4fef
commit 5f919be
Showing
20 changed files
with
599 additions
and
29 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
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
59 changes: 59 additions & 0 deletions
59
src/GraphQL/InputMapper/ContentCollectionFilterBuilder.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,59 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformGraphQL\GraphQL\InputMapper; | ||
|
||
use eZ\Publish\API\Repository\Repository; | ||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; | ||
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Subtree; | ||
use eZ\Publish\API\Repository\Values\Content\URLAlias; | ||
use eZ\Publish\Core\MVC\ConfigResolverInterface; | ||
|
||
/** | ||
* Builds the base query used to retrieve locations collections. | ||
* | ||
* @internal | ||
*/ | ||
class ContentCollectionFilterBuilder | ||
{ | ||
/** | ||
* @var \eZ\Publish\Core\MVC\ConfigResolverInterface | ||
*/ | ||
private $configResolver; | ||
|
||
/** | ||
* @var \eZ\Publish\API\Repository\Repository | ||
*/ | ||
private $repository; | ||
|
||
public function __construct(ConfigResolverInterface $configResolver, Repository $repository) | ||
{ | ||
$this->configResolver = $configResolver; | ||
$this->repository = $repository; | ||
} | ||
|
||
/** | ||
* Returns a criterion to be added as a global 'and' to a query's filters. | ||
*/ | ||
public function buildFilter(): Criterion | ||
{ | ||
$treeRootLocationId = $this->configResolver->getParameter('content.tree_root.location_id'); | ||
$rootLocation = $this->repository->getLocationService()->loadLocation($treeRootLocationId); | ||
|
||
$includedSubtrees = [$rootLocation->pathString ?? '/']; | ||
|
||
foreach ($this->configResolver->getParameter('content.tree_root.excluded_uri_prefixes') as $uriPrefix) { | ||
$urlAlias = $this->repository->getURLAliasService()->lookup($uriPrefix); | ||
if ($urlAlias->type === URLAlias::LOCATION) { | ||
$includedSubtrees[] = $this->repository->getLocationService()->loadLocation($urlAlias->destination)->pathString; | ||
} | ||
} | ||
|
||
return new SubTree($includedSubtrees); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace EzSystems\EzPlatformGraphQL\GraphQL\InputMapper; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\LocationQuery; | ||
use eZ\Publish\API\Repository\Values\Content\Query; | ||
|
||
interface QueryMapper | ||
{ | ||
public function mapInputToLocationQuery(array $inputArray): LocationQuery; | ||
|
||
public function mapInputToQuery(array $inputArray): Query; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace EzSystems\EzPlatformGraphQL\GraphQL; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Content; | ||
use eZ\Publish\API\Repository\Values\Content\Location; | ||
use EzSystems\EzPlatformGraphQL\GraphQL\Value\Item; | ||
|
||
class ItemFactory | ||
{ | ||
/** | ||
* @var \EzSystems\EzPlatformGraphQL\GraphQL\Resolver\LocationGuesser\LocationGuesser | ||
*/ | ||
private $locationGuesser; | ||
|
||
public function __construct(Resolver\LocationGuesser\LocationGuesser $locationGuesser) | ||
{ | ||
$this->locationGuesser = $locationGuesser; | ||
} | ||
|
||
public function fromContent(Content $content): Item | ||
{ | ||
return new Item($this->locationGuesser, null, $content); | ||
} | ||
|
||
public function fromLocation(Location $location) | ||
{ | ||
return new Item($this->locationGuesser, $location, null); | ||
} | ||
} |
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
Oops, something went wrong.