22
33namespace Pdsinterop \Solid \Controller \Profile ;
44
5- use League \Flysystem \FilesystemInterface ;
65use League \Route \Http \Exception \NotFoundException ;
76use Pdsinterop \Rdf \Enum \Format ;
87use Pdsinterop \Solid \Controller \AbstractController ;
8+ use Pdsinterop \Solid \Traits \HasFilesystemTrait ;
99use Psr \Http \Message \ServerRequestInterface ;
1010use Psr \Http \Message \ResponseInterface ;
1111
1212class CardController extends AbstractController
1313{
1414 ////////////////////////////// CLASS PROPERTIES \\\\\\\\\\\\\\\\\\\\\\\\\\\\
1515
16- /** @var FilesystemInterface $filesystem */
17- private $ filesystem ;
18-
19- //////////////////////////// GETTERS AND SETTERS \\\\\\\\\\\\\\\\\\\\\\\\\\\
16+ use HasFilesystemTrait;
2017
2118 //////////////////////////////// PUBLIC API \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
2219
23- /**
24- * CardController constructor.
25- *
26- * @param ResponseInterface $response
27- * @param FilesystemInterface $filesystem
28- */
29- final public function __construct (
30- ResponseInterface $ response ,
31- FilesystemInterface $ filesystem
32- ) {
33- $ this ->filesystem = $ filesystem ;
34-
35- parent ::__construct ($ response );
36- }
37-
3820 /**
3921 * @param ServerRequestInterface $request
4022 * @param array $args
@@ -45,8 +27,14 @@ final public function __construct(
4527 */
4628 final public function __invoke (ServerRequestInterface $ request , array $ args ): ResponseInterface
4729 {
30+ // @FIXME: Target file is hard-coded for not, replace with path from $request->getRequestTarget()
31+ $ filePath = '/foaf.rdf ' ;
32+ $ filesystem = $ this ->getFilesystem ();
4833 $ extension = '.ttl ' ;
4934
35+ // @TODO: Content negotiation from Accept headers
36+ //$format = $request->getHeader('Accept');
37+
5038 if (array_key_exists ('extension ' , $ args )) {
5139 $ extension = $ args ['extension ' ];
5240 }
@@ -59,11 +47,8 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
5947
6048 $ contentType = $ this ->getContentTypeForFormat ($ format );
6149
62- // @FIXME: Target file is hard-coded for not, replace with path from $request->getRequestTarget()
63- $ filePath = '/foaf.rdf ' ;
64-
6550 /** @noinspection PhpUndefinedMethodInspection */ // Method `readRdf` is defined by plugin
66- $ content = $ this -> filesystem ->readRdf ($ filePath , $ format );
51+ $ content = $ filesystem ->readRdf ($ filePath , $ format );
6752
6853 return $ this ->createTextResponse ($ content )->withHeader ('Content-Type ' , $ contentType );
6954 }
0 commit comments