Abstract Class FOFPlatform

Description

Implements interfaces:

Part of the FOF Platform Abstraction Layer. It implements everything that depends on the platform FOF is running under, e.g. the Joomla! CMS front-end, the Joomla! CMS back-end, a CLI Joomla! Platform app, a bespoke Joomla! Platform / Framework web application and so on.

This is the abstract class implementing some basic housekeeping functionality and provides the static interface to get the appropriate Platform object for use in the rest of the framework.

  • abstract:
  • since: 2.1

Located in /libraries/fof/platform/platform.php (line 24)


	
			
Direct descendents
Class Description
 class FOFPlatformJoomla Part of the FOF Platform Abstraction Layer.
Variable Summary
 static array $paths
 boolean $isEnabled
 integer $ordering
Method Summary
 static void forceInstance (FOFPlatformInterface|null $instance)
 static void registerPlatformPath (string $path)
 static void unregisterPlatformPath (string $path)
 boolean authorise (string $action, string $assetname)
 boolean authorizeAdmin (string $component)
 boolean checkVersion (string $version1, string $version2, string $operator)
 boolean clearCache ()
 string getCache (string $key, [string $default = null])
 array getComponentBaseDirs (string $component)
 integer getOrdering ()
 string getTemplateOverridePath (string $component, [boolean $absolute = true])
 JDocument getUser ([integer $id = null])
 mixed getUserStateFromRequest (string $key, string $request, FOFInput $input, [mixed $default = null], [string $type = 'none'], [boolean $setUserState = true])
 array getViewTemplatePaths (string $component, string $view, [string $layout = 'default'], [string $tpl = null], [boolean $strict = false])
 void importPlugin (string $type)
 boolean isBackend ()
 boolean isCli ()
 boolean isEnabled ()
 boolean isFrontend ()
 void loadTranslations (string $component)
 boolean loginUser (array $authInfo)
 boolean logoutUser ()
 array runPlugins (string $event, array $data)
 boolean setCache (string $key, string $content)
 void setErrorHandling (integer $level, string $log_level, [array $options = array()])
Variables
static FOFPlatformInterface $instance = null (line 54)

The platform class instance which will be returned by getInstance

  • access: protected
static array $paths = array() (line 47)

The list of paths where platform class files will be looked for

  • access: protected
boolean $isEnabled = null (line 40)

Caches the enabled status of this platform class.

  • access: protected
integer $ordering = 100 (line 33)

The ordering for this platform class. The lower this number is, the more important this class becomes. Most important enabled class ends up being used.

  • access: public
Methods
static forceInstance (line 115)

Force a specific platform object to be used. If null, nukes the cache

  • access: public
static void forceInstance (FOFPlatformInterface|null $instance)
static getInstance (line 128)

Find and return the most relevant platform object

  • access: public
static FOFPlatformInterface getInstance ()
static registerPlatformPath (line 81)

Register a path where platform files will be looked for. These take precedence over the built-in platform files.

  • access: public
static void registerPlatformPath (string $path)
  • string $path: The path to add
static unregisterPlatformPath (line 97)

Unregister a path where platform files will be looked for.

  • access: public
static void unregisterPlatformPath (string $path)
  • string $path: The path to remove
authorise (line 428)

Perform an ACL check.

boolean authorise (string $action, string $assetname)
  • string $action: The ACL privilege to check, e.g. core.edit
  • string $assetname: The asset name to check, typically the component's name

Implementation of:
FOFPlatformInterface::authorise()
Perform an ACL check. Please note that FOF uses by default the Joomla! CMS convention for ACL privileges, e.g core.edit for the edit privilege.

Redefined in descendants as:
authorizeAdmin (line 338)

Authorise access to the component in the back-end.

boolean authorizeAdmin (string $component)
  • string $component: The name of the component.

Implementation of:
FOFPlatformInterface::authorizeAdmin()
By default FOF will only use the Controller's onBefore* methods to

Redefined in descendants as:
checkVersion (line 492)

Performs a check between two versions. Use this function instead of PHP version_compare so we can mock it while testing

  • access: public
boolean checkVersion (string $version1, string $version2, string $operator)
  • string $version1: First version number
  • string $version2: Second version number
  • string $operator: Operator (see version_compare for valid operators)

Implementation of:
FOFPlatformInterface::checkVersion()
Performs a check between two versions. Use this function instead of PHP version_compare so we can mock it while testing
clearCache (line 544)

Clears the cache of system-wide FOF data. You are supposed to call this in

your components' installation script post-installation and post-upgrade methods or whenever you are modifying the structure of database tables accessed by FOF. Please note that FOF's cache never expires and is not purged by Joomla!. You MUST use this method to manually purge the cache.

  • return: True on success
  • access: public
boolean clearCache ()

Implementation of:
FOFPlatformInterface::clearCache()
Clears the cache of system-wide FOF data. You are supposed to call this in

Redefined in descendants as:
getCache (line 520)

Retrieves data from the cache. This is supposed to be used for system-side FOF data, not application data.

  • return: The cached value
  • access: public
string getCache (string $key, [string $default = null])
  • string $key: The key of the data to retrieve
  • string $default: The default value to return if the key is not found or the cache is not populated

Implementation of:
FOFPlatformInterface::getCache()
Retrieves data from the cache. This is supposed to be used for system-side FOF data, not application data.

Redefined in descendants as:
getComponentBaseDirs (line 254)

Returns the base (root) directories for a given component.

array getComponentBaseDirs (string $component)
  • string $component: The name of the component. For Joomla! this is something like "com_example"

Implementation of:
FOFPlatformInterface::getComponentBaseDirs()
Returns the base (root) directories for a given component. The "component" is used in the sense of what we call "component" in Joomla!, "plugin" in WordPress and "module" in Drupal, i.e. an application which is running inside our main application (CMS).

Redefined in descendants as:
getDocument (line 364)

Returns the JDocument object which handles this component's response.

JDocument getDocument ()

Implementation of:
FOFPlatformInterface::getDocument()
Returns the JDocument object which handles this component's response. You may also return null and FOF will a. try to figure out the output type by examining the "format" input parameter (or fall back to "html") and b.

Redefined in descendants as:
getOrdering (line 222)

Returns the ordering of the platform class.

integer getOrdering ()

Implementation of:
FOFPlatformInterface::getOrdering()
Returns the ordering of the platform class. Files with a lower ordering number will be loaded first.
getTemplateOverridePath (line 309)

Return the absolute path to the application's template overrides directory for a specific component. We will use it to look for template files instead of the regular component directorues. If the application does not have such a thing as template overrides return an empty string.

  • return: The path to the template overrides directory
  • access: public
string getTemplateOverridePath (string $component, [boolean $absolute = true])
  • string $component: The name of the component for which to fetch the overrides
  • boolean $absolute: Should I return an absolute or relative path?

Implementation of:
FOFPlatformInterface::getTemplateOverridePath()
Return the absolute path to the application's template overrides directory for a specific component. We will use it to look for template files instead of the regular component directorues. If the application does not have such a thing as template overrides return an empty string.

Redefined in descendants as:
  • FOFPlatformJoomla::getTemplateOverridePath() : Return the absolute path to the application's template overrides directory for a specific component. We will use it to look for template files instead of the regular component directorues. If the application does not have such a thing as template overrides return an empty string.
getTemplateSuffixes (line 293)

Get application-specific suffixes to use with template paths. This allows you to look for view template overrides based on the application version.

  • return: A plain array of suffixes to try in template names
  • access: public
array getTemplateSuffixes ()

Implementation of:
FOFPlatformInterface::getTemplateSuffixes()
Get application-specific suffixes to use with template paths. This allows you to look for view template overrides based on the application version.

Redefined in descendants as:
getUser (line 352)

Returns the JUser object for the current user

JDocument getUser ([integer $id = null])
  • integer $id: The ID of the user to fetch

Implementation of:
FOFPlatformInterface::getUser()
Returns a user object.

Redefined in descendants as:
getUserStateFromRequest (line 383)

This method will try retrieving a variable from the request (input) data.

mixed getUserStateFromRequest (string $key, string $request, FOFInput $input, [mixed $default = null], [string $type = 'none'], [boolean $setUserState = true])
  • string $key: The user state key for the variable
  • string $request: The request variable name for the variable
  • FOFInput $input: The FOFInput object with the request (input) data
  • mixed $default: The default value. Default: null
  • string $type: The filter type for the variable data. Default: none (no filtering)
  • boolean $setUserState: Should I set the user state with the fetched value?

Implementation of:
FOFPlatformInterface::getUserStateFromRequest()
This method will try retrieving a variable from the request (input) data.

Redefined in descendants as:
getViewTemplatePaths (line 282)

Return a list of the view template directories for this component.

  • see: FOFPlatformInterface::getViewTemplateDirs()
  • access: public
array getViewTemplatePaths (string $component, string $view, [string $layout = 'default'], [string $tpl = null], [boolean $strict = false])
  • string $component: The name of the component. For Joomla! this is something like "com_example"
  • string $view: The name of the view you're looking a template for
  • string $layout: The layout name to load, e.g. 'default'
  • string $tpl: The sub-template name to load (null by default)
  • boolean $strict: If true, only the specified layout will be searched for. Otherwise we'll fall back to the 'default' layout if the specified layout is not found.

Implementation of:
FOFPlatformInterface::getViewTemplatePaths()
Return a list of the view template paths for this component. The paths are in the format site:/component_name/view_name/layout_name or admin:/component_name/view_name/layout_name

Redefined in descendants as:
importPlugin (line 398)

Load plugins of a specific type. Obviously this seems to only be required in the Joomla! CMS.

void importPlugin (string $type)
  • string $type: The type of the plugins to be loaded

Implementation of:
FOFPlatformInterface::importPlugin()
Load plugins of a specific type. Obviously this seems to only be required in the Joomla! CMS.

Redefined in descendants as:
isBackend (line 440)

Is this the administrative section of the component?

boolean isBackend ()

Implementation of:
FOFPlatformInterface::isBackend()
Is this the administrative section of the component?

Redefined in descendants as:
isCli (line 464)

Is this a component running in a CLI application?

boolean isCli ()

Implementation of:
FOFPlatformInterface::isCli()
Is this a component running in a CLI application?

Redefined in descendants as:
isEnabled (line 234)

Is this platform enabled?

boolean isEnabled ()

Implementation of:
FOFPlatformInterface::isEnabled()
Is this platform enabled? This is used for automatic platform detection.

Redefined in descendants as:
isFrontend (line 452)

Is this the public section of the component?

boolean isFrontend ()

Implementation of:
FOFPlatformInterface::isFrontend()
Is this the public section of the component?

Redefined in descendants as:
isGlobalFOFCacheEnabled (line 530)

Is the global FOF cache enabled?

  • access: public
boolean isGlobalFOFCacheEnabled ()

Implementation of:
FOFPlatformInterface::isGlobalFOFCacheEnabled()
Is the global FOF cache enabled?

Redefined in descendants as:
loadTranslations (line 324)

Load the translation files for a given component.

void loadTranslations (string $component)
  • string $component: The name of the component. For Joomla! this is something like "com_example"

Implementation of:
FOFPlatformInterface::loadTranslations()
Load the translation files for a given component. The "component" is used in the sense of what we call "component" in Joomla!, "plugin" in WordPress and "module" in Drupal, i.e. an application which is running inside our main application (CMS).

Redefined in descendants as:
loginUser (line 556)

logs in a user

  • return: True on success
  • access: public
boolean loginUser (array $authInfo)
  • array $authInfo: authentification information

Implementation of:
FOFPlatformInterface::loginUser()
logs in a user

Redefined in descendants as:
logoutUser (line 566)

logs out a user

  • return: True on success
  • access: public
boolean logoutUser ()

Implementation of:
FOFPlatformInterface::logoutUser()
logs out a user

Redefined in descendants as:
runPlugins (line 413)

Execute plugins (system-level triggers) and fetch back an array with their return values.

array runPlugins (string $event, array $data)
  • string $event: The event (trigger) name, e.g. onBeforeScratchMyEar
  • array $data: A hash array of data sent to the plugins as part of the trigger

Implementation of:
FOFPlatformInterface::runPlugins()
Execute plugins (system-level triggers) and fetch back an array with their return values.

Redefined in descendants as:
setCache (line 506)

Saves something to the cache. This is supposed to be used for system-wide FOF data, not application data.

  • return: True on success
  • access: public
boolean setCache (string $key, string $content)
  • string $key: The key of the data to save
  • string $content: The actual data to save

Implementation of:
FOFPlatformInterface::setCache()
Saves something to the cache. This is supposed to be used for system-wide FOF data, not application data.

Redefined in descendants as:
setErrorHandling (line 65)

Set the error Handling, if possible

  • access: public
void setErrorHandling (integer $level, string $log_level, [array $options = array()])
  • integer $level: PHP error level (E_ALL)
  • string $log_level: What to do with the error (ignore, callback)
  • array $options: Options for the error handler

Implementation of:
FOFPlatformInterface::setErrorHandling()
Set the error Handling, if possible
supportsAjaxOrdering (line 477)

Is AJAX re-ordering supported? This is 100% Joomla!-CMS specific. All other platforms should return false and never ask why.

boolean supportsAjaxOrdering ()

Implementation of:
FOFPlatformInterface::supportsAjaxOrdering()
Is AJAX re-ordering supported? This is 100% Joomla!-CMS specific. All other platforms should return false and never ask why.

Redefined in descendants as:

Documentation generated on Tue, 19 Nov 2013 15:10:42 +0100 by phpDocumentor 1.4.3