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

first version with linter fixes

parent 2224026f
No related branches found
No related tags found
No related merge requests found
Pipeline #86044 failed
Showing
with 569 additions and 163 deletions
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"php": ">=7.3", "php": ">=7.3",
"ext-json": "*", "ext-json": "*",
"api-platform/core": "^2.6", "api-platform/core": "^2.6",
"dbp/relay-base-person-bundle": "dev-main",
"dbp/relay-core-bundle": "^0.1.11", "dbp/relay-core-bundle": "^0.1.11",
"symfony/framework-bundle": "^5.4" "symfony/framework-bundle": "^5.4"
}, },
...@@ -34,6 +35,9 @@ ...@@ -34,6 +35,9 @@
"sort-packages": true, "sort-packages": true,
"platform": { "platform": {
"php": "7.3" "php": "7.3"
},
"allow-plugins": {
"composer/package-versions-deprecated": true
} }
}, },
"scripts": { "scripts": {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "db61c2249bc8c4ee921893e623472e9a", "content-hash": "c6de62624b6c871ceea7cd39f50c97b9",
"packages": [ "packages": [
{ {
"name": "api-platform/core", "name": "api-platform/core",
...@@ -167,6 +167,56 @@ ...@@ -167,6 +167,56 @@
], ],
"time": "2022-01-11T10:29:54+00:00" "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": "a7e3c201348fe70841d7e7c031e7a5ca8a007a54"
},
"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-01-31T11:47:53+00:00"
},
{ {
"name": "dbp/relay-core-bundle", "name": "dbp/relay-core-bundle",
"version": "v0.1.30", "version": "v0.1.30",
...@@ -9917,7 +9967,9 @@ ...@@ -9917,7 +9967,9 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"dbp/relay-base-person-bundle": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
......
...@@ -6,6 +6,4 @@ parameters: ...@@ -6,6 +6,4 @@ parameters:
level: 3 level: 3
paths: paths:
- src - src
ignoreErrors:
- message: '#.*NodeDefinition::children.*#'
path: ./src/DependencyInjection
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\API;
use Dbp\Relay\BasePersonBundle\Entity\Person;
use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Entity\Exam;
interface CourseProviderInterface
{
public function getCourseById(string $identifier, array $options = []): ?Course;
/**
* @return Course[]
*/
public function getCourses(array $options = []): array;
/**
* @return Course[]
*/
public function getCoursesByOrganization(string $orgUnitId, array $options = []): array;
/**
* @return Course[]
*/
public function getCoursesByPerson(string $personId, array $options = []): array;
/**
* @return Person[]
*/
public function getStudentsByCourse(string $courseId, array $options = []): array;
/**
* @return Exam[]
*/
public function getExamsByCourse(string $courseId, array $options = []): array;
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class TestCommand extends Command
{
protected static $defaultName = 'dbp:my-custom-command';
public function __construct()
{
parent::__construct();
}
protected function configure()
{
$this->addArgument('argument', InputArgument::REQUIRED, 'Example.');
$this->setDescription('Hey there!');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$argument = $input->getArgument('argument');
$output->writeln($argument);
return 0;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Controller;
use ApiPlatform\Core\DataProvider\PaginatorInterface;
use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class GetCoursesByOrganization extends AbstractController
{
public const ITEMS_PER_PAGE = 250;
protected $coursesProvider;
public function __construct(CourseProviderInterface $coursesProvider)
{
$this->coursesProvider = $coursesProvider;
}
public function __invoke(string $id, Request $request): PaginatorInterface
{
$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->getCoursesByOrganization($id, $options);
return new ArrayFullPaginator($courses, $page, $perPage);
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Controller;
use ApiPlatform\Core\DataProvider\PaginatorInterface;
use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class GetCoursesByPerson extends AbstractController
{
public const ITEMS_PER_PAGE = 250;
protected $coursesProvider;
public function __construct(CourseProviderInterface $coursesProvider)
{
$this->coursesProvider = $coursesProvider;
}
public function __invoke(string $id, Request $request): PaginatorInterface
{
$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->getCoursesByPerson($id, $options);
return new ArrayFullPaginator($courses, $page, $perPage);
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Controller;
use ApiPlatform\Core\DataProvider\PaginatorInterface;
use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class GetExamsByCourse extends AbstractController
{
public const ITEMS_PER_PAGE = 250;
protected $coursesProvider;
public function __construct(CourseProviderInterface $coursesProvider)
{
$this->coursesProvider = $coursesProvider;
}
public function __invoke(string $id, Request $request): PaginatorInterface
{
$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->getExamsByCourse($id, $options);
return new ArrayFullPaginator($courses, $page, $perPage);
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Controller;
use ApiPlatform\Core\DataProvider\PaginatorInterface;
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 $id, Request $request): PaginatorInterface
{
$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->getStudentsByCourse($id, $options);
return new ArrayFullPaginator($courses, $page, $perPage);
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Controller;
use Dbp\Relay\CourseBundle\Entity\Course;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class LoggedInOnly extends AbstractController
{
public function __invoke(Course $data, Request $request): Course
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
return $data;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\DataPersister;
use ApiPlatform\Core\DataPersister\DataPersisterInterface;
use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Service\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class CourseDataPersister extends AbstractController implements DataPersisterInterface
{
private $api;
public function __construct(CourseProviderInterface $api)
{
$this->api = $api;
}
public function supports($data): bool
{
return $data instanceof Course;
}
public function persist($data): void
{
// TODO
}
public function remove($data)
{
// TODO
}
}
...@@ -7,8 +7,8 @@ namespace Dbp\Relay\CourseBundle\DataProvider; ...@@ -7,8 +7,8 @@ namespace Dbp\Relay\CourseBundle\DataProvider;
use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface; use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator; use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Dbp\Relay\CourseBundle\Entity\Course; use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Service\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
final class CourseCollectionDataProvider extends AbstractController implements CollectionDataProviderInterface, RestrictedDataProviderInterface final class CourseCollectionDataProvider extends AbstractController implements CollectionDataProviderInterface, RestrictedDataProviderInterface
......
...@@ -6,8 +6,8 @@ namespace Dbp\Relay\CourseBundle\DataProvider; ...@@ -6,8 +6,8 @@ namespace Dbp\Relay\CourseBundle\DataProvider;
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface; use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Dbp\Relay\CourseBundle\Entity\Course; use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Service\CourseProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
final class CourseItemDataProvider extends AbstractController implements ItemDataProviderInterface, RestrictedDataProviderInterface final class CourseItemDataProvider extends AbstractController implements ItemDataProviderInterface, RestrictedDataProviderInterface
......
...@@ -11,15 +11,6 @@ class Configuration implements ConfigurationInterface ...@@ -11,15 +11,6 @@ class Configuration implements ConfigurationInterface
{ {
public function getConfigTreeBuilder(): TreeBuilder public function getConfigTreeBuilder(): TreeBuilder
{ {
$treeBuilder = new TreeBuilder('dbp_relay_course'); return new TreeBuilder('dbp_relay_course');
$treeBuilder->getRootNode()
->children()
->scalarNode('example_config')
->defaultValue('42')
->end()
->end();
return $treeBuilder;
} }
} }
...@@ -21,10 +21,6 @@ class DbpRelayCourseExtension extends ConfigurableExtension ...@@ -21,10 +21,6 @@ class DbpRelayCourseExtension extends ConfigurableExtension
new FileLocator(__DIR__.'/../Resources/config') new FileLocator(__DIR__.'/../Resources/config')
); );
$loader->load('services.yaml'); $loader->load('services.yaml');
// Inject the config value into the MyCustomService service
$definition = $container->getDefinition('Dbp\Relay\CourseBundle\Service\MyCustomService');
$definition->addArgument($mergedConfig['example_config']);
} }
private function extendArrayParameter(ContainerBuilder $container, string $parameter, array $values) private function extendArrayParameter(ContainerBuilder $container, string $parameter, array $values)
......
...@@ -6,59 +6,61 @@ namespace Dbp\Relay\CourseBundle\Entity; ...@@ -6,59 +6,61 @@ namespace Dbp\Relay\CourseBundle\Entity;
use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource; use ApiPlatform\Core\Annotation\ApiResource;
use Dbp\Relay\CourseBundle\Controller\LoggedInOnly;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
/** /**
* @ApiResource( * @ApiResource(
* collectionOperations={ * collectionOperations={
* "get" = { * "get" = {
* "path" = "/course/courses",
* "openapi_context" = { * "openapi_context" = {
* "tags" = {"Course API"}, * "tags" = {"Courses"},
* }, * "parameters" = {
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"}
* }
* } * }
* }, * },
* itemOperations={ * "get_byorganization" = {
* "get" = { * "method" = "GET",
* "path" = "/course/courses/{identifier}", * "path" = "/base/organizations/{id}/courses",
* "controller" = GetCoursesByOrganization::class,
* "read" = false,
* "openapi_context" = { * "openapi_context" = {
* "tags" = {"Course API"}, * "tags" = {"Courses"},
* "summary" = "Get the Courses related to an organization.",
* "parameters" = {
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"},
* {"name" = "id", "in" = "path", "description" = "Id of Organization", "required" = true, "type" = "string", "example" = "123456"}
* }
* }, * },
* }, * },
* "put" = { * "get_byperson" = {
* "path" = "/course/courses/{identifier}", * "method" = "GET",
* "path" = "/base/people/{id}/courses",
* "controller" = GetCoursesByPerson::class,
* "read" = false,
* "openapi_context" = { * "openapi_context" = {
* "tags" = {"Course API"}, * "tags" = {"Courses"},
* }, * "summary" = "Get the Courses related to a person.",
* "parameters" = {
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"},
* {"name" = "id", "in" = "path", "description" = "Id of Organization", "required" = true, "type" = "string", "example" = "123456"}
* }
* }, * },
* "delete" = {
* "path" = "/course/courses/{identifier}",
* "openapi_context" = {
* "tags" = {"Course API"},
* }, * },
* }, * },
* "loggedin_only" = { * itemOperations={
* "security" = "is_granted('IS_AUTHENTICATED_FULLY')", * "get" = {
* "method" = "GET",
* "path" = "/course/courses/{identifier}/loggedin-only",
* "controller" = LoggedInOnly::class,
* "openapi_context" = { * "openapi_context" = {
* "summary" = "Only works when logged in.", * "tags" = {"Courses"},
* "tags" = {"Course API"}, * "parameters" = {
* }, * {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"}
* }
* }
* } * }
* }, * },
* iri="https://schema.org/Course", * iri="https://schema.org/Course",
* shortName="CourseCourse", * normalizationContext={"groups" = {"Course:output"}, "jsonld_embed_context" = true},
* normalizationContext={ * denormalizationContext={"groups" = {"Course:input"}, "jsonld_embed_context" = true}
* "groups" = {"CourseCourse:output"},
* "jsonld_embed_context" = true
* },
* denormalizationContext={
* "groups" = {"CourseCourse:input"},
* "jsonld_embed_context" = true
* }
* ) * )
*/ */
class Course class Course
...@@ -70,12 +72,38 @@ class Course ...@@ -70,12 +72,38 @@ class Course
/** /**
* @ApiProperty(iri="https://schema.org/name") * @ApiProperty(iri="https://schema.org/name")
* @Groups({"CourseCourse:output", "CourseCourse:input"}) * @Groups({"Course:output"})
* *
* @var string * @var string
*/ */
private $name; private $name;
/**
* @ApiProperty
* @Groups({"Course:output"})
*
* @var string
*/
private $type;
/**
* @ApiProperty(iri="https://schema.org/description")
* @Groups({"Course:output"})
*
* @var string
*/
private $description;
public function getIdentifier(): string
{
return $this->identifier;
}
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
public function getName(): string public function getName(): string
{ {
return $this->name; return $this->name;
...@@ -86,13 +114,23 @@ class Course ...@@ -86,13 +114,23 @@ class Course
$this->name = $name; $this->name = $name;
} }
public function getIdentifier(): string public function getType(): string
{ {
return $this->identifier; return $this->type;
} }
public function setIdentifier(string $identifier): void public function setType(string $type): void
{ {
$this->identifier = $identifier; $this->type = $type;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): void
{
$this->description = $description;
} }
} }
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Dbp\Relay\BasePersonBundle\Entity\PersonTrait;
/**
* @ApiResource(
* collectionOperations={
* "get_bycourse" = {
* "method" = "GET",
* "path" = "/courses/{id}/attendees",
* "controller" = GetStudentsByCourse::class,
* "read" = false,
* "openapi_context" = {
* "tags" = {"Courses"},
* "summary" = "Get the attendees attending to a course.",
* "parameters" = {
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"},
* {"name" = "id", "in" = "path", "description" = "Id of Organization", "required" = true, "type" = "string", "example" = "123456"}
* }
* },
* }
* },
* itemOperations={},
* iri="https://schema.org/EducationEvent",
* normalizationContext={"groups" = {"BasePerson:output"}, "jsonld_embed_context" = true},
* denormalizationContext={"groups" = {"BasePerson:input"}, "jsonld_embed_context" = true}
* )
*/
class CourseAttendee
{
use PersonTrait;
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use DateTime;
use DBP\API\CourseBundle\Controller\GetExamsByCourse;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* collectionOperations={
* "get_bycourse" = {
* "method" = "GET",
* "path" = "/courses/{id}/exams",
* "controller" = GetExamsByCourse::class,
* "read" = false,
* "openapi_context" = {
* "tags" = {"Courses"},
* "summary" = "Get the Exams for a course.",
* "parameters" = {
* {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"},
* {"name" = "id", "in" = "path", "description" = "Id of Organization", "required" = true, "type" = "string", "example" = "123456"}
* }
* },
* }
* },
* itemOperations={},
* iri="https://schema.org/EducationEvent",
* normalizationContext={"groups" = {"Exam:output"}, "jsonld_embed_context" = true},
* denormalizationContext={"groups" = {"Exam:input"}, "jsonld_embed_context" = true}
* )
*/
class Exam
{
/**
* @ApiProperty(identifier=true)
*
* @var string
*/
private $identifier;
/**
* @ApiProperty(iri="https://schema.org/description")
* @Groups({"Exam:output"})
*
* @var string
*/
private $description;
/**
* @ApiProperty(iri="https://schema.org/startDate")
* @Groups({"Exam:output"})
*
* @var DateTime
*/
private $startDate;
/**
* @ApiProperty(iri="https://schema.org/endDate")
* @Groups({"Exam:output"})
*
* @var DateTime
*/
private $endDate;
/**
* @ApiProperty(iri="https://schema.org/location")
* @Groups({"Exam:output"})
*
* @var string
*/
private $location;
public function getIdentifier(): string
{
return $this->identifier;
}
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): void
{
$this->description = $description;
}
public function getStartDate(): DateTime
{
return $this->startDate;
}
public function setStartDate(DateTime $startDate): void
{
$this->startDate = $startDate;
}
public function getEndDate(): DateTime
{
return $this->endDate;
}
public function setEndDate(DateTime $endDate): void
{
$this->endDate = $endDate;
}
public function getLocation(): string
{
return $this->location;
}
public function setLocation(string $location): void
{
$this->location = $location;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Service;
use Dbp\Relay\CourseBundle\Entity\Course;
interface CourseProviderInterface
{
public function getCourseById(string $identifier): ?Course;
public function getCourses(): array;
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Service;
use DateTime;
use Dbp\Relay\BasePersonBundle\Entity\Person;
use Dbp\Relay\CourseBundle\API\CourseProviderInterface;
use Dbp\Relay\CourseBundle\Entity\Course;
use Dbp\Relay\CourseBundle\Entity\Exam;
class DummyCourseProvider implements CourseProviderInterface
{
public function getCourseById(string $identifier, array $options = []): ?Course
{
$course = new Course();
$course->setIdentifier($identifier);
$course->setName('Field Theory');
$course->setDescription('News from field theory');
return $course;
}
public function getCourses(array $options = []): array
{
$course = $this->getCourseById('123', $options);
assert($course !== null);
return [$course];
}
public function getCoursesByOrganization(string $orgUnitId, array $options = []): array
{
return $this->getCourses($options);
}
public function getCoursesByPerson(string $personId, array $options = []): array
{
return $this->getCourses($options);
}
public function getStudentsByCourse(string $courseId, array $options = []): array
{
$person = new Person();
$person->setIdentifier('123');
$person->setFamilyName('Spencer');
$person->setGivenName('Bud');
$person->setEmail('bud@spencer.net');
$person->setBirthDate('1.1.1950');
return [$person];
}
public function getExamsByCourse(string $courseId, array $options = []): array
{
$exam = new Exam();
$exam->setIdentifier('123');
$exam->setDescription('Oral exam');
$exam->setStartDate(new DateTime('25.08.2021 8:00AM'));
$exam->setEndDate(new DateTime('25.08.2021 10:00AM'));
$exam->setLocation('In a room');
return [$exam];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment