JsonApiView
Extends JsonViewBase class for a Joomla Json List View
Class holding methods for displaying presentation data.
since |
4.0.0 |
---|---|
package |
Joomla CMS |
Methods
__construct
Constructor.
__construct(mixed||string|int config = []) :
since |
4.0.0 |
---|
Arguments
- config
array<string|int, mixed>
A named configuration array for object construction. contentType: the name (optional) of the content type to use for the serialization
Response
mixed
__toString
Magic method to convert the object to a string gracefully.
__toString() :
since |
1.7.0 |
---|---|
deprecated |
4.3 will be removed in 6.0 Classes should provide their own __toString() implementation. |
Response
string
The classname.
def
Sets a default value if not already assigned
def( property, default = null) :
since |
1.7.0 |
---|---|
deprecated |
4.3.0 will be removed in 6.0 Defining dynamic properties should not be used anymore |
Arguments
- property
string
The name of the property.- default
mixed
The default value.
Response
mixed
dispatchEvent
Dispatches the given event on the internal dispatcher, does a fallback to the global one.
dispatchEvent(\Joomla\Event\EventInterface event) :
since |
4.1.0 |
---|---|
deprecated |
4.4 will be removed in 6.0. Use $this->getDispatcher() directly. |
Arguments
- event
EventInterface
The event
Response
void
display
Execute and display a template script.
display( tpl = null) :
since |
4.0.0 |
---|
Arguments
- tpl
string
The name of the template file to parse; automatically searches through the template paths.
Response
void
displayItem
Execute and display a template script.
displayItem( item = null) :
since |
4.0.0 |
---|
Arguments
- item
object
Item
Response
string
displayList
Execute and display a template script.
displayList(array|null items = null) :
since |
4.0.0 |
---|
Arguments
- items
array<string|int, mixed>|null
Array of items
Response
string
get
Method to get data from a registered model or a property of the view
get( property, default = null) :
since |
3.0 |
---|
Arguments
- property
string
The name of the method to call on the model or the property to get- default
string
The name of the model to reference or the default value [optional]
Response
mixed
The return value of the method
getDispatcher
Get the event dispatcher.
getDispatcher() : \Joomla\Event\DispatcherInterface
The override was made to keep a backward compatibility for legacy component. TODO: Remove the override in 6.0
since |
4.4.0 |
---|---|
throws |
|
Response
DispatcherInterface
getDocument
Get the Document.
getDocument() : \Joomla\CMS\Document\Document
since |
4.4.0 |
---|---|
throws |
|
Response
getError
Get the most recent error message.
getError( i = null, toString = true) :
since |
1.7.0 |
---|---|
deprecated |
3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getError |
Arguments
- i
int
Option error index.- toString
bool
Indicates if Exception objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : mixed||string|int
since |
1.7.0 |
---|---|
deprecated |
3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getErrors |
Response
array<string|int, mixed>
Array of error messages.
getLanguage
Get the Language.
getLanguage() : \Joomla\CMS\Language\Language
since |
4.4.0 |
---|---|
throws |
|
Response
getModel
Method to get the model object
getModel( name = null) : \Joomla\CMS\MVC\Model\BaseDatabaseModel
since |
3.0 |
---|
Arguments
- name
string
The name of the model (optional)
Response
BaseDatabaseModel
The model object
getName
Method to get the view name
getName() :
The model name by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor
since |
3.0 |
---|---|
throws |
|
Response
string
The name of the model
getProperties
Returns an associative array of object properties.
getProperties( public = true) : mixed||string|int
since |
1.7.0 |
---|---|
see | CMSObject::get() |
deprecated |
4.3.0 will be removed in 6.0 Create a proper getter function for the property |
Arguments
- public
bool
If true, returns only the public properties.
Response
array<string|int, mixed>
prepareItem
Prepare item before render.
prepareItem( item) :
since |
4.0.0 |
---|
Arguments
- item
object
The model item
Response
object
queryEncode
Encode square brackets in the URI query, according to JSON API specification.
queryEncode( query) :
since |
4.0.0 |
---|
Arguments
- query
string
The URI query
Response
string
set
Modifies a property of the object, creating it if it does not already exist.
set( property, value = null) :
since |
1.7.0 |
---|---|
deprecated |
4.3.0 will be removed in 6.0 Create a proper setter function for the property |
Arguments
- property
string
The name of the property.- value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setDocument
Set the document to use.
setDocument(\Joomla\CMS\Document\Document document) :
setError
Add an error message.
setError( error) :
since |
1.7.0 |
---|---|
deprecated |
3.1.4 will be removed in 6.0 Will be removed without replacement Throw an Exception instead of using setError |
Arguments
- error
string
Error message.
Response
void
setLanguage
Set the language to use.
setLanguage(\Joomla\CMS\Language\Language language) :
setModel
Method to add a model to the view. We support a multiple model single view system by which models are referenced by classname. A caveat to the classname referencing is that any classname prepended by \JModel will be referenced by the name without \JModel, eg. \JModelCategory is just Category.
setModel(\Joomla\CMS\MVC\Model\BaseDatabaseModel model, default = false) : \Joomla\CMS\MVC\Model\BaseDatabaseModel
since |
3.0 |
---|
Arguments
- model
BaseDatabaseModel
The model to add to the view.- default
bool
Is this the default model?
Response
BaseDatabaseModel
The added model.
setProperties
Set the object properties based on a named array/hash.
setProperties( properties) :
since |
1.7.0 |
---|---|
see | CMSObject::set() |
deprecated |
4.3.0 will be removed in 6.0 Create a proper setter function for the property |
Arguments
- properties
mixed
Either an associative array or another object.
Response
bool
Properties
_errors
An array of error messages or Exception objects.
since |
1.7.0 |
---|---|
deprecated |
3.1.4 JError has been deprecated |
Type(s)
array<string|int, mixed>
option
The URL option for the component. It is usually passed by controller while it creates the view
since |
3.0 |
---|
Type(s)
string
_name
The name of the view
since |
3.0 |
---|
Type(s)
string
_models
Registered models
since |
3.0 |
---|
Type(s)
array<string|int, mixed>
_defaultModel
The default model
since |
3.0 |
---|
Type(s)
string
_basePath
The base path of the view
since |
4.0.0 |
---|
Type(s)
string
_charset
Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
since |
4.0.0 |
---|
Type(s)
string
_output
The output of the view.
since |
4.0.0 |
---|
Type(s)
array<string|int, mixed>
type
The content type
Type(s)
string
relationship
Item relationship
since |
4.0.0 |
---|
Type(s)
array<string|int, mixed>
serializer
Serializer data
since |
4.0.0 |
---|
Type(s)
AbstractSerializer
fieldsToRenderItem
The fields to render item in the documents
since |
4.0.0 |
---|
Type(s)
array<string|int, mixed>
fieldsToRenderList
The fields to render items in the documents
since |
4.0.0 |
---|
Type(s)
array<string|int, mixed>