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

reintroducing CourseAttendee

parent 44859f79
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
"php": ">=7.3",
"ext-json": "*",
"api-platform/core": "^2.6",
"dbp/relay-base-person-bundle": "dev-main",
"dbp/relay-core-bundle": "^0.1.11",
"symfony/framework-bundle": "^5.4"
},
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f5c22688f47ec610c9b3ebcd5797cb1b",
"content-hash": "c6de62624b6c871ceea7cd39f50c97b9",
"packages": [
{
"name": "api-platform/core",
......@@ -167,6 +167,56 @@
],
"time": "2022-01-11T10:29:54+00:00"
},
{
"name": "dbp/relay-base-person-bundle",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://gitlab.tugraz.at/dbp/relay/dbp-relay-base-person-bundle",
"reference": "2c871dbc1774839a10f544dc44a2e54d0a525443"
},
"require": {
"api-platform/core": "^2.6.3",
"dbp/relay-core-bundle": "^0.1.25",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0",
"nelmio/cors-bundle": "^2.1.0",
"php": ">=7.3",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0",
"symfony/config": "^5.2",
"symfony/expression-language": "^5.2",
"symfony/framework-bundle": "^5.2",
"symfony/security-bundle": "^5.2",
"symfony/security-core": "^5.2",
"symfony/security-guard": "^5.2",
"symfony/twig-bundle": "^5.2",
"symfony/validator": "^5.2",
"symfony/yaml": "^5.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpunit/phpunit": "^9",
"symfony/browser-kit": "^5.2",
"symfony/http-client": "^5.2",
"symfony/monolog-bundle": "^3.7",
"symfony/phpunit-bridge": "^5.2",
"vimeo/psalm": "^4.4"
},
"default-branch": true,
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Dbp\\Relay\\BasePersonBundle\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"AGPL-3.0-or-later"
],
"time": "2022-02-07T09:07:33+00:00"
},
{
"name": "dbp/relay-core-bundle",
"version": "v0.1.30",
......@@ -9917,7 +9967,9 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"dbp/relay-base-person-bundle": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
......
......@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\API;
use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Entity\CourseAttendee;
interface CourseProviderInterface
{
......@@ -19,4 +20,9 @@ interface CourseProviderInterface
* @return Course[]
*/
public function getCoursesByOrganization(string $orgUnitId, array $options = []): array;
/**
* @return CourseAttendee[]
*/
public function getAttendeesByCourse(string $courseId, array $options = []): array;
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Controller;
use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class GetStudentsByCourse extends AbstractController
{
public const ITEMS_PER_PAGE = 250;
protected $coursesProvider;
public function __construct(CourseProviderInterface $coursesProvider)
{
$this->coursesProvider = $coursesProvider;
}
public function __invoke(string $identifier, Request $request): ArrayFullPaginator
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$page = (int) $request->query->get('page', 1);
$perPage = (int) $request->query->get('perPage', self::ITEMS_PER_PAGE);
$options = [];
if ($request->query->has('lang')) {
$options['lang'] = (string) $request->query->get('lang');
}
$courses = $this->coursesProvider->getAttendeesByCourse($identifier, $options);
return new ArrayFullPaginator($courses, $page, $perPage);
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Dbp\Relay\BasePersonBundle\Controller\GetAtteendeesByCourse;
use Dbp\Relay\BasePersonBundle\Entity\PersonInterface;
use Dbp\Relay\BasePersonBundle\Entity\PersonTrait;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* collectionOperations={
* "get" = {
* "openapi_context" = {
* "tags" = {"Courses"}
* }
* },
* "get_bycourse" = {
* "method" = "GET",
* "path" = "/courses/{identifier}/attendees",
* "controller" = GetAtteendeesByCourse::class,
* "read" = false,
* "normalization_context" = {
* "jsonld_embed_context" = true,
* "groups" = {"BasePerson:output"}
* },
* "openapi_context" = {
* "tags" = {"Courses"},
* "summary" = "Get the attendees of a course.",
* "parameters" = {
* {"name" = "identifier", "in" = "path", "description" = "Id of course", "required" = true, "type" = "string", "example" = "123456"},
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"}
* }
* }
* }
* },
* itemOperations={
* "get" = {
* "openapi_context" = {
* "tags" = {"Courses"}
* }
* }
* },
* iri="http://schema.org/Person",
* shortName="BasePerson",
* description="A person of the LDAP system",
* normalizationContext={
* "groups" = {"BasePerson:output"},
* "jsonld_embed_context" = true,
* }
* )
*/
class CourseAttendee implements PersonInterface
{
use PersonTrait;
}
......@@ -6,6 +6,7 @@ namespace Dbp\Relay\CourseBundle\Service;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Entity\CourseAttendee;
class DummyCourseProvider implements CourseProviderInterface
{
......@@ -31,4 +32,15 @@ class DummyCourseProvider implements CourseProviderInterface
{
return $this->getCourses($options);
}
public function getAttendeesByCourse(string $courseId, array $options = []): array
{
$attendee = new CourseAttendee();
$attendee->setIdentifier('aeinstein');
$attendee->setGivenName('Albert');
$attendee->setFamilyName('Einstein');
$attendee->setEmail('info@einstein.com');
return [$attendee];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment