Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
JsonApiController Class Reference
Inheritance diagram for JsonApiController:
ActivityStreamShow CommentsByThreadIndex CommentsCreate CommentsDelete CommentsIndex CommentsShow CommentsUpdate ThreadsCreate ThreadsIndex ThreadsShow 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 ContainersCreate ContainersDelete ContainersIndex ContainersShow ContainersUpdate 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 TaskGroupsShow TasksDelete TasksIndex TasksShow TasksUpdate TemplatesCreate TemplatesDelete TemplatesIndex TemplatesShow TemplatesUpdate UserDataFieldOfBlocksShow UserDataFieldsShow UserDataFieldsUpdate UserProgressesShow UserProgressesUpdate UserProgressOfBlocksShow UsersBookmarkedStructuralElementsIndex DiscoveryIndex CourseEventsIndex UserEventsIndex FeedbackElementsByCourseIndex FeedbackElementsByFileRefIndex FeedbackElementsByFolderIndex FeedbackElementsShow FeedbackEntriesIndex FeedbackEntriesShow 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 InstitutesIndex InstitutesShow StatusGroupsOfInstitutes BoxController MessageCreate MessageDelete MessageShow MessageUpdate AbstractNewsCreate ByCourseIndex ByCurrentUser ByUserIndex CommentCreate CommentsDelete CommentsIndex CommentsShow GlobalNewsShow NewsDelete NewsShow NewsUpdate RelationshipsController ScheduleEntriesShow SeminarCycleDatesShow UserScheduleShow SemestersIndex SemestersShow PropertiesIndex ChildrenOfStudyAreas CoursesOfStudyAreas InstituteOfStudyAreas ParentOfStudyAreas StudyAreasIndex StudyAreasShow 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 ( \Slim\App  $app,
ContainerInterface  $container,
FactoryInterface  $factory,
EncoderInterface  $encoder,
SchemaContainerInterface  $schemaContainer,
QueryParserInterface  $queryParser,
HeaderParametersParserInterface  $headerParametersParser 
)

Der Konstruktor.

Member Function Documentation

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

Get response with HTTP code only.

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 (   $resource,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected
Parameters
object$resource
array | null$links
mixed$meta
getIdentifiersResponse (   $data,
  $links = [],
  $meta = [],
array  $headers = [] 
)
protected

Get response with only resource identifiers.

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

Get response with meta information only.

Parameters
array | object$metaMeta information
int$statusCode
getOffsetAndLimit (   $offsetDefault = 0,
  $limitDefault = 30 
)
protected
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 (   $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 ( )
protected
getResponses ( array  $links = [],
array  $meta = [] 
)
protected
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 ( 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 = null
protected
$allowedFilteringParameters = []
protected
$allowedIncludePaths = []
protected
$allowedPagingParameters = []
protected
$allowedSortFields = []
protected
$allowUnrecognizedParams = false
protected
$app
protected
$container
protected
$encoder
protected
$factory
protected
$queryParser
protected
$schemaContainer
protected

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