Factory
Joomla Platform Factory class.
since |
1.7.0 |
---|---|
package |
Joomla CMS |
Methods
createConfig
Create a configuration object
createConfig(string file, string type = 'PHP', string namespace = '') : \Joomla\Registry\Registry
see | \Joomla\Registry\Registry |
---|---|
since |
1.7.0 |
deprecated |
5.0 Use the configuration object within the application. |
Arguments
- file
string
The path to the configuration file.- type
string
The type of the configuration file.- namespace
string
The namespace of the configuration file.
Response
\Joomla\Registry\Registry
createContainer
Create a container object
createContainer() : \Joomla\DI\Container
since |
4.0.0 |
---|
Response
\Joomla\DI\Container
createDbo
Create a database object
createDbo() : \Joomla\Database\DatabaseDriver
see | \Joomla\Database\DatabaseDriver |
---|---|
since |
1.7.0 |
deprecated |
5.0 Use the database service in the DI container |
Response
\Joomla\Database\DatabaseDriver
createDocument
Create a document object
createDocument() : \Joomla\CMS\Document\Document
see | Document |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the document service from the dependency injection container or via $app->getDocument() |
Response
\Joomla\CMS\Document\Document
object
createLanguage
Create a language object
createLanguage() : \Joomla\CMS\Language\Language
see | Language |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the language service from the dependency injection container or via $app->getLanguage() |
Response
\Joomla\CMS\Language\Language
object
createMailer
Create a mailer object
createMailer() : \Joomla\CMS\Mail\Mail
getApplication
Get the global application object. When the global application doesn't exist, an exception is thrown.
getApplication() : \Joomla\CMS\Application\CMSApplicationInterface
since |
1.7.0 |
---|---|
throws |
|
Response
\Joomla\CMS\Application\CMSApplicationInterface
object
getCache
Get a cache object
getCache(string group = '', string handler = 'callback', string storage = null) : \Joomla\CMS\Cache\CacheController
Returns the global {@link CacheController} object
see | Cache |
---|---|
since |
1.7.0 |
deprecated |
5.0 Use the cache controller factory instead |
Arguments
- group
string
The cache group name- handler
string
The handler to use- storage
string
The storage method
Response
\Joomla\CMS\Cache\CacheController
object
getConfig
Get a configuration object
getConfig(string file = null, string type = 'PHP', string namespace = '') : \Joomla\Registry\Registry
Returns the global {@link \JConfig} object, only creating it if it doesn't already exist.
see | \Joomla\Registry\Registry |
---|---|
since |
1.7.0 |
deprecated |
5.0 Use the configuration object within the application. |
Arguments
- file
string
The path to the configuration file- type
string
The type of the configuration file- namespace
string
The namespace of the configuration file
Response
\Joomla\Registry\Registry
getContainer
Get a container object
getContainer() : \Joomla\DI\Container
Returns the global service container object, only creating it if it doesn't already exist.
This method is only suggested for use in code whose responsibility is to create new services and needs to be able to resolve the dependencies, and should therefore only be used when the container is not accessible by other means. Valid uses of this method include:
- A static
getInstance()
method calling a factory service from the container, seeJoomla\CMS\Toolbar\Toolbar::getInstance()
as an example - An application front controller loading and executing the Joomla application class,
see the
cli/joomla.php
file as an example - Retrieving optional constructor dependencies when not injected into a class during a transitional period to retain backward compatibility, in this case a deprecation notice should also be emitted to notify developers of changes needed in their code
This method is not suggested for use as a one-for-one replacement of static calls, such as
replacing calls to Factory::getDbo()
with calls to Factory::getContainer()->get('db')
, code
should be refactored to support dependency injection instead of making this change.
since |
4.0.0 |
---|
Response
\Joomla\DI\Container
getDate
Return the {@link Date} object
getDate(mixed time = 'now', mixed tzOffset = null) : \Joomla\CMS\Date\Date
see | Date |
---|---|
since |
1.7.0 |
Arguments
- time
mixed
The initial time for the Date object- tzOffset
mixed
The timezone offset.
Response
\Joomla\CMS\Date\Date
object
getDbo
Get a database object.
getDbo() : \Joomla\Database\DatabaseDriver
Returns the global {@link DatabaseDriver} object, only creating it if it doesn't already exist.
see | \Joomla\Database\DatabaseDriver |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the database service from the dependency injection container |
Response
\Joomla\Database\DatabaseDriver
getDocument
Get a document object.
getDocument() : \Joomla\CMS\Document\Document
Returns the global {@link \Joomla\CMS\Document\Document} object, only creating it if it doesn't already exist.
see | Document |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the document service from the dependency injection container or via $app->getDocument() |
Response
\Joomla\CMS\Document\Document
object
getLanguage
Get a language object.
getLanguage() : \Joomla\CMS\Language\Language
Returns the global {@link Language} object, only creating it if it doesn't already exist.
see | Language |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the language service from the dependency injection container or via $app->getLanguage() |
Response
\Joomla\CMS\Language\Language
object
getMailer
Get a mailer object.
getMailer() : \Joomla\CMS\Mail\Mail
Returns the global {@link Mail} object, only creating it if it doesn't already exist.
see | |
---|---|
since |
1.7.0 |
Response
\Joomla\CMS\Mail\Mail
object
getSession
Get a session object.
getSession(array options = array()) : \Joomla\CMS\Session\Session
Returns the global {@link Session} object, only creating it if it doesn't already exist.
see | Session |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the session service from the dependency injection container or via $app->getSession() |
Arguments
- options
array
An array containing session options
Response
\Joomla\CMS\Session\Session
object
getStream
Creates a new stream object with appropriate prefix
getStream(bool usePrefix = true, bool useNetwork = true, string userAgentSuffix = 'Joomla', bool maskUserAgent = false) : \Joomla\CMS\Filesystem\Stream
see | Stream |
---|---|
since |
1.7.0 |
Arguments
- usePrefix
bool
Prefix the connections for writing- useNetwork
bool
Use network if available for writing; use false to disable (e.g. FTP, SCP)- userAgentSuffix
string
String to append to user agent- maskUserAgent
bool
User agent masking (prefix Mozilla)
Response
\Joomla\CMS\Filesystem\Stream
getUser
Get a user object.
getUser(int id = null) : \Joomla\CMS\User\User
Returns the global {@link User} object, only creating it if it doesn't already exist.
see | User |
---|---|
since |
1.7.0 |
deprecated |
5.0 Load the user service from the dependency injection container or via $app->getIdentity() |
Arguments
- id
int
The user to load - Can be an integer or string - If string, it is converted to ID automatically.
Response
\Joomla\CMS\User\User
object
Properties
config
Global configuration object
since |
1.7.0 |
---|---|
deprecated |
5.0 Use the configuration object within the application |
Type(s)
\JConfig
container
Global container object
since |
4.0.0 |
---|
Type(s)
\Joomla\DI\Container
session
Global session object
language
Global language object
document
Global document object
database
Global database object
since |
1.7.0 |
---|---|
deprecated |
5.0 Use the database service in the DI container |
Type(s)
\Joomla\Database\DatabaseDriver