Factory

Joomla Platform Factory class.

abstract
since

1.7.0

Methods

createConfig

Create a configuration object

createConfig(string $file, string $type = 'PHP', string $namespace = '') : \Joomla\Registry\Registry
static deprecated
see \Joomla\Registry\Registry
since

1.7.0

deprecated

5.0 Use the configuration object within the application.

Arguments

$file

stringThe path to the configuration file.

$type

stringThe type of the configuration file.

$namespace

stringThe namespace of the configuration file.

Response

\Joomla\Registry\Registry

createContainer

Create a container object

createContainer() : \Joomla\DI\Container
static
since

4.0.0

Response

\Joomla\DI\Container

createDbo

Create a database object

createDbo() : \Joomla\Database\DatabaseDriver
static deprecated
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
static deprecated
see \Joomla\CMS\Document\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\Documentobject

createLanguage

Create a language object

createLanguage() : \Joomla\CMS\Language\Language
static deprecated
see \Joomla\CMS\Language\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\Languageobject

createMailer

Create a mailer object

createMailer() : \Joomla\CMS\Mail\Mail
static
see \Joomla\CMS\Mail\Mail
since

1.7.0

Response

\Joomla\CMS\Mail\Mailobject

getApplication

Get the global application object. When the global application doesn't exist, an exception is thrown.

getApplication() : \Joomla\CMS\Application\CMSApplicationInterface
static
since

1.7.0

throws

\Exception

Response

\Joomla\CMS\Application\CMSApplicationInterfaceobject

getCache

Get a cache object

getCache(string $group = '', string $handler = 'callback', string $storage = null) : \Joomla\CMS\Cache\CacheController
static deprecated

Returns the global \Joomla\CMS\CacheController object

see \Joomla\CMS\Cache\Cache
since

1.7.0

deprecated

5.0 Use the cache controller factory instead

Arguments

$group

stringThe cache group name

$handler

stringThe handler to use

$storage

stringThe storage method

Response

\Joomla\CMS\Cache\CacheControllerobject

getConfig

Get a configuration object

getConfig(string $file = null, string $type = 'PHP', string $namespace = '') : \Joomla\Registry\Registry
static deprecated

Returns the global \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

stringThe path to the configuration file

$type

stringThe type of the configuration file

$namespace

stringThe namespace of the configuration file

Response

\Joomla\Registry\Registry

getContainer

Get a container object

getContainer() : \Joomla\DI\Container
static

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, see Joomla\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
static
see \Joomla\CMS\Date\Date
since

1.7.0

Arguments

$time

mixedThe initial time for the Date object

$tzOffset

mixedThe timezone offset.

Response

\Joomla\CMS\Date\Dateobject

getDbo

Get a database object.

getDbo() : \Joomla\Database\DatabaseDriver
static deprecated

Returns the global \Joomla\Database\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
static deprecated

Returns the global \Joomla\CMS\Document\Document object, only creating it if it doesn't already exist.

see \Joomla\CMS\Document\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\Documentobject

getLanguage

Get a language object.

getLanguage() : \Joomla\CMS\Language\Language
static deprecated

Returns the global Language object, only creating it if it doesn't already exist.

see \Joomla\CMS\Language\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\Languageobject

getMailer

Get a mailer object.

getMailer() : \Joomla\CMS\Mail\Mail
static

Returns the global Mail object, only creating it if it doesn't already exist.

see \Joomla\CMS\Mail\Mail
since

1.7.0

Response

\Joomla\CMS\Mail\Mailobject

getSession

Get a session object.

getSession(array $options = array()) : \Joomla\CMS\Session\Session
static deprecated

Returns the global Session object, only creating it if it doesn't already exist.

see \Joomla\CMS\Session\Session
since

1.7.0

deprecated

5.0 Load the session service from the dependency injection container or via $app->getSession()

Arguments

$options

arrayAn array containing session options

Response

\Joomla\CMS\Session\Sessionobject

getStream

Creates a new stream object with appropriate prefix

getStream(boolean $usePrefix = true, boolean $useNetwork = true, string $userAgentSuffix = 'Joomla', boolean $maskUserAgent = false) : \Joomla\CMS\Filesystem\Stream
static
see \Joomla\CMS\Filesystem\Stream
since

1.7.0

Arguments

$usePrefix

booleanPrefix the connections for writing

$useNetwork

booleanUse network if available for writing; use false to disable (e.g. FTP, SCP)

$userAgentSuffix

stringString to append to user agent

$maskUserAgent

booleanUser agent masking (prefix Mozilla)

Response

\Joomla\CMS\Filesystem\Stream

getUser

Get a user object.

getUser(integer $id = null) : \Joomla\CMS\User\User
static deprecated

Returns the global User object, only creating it if it doesn't already exist.

see \Joomla\CMS\User\User
since

1.7.0

deprecated

5.0 Load the user service from the dependency injection container or via $app->getIdentity()

Arguments

$id

integerThe user to load - Can be an integer or string - If string, it is converted to ID automatically.

Response

\Joomla\CMS\User\Userobject

Properties

application

Global application object

static

cache

Global cache object

static
since

1.7.0

Type(s)

\Joomla\CMS\Cache\Cache

config

Global configuration object

static deprecated
since

1.7.0

deprecated

5.0 Use the configuration object within the application

Type(s)

\JConfig

container

Global container object

static
since

4.0.0

Type(s)

\Joomla\DI\Container

dates

Container for Date instances

static
since

1.7.3

Type(s)

array

session

Global session object

static deprecated
since

1.7.0

deprecated

5.0 Use the session service in the DI container

Type(s)

\Joomla\CMS\Session\Session

language

Global language object

static deprecated
since

1.7.0

deprecated

5.0 Use the language service in the DI container

Type(s)

\Joomla\CMS\Language\Language

document

Global document object

static deprecated
since

1.7.0

deprecated

5.0 Use the document service in the DI container

Type(s)

\Joomla\CMS\Document\Document

database

Global database object

static deprecated
since

1.7.0

deprecated

5.0 Use the database service in the DI container

Type(s)

\Joomla\Database\DatabaseDriver

mailer

Global mailer object

static
since

1.7.0

Type(s)

\Joomla\CMS\Mail\Mail