Implement GetObjectController

This commit is contained in:
Jeremy Dormitzer 2019-01-09 08:48:53 -05:00
parent a0bc35d692
commit 07405846a6

View File

@ -2,13 +2,18 @@
namespace ActivityPub\Controllers;
use ActivityPub\Objects\ObjectsService;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* The GetObjectController is responsible for rendering ActivityPub objects as JSON
*/
class GetObjectController
{
/**
* @var ObjectsService
*/
private $objectsService;
public function __construct( ObjectsService $objectsService )
@ -24,7 +29,12 @@ class GetObjectController
*/
public function handle( Request $request )
{
// TODO implement me
$uri = $request->getUri();
$object = $this->objectsService->getObject( $uri );
if ( ! $object ) {
throw new NotFoundHttpException();
}
return new JsonResponse( $object->asArray() );
}
}
?>