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
93 changed files
with
1,128 additions
and
462 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# usage: generate-changelog.sh previous_tag next_tag | ||
# example: generate-changelog.sh v2.7.2 v2.7.3 > CHANGELOG.new.md | ||
log=$(git log "$1..HEAD" --pretty='format:* [%h](https://github.com/api-platform/core/commit/%H) %s' --no-merges) | ||
|
||
diff=$( | ||
printf "# Changelog\n\n" | ||
printf "## %s\n\n" "$2" | ||
if [[ 0 != $(echo "$log" | grep fix | grep -v chore | wc -l) ]]; | ||
then | ||
printf "### Bug fixes\n\n" | ||
printf "$log" | grep fix | grep -v chore | sort | ||
printf "\n\n" | ||
fi | ||
if [[ 0 != $(echo "$log" | grep feat | grep -v chore | wc -l) ]]; | ||
then | ||
printf "### Features\n\n" | ||
printf "$log" | grep feat | grep -v chore | sort | ||
fi | ||
) | ||
|
||
changelog=$(tail -n+2 CHANGELOG.md) | ||
printf "%s\n%s" "$diff" "$changelog" |
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
67 changes: 67 additions & 0 deletions
67
src/GraphQl/Metadata/Factory/GraphQlNestedOperationResourceMetadataFactory.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,67 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\GraphQl\Metadata\Factory; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Resource\Factory\OperationDefaultsTrait; | ||
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; | ||
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; | ||
use Psr\Log\LoggerInterface; | ||
use Psr\Log\NullLogger; | ||
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; | ||
|
||
final class GraphQlNestedOperationResourceMetadataFactory implements ResourceMetadataCollectionFactoryInterface | ||
{ | ||
use OperationDefaultsTrait; | ||
|
||
public function __construct(array $defaults, private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null, ?LoggerInterface $logger = null) | ||
{ | ||
$this->defaults = $defaults; | ||
$this->camelCaseToSnakeCaseNameConverter = new CamelCaseToSnakeCaseNameConverter(); | ||
$this->logger = $logger ?? new NullLogger(); | ||
} | ||
|
||
public function create(string $resourceClass): ResourceMetadataCollection | ||
{ | ||
$resourceMetadataCollection = new ResourceMetadataCollection($resourceClass); | ||
|
||
if ($this->decorated) { | ||
$resourceMetadataCollection = $this->decorated->create($resourceClass); | ||
} | ||
|
||
if (0 < \count($resourceMetadataCollection)) { | ||
return $resourceMetadataCollection; | ||
} | ||
|
||
$shortName = (false !== $pos = strrpos($resourceClass, '\\')) ? substr($resourceClass, $pos + 1) : $resourceClass; | ||
|
||
$apiResource = new ApiResource( | ||
class: $resourceClass, | ||
shortName: $shortName | ||
); | ||
|
||
if (class_exists($resourceClass)) { | ||
$refl = new \ReflectionClass($resourceClass); | ||
$attribute = $refl->getAttributes(ApiResource::class)[0] ?? null; | ||
$attributeInstance = $attribute?->newInstance(); | ||
if ($filters = $attributeInstance?->getFilters()) { | ||
$apiResource = $apiResource->withFilters($filters); | ||
} | ||
} | ||
|
||
$resourceMetadataCollection[0] = $this->addDefaultGraphQlOperations($apiResource); | ||
|
||
return $resourceMetadataCollection; | ||
} | ||
} |
Oops, something went wrong.