Skip to content

Commit

Permalink
[Task]: Follow up to `Replace Request::get with explicit input source…
Browse files Browse the repository at this point in the history
…s` (#877)

* Removed default value from request->get

* Apply php-cs-fixer changes

* Update src/Controller/WebserviceController.php

Co-authored-by: Sebastian Blank <[email protected]>

* Using all instead of get because of the array type

---------

Co-authored-by: mcop1 <[email protected]>
Co-authored-by: Sebastian Blank <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2024
1 parent b6433ed commit 0a9a920
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/Controller/WebserviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function webonyxAction(
LongRunningHelper $longRunningHelper
) {
$clientname = $request->attributes->getString('clientname');
$variableValues = null;

$configuration = Configuration::getByName($clientname);
if (!$configuration || !$configuration->isActive()) {
Expand Down Expand Up @@ -161,7 +162,6 @@ public function webonyxAction(
}

$query = $input['query'] ?? '';
$variableValues = $input['variables'] ?? null;

try {
$rootValue = [];
Expand All @@ -178,7 +178,11 @@ public function webonyxAction(
$this->eventDispatcher->dispatch($event, ExecutorEvents::PRE_EXECUTE);

if ($event->getRequest() instanceof Request) {
$variableValues = $event->getRequest()->request->get('variables', $variableValues);
$variableValues = $event->getRequest()->request->all('variables');
}

if (!$variableValues) {
$variableValues = $input['variables'] ?? null;
}

$configAllowIntrospection = true;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/DataObjectInputProcessor/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)
$attribute = $this->getAttribute();
$objectBrickParts = Service::parseObjectBrickFieldName($attribute);

if(empty($objectBrickParts)) {
if (empty($objectBrickParts)) {
$getter = 'get' . ucfirst($attribute);
$currentTable = $object->$getter();
} else {
Expand Down
12 changes: 6 additions & 6 deletions tests/GraphQL/ResolveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testGraphQLTranslationListingResolveListing()
$translationListing = new TranslationListing($this->service, new EventDispatcher());
$listRes = $translationListing->resolveListing([], []);

for($i = 0; $i < 4; $i++) {
for ($i = 0; $i < 4; $i++) {
$this->assertEquals('translation-k' .$i, $listRes['edges'][$i]['cursor']);

$translation = $listRes['edges'][$i]['node'];
Expand All @@ -53,7 +53,7 @@ public function testGraphQLTranslationListingResolveListingWithDomain()
$translationListing = new TranslationListing($this->service, new EventDispatcher());
$listRes = $translationListing->resolveListing([], ['domain' => 'admin']);

for($i = 0; $i < 2; $i++) {
for ($i = 0; $i < 2; $i++) {
$this->assertEquals('translation-ka' .$i, $listRes['edges'][$i]['cursor']);

$translation = $listRes['edges'][$i]['node'];
Expand Down Expand Up @@ -85,7 +85,7 @@ public function testGraphQLTranslationListingResolveListingWithKeys()
$translationListing = new TranslationListing($this->service, new EventDispatcher());
$listRes = $translationListing->resolveListing([], ['keys' => $keys]);

for($i = 0; $i < 2; $i++) {
for ($i = 0; $i < 2; $i++) {
$this->assertEquals('translation-k' .$i + 1, $listRes['edges'][$i]['cursor']);

$translation = $listRes['edges'][$i]['node'];
Expand Down Expand Up @@ -128,7 +128,7 @@ public function testGraphQLTranslationListingResolveListingWithLanguagesAndKeys(
$translationListing = new TranslationListing($this->service, new EventDispatcher());
$listRes = $translationListing->resolveListing([], ['languages' => $languages, 'keys' => $keys]);

for($i = 0; $i < 2; $i++) {
for ($i = 0; $i < 2; $i++) {
$translation = $listRes['edges'][$i]['node'];
$translations = $translation->getTranslations();

Expand All @@ -149,10 +149,10 @@ public function testGraphQLResolveTranslationGetter()

private function addTranslations(): void
{
for($i = 0; $i < 4; $i++) {
for ($i = 0; $i < 4; $i++) {
$this->addTranslation('k' . $i);
}
for($i = 0; $i < 2; $i++) {
for ($i = 0; $i < 2; $i++) {
$this->addTranslation('ka' . $i, 'admin');
$this->addTranslation('ka' . $i, 'admin');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_support/Helper/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function grabService(string $serviceId)
{

//TODO change this as soon as Pimcore helper as grabService method and requirement is bumped to pimcore/pimcore:10.4
if(empty(self::$container)) {
if (empty(self::$container)) {
$container = \Pimcore::getContainer();
self::$container = $container->has('test.service_container') ? $container->get('test.service_container') : $container;
}
Expand Down

0 comments on commit 0a9a920

Please sign in to comment.