Stud.IP  5.4
JsonApiController Class Reference
Inheritance diagram for JsonApiController:
ActivityStreamShow CommentsByThreadIndex CommentsCreate CommentsDelete CommentsIndex CommentsShow CommentsUpdate ThreadsCreate ThreadsIndex ThreadsShow ThreadsUpdate ByUserIndex ConfigValuesShow ConfigValuesUpdate BlocksByRangeIndex BlockShow BookingsBySlotIndex BookingsCreate BookingsDelete BookingsShow SlotsByBlockIndex SlotShow ByUserIndex CourseMembershipsShow CourseMembershipsUpdate CoursesByUserIndex CoursesIndex CoursesMembershipsIndex CoursesShow SemClassesIndex SemClassesShow SemTypesBySemClassIndex SemTypesIndex SemTypesShow StatusGroupsOfCourses BlockCommentsCreate BlockCommentsDelete BlockCommentsOfBlocksIndex BlockCommentsShow BlockCommentsUpdate BlockFeedbacksCreate BlockFeedbacksDelete BlockFeedbacksOfBlocksIndex BlockFeedbacksShow BlockFeedbacksUpdate BlocksCreate BlocksDelete BlocksIndex BlocksListFiles BlocksShow BlocksUpdate BookmarkedStructuralElementsIndex ChildrenOfStructuralElementsIndex ClipboardsCreate ClipboardsDelete ClipboardsIndex ClipboardsShow ClipboardsUpdate ContainersCreate ContainersDelete ContainersIndex ContainersShow ContainersUpdate CoursesUnitsIndex CoursewareInstancesShow CoursewareInstancesUpdate DescendantsOfStructuralElementsIndex PublicLinksCreate PublicLinksDelete PublicLinksIndex PublicLinksShow PublicLinksUpdate PublicStructuralElementsIndex PublicStructuralElementsShow StructuralElementCommentsCreate StructuralElementCommentsDelete StructuralElementCommentsOfStructuralElementsIndex StructuralElementCommentsShow StructuralElementCommentsUpdate StructuralElementFeedbackCreate StructuralElementFeedbackDelete StructuralElementFeedbackOfStructuralElementsIndex StructuralElementFeedbackShow StructuralElementFeedbackUpdate StructuralElementsCreate StructuralElementsDelete StructuralElementsIndex StructuralElementsReleasedIndex StructuralElementsSharedIndex StructuralElementsShow StructuralElementsUpdate TaskFeedbackCreate TaskFeedbackDelete TaskFeedbackShow TaskFeedbackUpdate TaskGroupsCreate TaskGroupsDelete TaskGroupsShow TaskGroupsUpdate TasksDelete TasksIndex TasksShow TasksUpdate TemplatesCreate TemplatesDelete TemplatesIndex TemplatesShow TemplatesUpdate UnitsCreate UnitsDelete UnitsIndex UnitsShow UnitsSort UnitsUpdate UserDataFieldOfBlocksShow UserDataFieldsShow UserDataFieldsUpdate UserProgressesShow UserProgressesUpdate UserProgressOfBlocksShow UsersBookmarkedStructuralElementsIndex UsersClipboardsDelete UsersClipboardsIndex UsersUnitsIndex DiscoveryIndex CourseEventsIndex UserEventsIndex FeedbackElementsByCourseIndex FeedbackElementsByFileRefIndex FeedbackElementsByFolderIndex FeedbackElementsCreate FeedbackElementsDelete FeedbackElementsShow FeedbackElementsUpdate FeedbackEntriesCreate FeedbackEntriesDelete FeedbackEntriesIndex FeedbackEntriesShow FeedbackEntriesUpdate AbstractRangeIndex FileRefsCreate FileRefsDelete FileRefsOfFilesShow FileRefsShow FileRefsUpdate FilesShow FoldersDelete FoldersShow FoldersUpdate RangeFileRefsCreate RangeFoldersCreate SubfilerefsIndex SubfoldersIndex TermsOfUseIndex TermsOfUseShow AbstractEntriesCreate ForumCategoriesCreate ForumCategoriesDelete ForumCategoriesIndex ForumCategoriesShow ForumCategoriesUpdate ForumCategoryEntriesIndex ForumEntriesDelete ForumEntriesShow ForumEntriesUpdate ForumEntryEntriesIndex ByUserIndex InstituteMembershipsShow InstituteMembershipsIndex InstitutesIndex InstitutesShow StatusGroupsOfInstitutes LtiToolsIndex LtiToolsShow BoxController MessageCreate MessageDelete MessageShow MessageUpdate AbstractNewsCreate ByCourseIndex ByCurrentUser ByUserIndex CommentCreate CommentsDelete CommentsIndex CommentsShow GlobalNewsShow NewsDelete NewsShow NewsUpdate ChildrenOfRangeTreeNode CoursesOfRangeTreeNode InstituteOfRangeTreeNode ParentOfRangeTreeNode RangeTreeIndex RangeTreeShow RelationshipsController ScheduleEntriesShow SeminarCycleDatesShow UserScheduleShow SemestersIndex SemestersShow StatusgroupShow StockImagesCreate StockImagesDelete StockImagesIndex StockImagesShow StockImagesUpdate PropertiesIndex ChildrenOfStudyAreas CoursesOfStudyAreas InstituteOfStudyAreas ParentOfStudyAreas StudyAreasIndex StudyAreasShow ChildrenOfTreeNode CoursesOfTreeNode TreeShow ContactsIndex UsersDelete UsersIndex UsersShow ChildrenIndex DescendantsIndex WikiCreate WikiDelete WikiIndex WikiShow WikiUpdate

Public Member Functions

 __construct (\Slim\App $app, ContainerInterface $container, FactoryInterface $factory, EncoderInterface $encoder, SchemaContainerInterface $schemaContainer, QueryParserInterface $queryParser, HeaderParametersParserInterface $headerParametersParser)
 
 getUser (Request $request)
 

Protected Member Functions

 getCodeResponse (int $statusCode, array $headers=[])
 
 getMetaResponse ($meta, $statusCode=ResponsesInterface::HTTP_OK, array $headers=[])
 
 getContentResponse ( $data, $statusCode=ResponsesInterface::HTTP_OK, $links=[], $meta=[], array $headers=[])
 
 getIdentifiersResponse ($data, $links=[], $meta=[], array $headers=[])
 
 getPaginatedIdentifiersResponse ( $data, $total, $links=[], $meta=[], array $headers=[])
 
 getCreatedResponse ($resource, $links=[], $meta=[], array $headers=[])
 
 getPaginatedContentResponse ( $data, $total, $statusCode=ResponsesInterface::HTTP_OK, $links=[], $meta=[], array $headers=[])
 
 getQueryParameters ()
 
 getOffsetAndLimit ($offsetDefault=0, $limitDefault=30)
 
 getSchema ($resource)
 
 getResponses (array $links=[], array $meta=[])
 

Protected Attributes

 $app
 
 $container
 
 $factory
 
 $encoder
 
 $schemaContainer
 
 $queryParser
 
 $allowUnrecognizedParams = false
 
 $allowedIncludePaths = []
 
 $allowedFieldSetTypes = null
 
 $allowedSortFields = []
 
 $allowedPagingParameters = []
 
 $allowedFilteringParameters = []
 

Detailed Description

Ein JsonApiController ist die einfachste Möglichkeit, eine eigene JSON-API-Route zu erstellen.

Dazu erstellt man eine Unterklasse von JsonApiController und kann darin __invoke oder andere Methoden definieren und diese in der RouteMap registrieren.

Wenn man auf den JsonApiController verzichten möchte, muss man den JsonApiTrait in seiner eigenen Lösung einbinden und außerdem den Dependency Container als Instanzvariabel $this->container eintragen und die Methode JsonApiTrait::initJsonApiSupport aufrufen.

Diese Klasse hier übernimmt all diese Aufgaben selbst.

See also

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Slim\App  $app,
ContainerInterface  $container,
FactoryInterface  $factory,
EncoderInterface  $encoder,
SchemaContainerInterface  $schemaContainer,
QueryParserInterface  $queryParser,
HeaderParametersParserInterface  $headerParametersParser 
)

Der Konstruktor.

Member Function Documentation

◆ getCodeResponse()

getCodeResponse ( int  $statusCode,
array  $headers = [] 
)
protected

Get response with HTTP code only.

◆ getContentResponse()

getContentResponse (   $data,
  $statusCode = ResponsesInterface::HTTP_OK,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected

Get response with regular JSON API Document in body.

Parameters
object | array$data
int$statusCode
array | null$links
mixed$meta

◆ getCreatedResponse()

getCreatedResponse (   $resource,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected
Parameters
object$resource
array | null$links
mixed$meta

◆ getIdentifiersResponse()

getIdentifiersResponse (   $data,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected

Get response with only resource identifiers.

Parameters
object | array$data
array | null$links
mixed$meta

◆ getMetaResponse()

getMetaResponse (   $meta,
  $statusCode = ResponsesInterface::HTTP_OK,
array  $headers = [] 
)
protected

Get response with meta information only.

Parameters
array | object$metaMeta information
int$statusCode

◆ getOffsetAndLimit()

getOffsetAndLimit (   $offsetDefault = 0,
  $limitDefault = 30 
)
protected

◆ getPaginatedContentResponse()

getPaginatedContentResponse (   $data,
  $total,
  $statusCode = ResponsesInterface::HTTP_OK,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected
Parameters
object | array$data
?int$total
int$statusCode
array | null$links
mixed$meta

◆ getPaginatedIdentifiersResponse()

getPaginatedIdentifiersResponse (   $data,
  $total,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected

Get response with paginated resource identifiers.

Parameters
object | array$data
?int$total
array | null$links
mixed$meta

◆ getQueryParameters()

getQueryParameters ( )
protected

◆ getResponses()

getResponses ( array  $links = [],
array  $meta = [] 
)
protected

◆ getSchema()

getSchema (   $resource)
protected

Gibt das Schema zu einer beliebigen Ressource zurück.

Parameters
mixed$resourcedie Ressource, zu der das Schema geliefert werden soll
Returns
SchemaInterface das Schema zur Ressource

◆ getUser()

getUser ( Request  $request)

Gibt null oder das User-Objekt des "eingeloggten" Nutzers zurück.

Parameters
Request$requestRequest der eingehende Request
Returns
mixed entweder null oder das User-Objekt des "eingeloggten" Nutzers

Field Documentation

◆ $allowedFieldSetTypes

$allowedFieldSetTypes = null
protected

◆ $allowedFilteringParameters

$allowedFilteringParameters = []
protected

◆ $allowedIncludePaths

$allowedIncludePaths = []
protected

◆ $allowedPagingParameters

$allowedPagingParameters = []
protected

◆ $allowedSortFields

$allowedSortFields = []
protected

◆ $allowUnrecognizedParams

$allowUnrecognizedParams = false
protected

◆ $app

$app
protected

◆ $container

$container
protected

◆ $encoder

$encoder
protected

◆ $factory

$factory
protected

◆ $queryParser

$queryParser
protected

◆ $schemaContainer

$schemaContainer
protected

The documentation for this class was generated from the following file: