Skip to content
Snippets Groups Projects
Commit f35a21b0 authored by Tobias Gross-Vogt's avatar Tobias Gross-Vogt
Browse files

include -> includeLocal

parent 47304cc4
No related branches found
No related tags found
No related merge requests found
......@@ -173,7 +173,7 @@
"source": {
"type": "git",
"url": "git@gitlab.tugraz.at:dbp/relay/dbp-relay-core-bundle.git",
"reference": "4ede1874cf2f75680fdf0aa839ee358f4c3a4b5d"
"reference": "106d795fda10967c6202e3157b8bb1861bd9d2f7"
},
"require": {
"api-platform/core": "^2.6.6",
......@@ -269,7 +269,7 @@
"AGPL-3.0-or-later"
],
"description": "The core bundle of the Relay API gateway",
"time": "2022-04-21T13:52:29+00:00"
"time": "2022-04-28T10:48:16+00:00"
},
{
"name": "doctrine/annotations",
......
......@@ -9,6 +9,7 @@ use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use Dbp\Relay\BaseCourseBundle\API\CourseProviderInterface;
use Dbp\Relay\BaseCourseBundle\Entity\Course;
use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
use Dbp\Relay\CoreBundle\LocalData\LocalData;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
final class CourseCollectionDataProvider extends AbstractController implements CollectionDataProviderInterface, RestrictedDataProviderInterface
......@@ -38,9 +39,7 @@ final class CourseCollectionDataProvider extends AbstractController implements C
$options['term'] = $term;
}
if ($include = ($filters['include'] ?? null)) {
$options['include'] = $include;
}
$options[LocalData::INCLUDE_PARAMETER_NAME] = LocalData::getIncludeParameter($filters);
$organizationId = $filters['organization'] ?? null;
$lecturerId = $filters['lecturer'] ?? null;
......
......@@ -8,6 +8,7 @@ use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use Dbp\Relay\BaseCourseBundle\API\CourseProviderInterface;
use Dbp\Relay\BaseCourseBundle\Entity\Course;
use Dbp\Relay\CoreBundle\LocalData\LocalData;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
final class CourseItemDataProvider extends AbstractController implements ItemDataProviderInterface, RestrictedDataProviderInterface
......@@ -32,10 +33,7 @@ final class CourseItemDataProvider extends AbstractController implements ItemDat
$options = [];
$options['lang'] = $filters['lang'] ?? 'de';
if ($include = ($filters['include'] ?? null)) {
$options['include'] = $include;
}
$options[LocalData::INCLUDE_PARAMETER_NAME] = LocalData::getIncludeParameter($filters);
return $this->api->getCourseById($id, $options);
}
......
......@@ -19,8 +19,8 @@ use Dbp\Relay\CoreBundle\LocalData\LocalDataAwareTrait;
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"},
* {"name" = "term", "in" = "query", "description" = "Teaching term", "type" = "string", "enum" = {"W", "S"}, "example" = "W"},
* {"name" = "organization", "in" = "query", "description" = "Get courses of an organization (ID of BaseOrganization resource)", "required" = false, "type" = "string", "example" = "1190"},
* {"name" = "lecturer", "in" = "query", "description" = "Get courses of a lecturer", "required" = false, "type" = "string", "example" = "woody007"},
* {"name" = "include", "in" = "query", "description" = "Optional resources to include", "type" = "string", "example" = "BaseCourse.code,BaseCourse.numberOfCredits"}
* {"name" = "lecturer", "in" = "query", "description" = "Get courses of a lecturer (ID of BasePerson resource)", "required" = false, "type" = "string", "example" = "woody007"},
* {"name" = "includeLocal", "in" = "query", "description" = "Local data attributes to include", "type" = "string", "example" = "BaseCourse.code,BaseCourse.numberOfCredits"}
* }
* }
* }
......@@ -33,7 +33,7 @@ use Dbp\Relay\CoreBundle\LocalData\LocalDataAwareTrait;
* "parameters" = {
* {"name" = "identifier", "in" = "path", "description" = "Resource identifier", "required" = true, "type" = "string", "example" = "257571"},
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"},
* {"name" = "include", "in" = "query", "description" = "Optional resources to include", "type" = "string", "example" = "BaseCourse.code,BaseCourse.numberOfCredits"}
* {"name" = "includeLocal", "in" = "query", "description" = "Local data attributes to include", "type" = "string", "example" = "BaseCourse.code,BaseCourse.numberOfCredits"}
* }
* }
* }
......
......@@ -9,11 +9,6 @@ services:
autowire: true
autoconfigure: true
# Dbp\Relay\BaseCourseBundle\Serializer\Normalizer\CourseNormalizer:
# autowire: true
# autoconfigure: true
# tags: ['serializer.normalizer']
Dbp\Relay\BaseCourseBundle\Service\DummyCourseProvider:
autowire: true
autoconfigure: true
......
<?php
declare(strict_types=1);
namespace Dbp\Relay\BaseCourseBundle\Serializer\Normalizer;
use Dbp\Relay\BaseCourseBundle\Entity\Course;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class CourseNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
private const ALREADY_CALLED = 'COURSE_NORMALIZER_CURRENT_USER_ALREADY_CALLED';
/**
* @return array|string|int|float|bool|\ArrayObject|null
*
* @throws ExceptionInterface
*/
public function normalize($object, $format = null, array $context = [])
{
// TODO: only add localData group if it is requested?
// problem: $context['filters'] not available at this point
$context['groups'][] = 'BaseCourse:localData';
$context[self::ALREADY_CALLED] = true;
return $this->normalizer->normalize($object, $format, $context);
}
public function supportsNormalization($data, $format = null, array $context = []): bool
{
if (isset($context[self::ALREADY_CALLED])) {
return false;
}
return $data instanceof Course;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment