ClassInterface FOFPlatformInterface

Description

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.

  • since: 2.1

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


	
			
Method Summary
 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])
 JUser 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()])
Methods
authorise (line 204)

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.

If your platform uses different conventions you'll have to override the FOF defaults using fof.xml or by specialising the controller.

  • return: True if the user is allowed this action
  • access: public
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
authorizeAdmin (line 152)

By default FOF will only use the Controller's onBefore* methods to

perform user authorisation. In some cases, like the Joomla! back-end, you alos need to perform component-wide user authorisation in the Dispatcher. This method MUST implement this authorisation check. If you do not need this in your platform, please always return true.

  • return: True to allow loading the component, false to halt loading
  • access: public
boolean authorizeAdmin (string $component)
  • string $component: The name of the component.
checkVersion (line 266)

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)
clearCache (line 299)

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 ()
getCache (line 288)

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
getComponentBaseDirs (line 82)

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).

The return is a table with the following keys: * main The normal location of component files. For a back-end Joomla! component this is the administrator/components/com_example directory. * alt The alternate location of component files. For a back-end Joomla! component this is the front-end directory, e.g. components/com_example * site The location of the component files serving the public part of the application. * admin The location of the component files serving the administrative part of the application.

All paths MUST be absolute. All four paths MAY be the same if the platform doesn't make a distinction between public and private parts, or when the component does not provide both a public and private part. All of the directories MUST be defined and non-empty.

  • return: A hash array with keys main, alt, site and admin.
  • access: public
array getComponentBaseDirs (string $component)
  • string $component: The name of the component. For Joomla! this is something like "com_example"
getDocument (line 225)

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.

FOF will not attempt to load CSS and Javascript files (as it doesn't make sense if there's no JDocument to handle them).

  • access: public
JDocument getDocument ()
getOrdering (line 42)

Returns the ordering of the platform class. Files with a lower ordering number will be loaded first.

  • access: public
integer getOrdering ()
getTemplateOverridePath (line 126)

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?
getTemplateSuffixes (line 113)

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 ()
getUser (line 214)

Returns a user object.

  • return: The JUser object for the specified user
  • access: public
JUser getUser ([integer $id = null])
  • integer $id: The user ID to load. Skip or use null to retrieve the object for the currently logged in user.
getUserStateFromRequest (line 170)

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

If it doesn't exist it will be loaded from the user state, typically stored in the session. If it doesn't exist there either, the $default value will be used. If $setUserState is set to true, the retrieved variable will be stored in the user session.

  • return: The value of the variable
  • access: public
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?
getViewTemplatePaths (line 105)

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

The list of paths returned is a prioritised list. If a file is found in the first path the other paths will not be scanned.

  • 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.
importPlugin (line 180)

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

  • access: public
void importPlugin (string $type)
  • string $type: The type of the plugins to be loaded
isBackend (line 232)

Is this the administrative section of the component?

  • access: public
boolean isBackend ()
isCli (line 246)

Is this a component running in a CLI application?

  • access: public
boolean isCli ()
isEnabled (line 52)

Is this platform enabled? This is used for automatic platform detection.

If the environment we're currently running in doesn't seem to be your platform return false. If many classes return true, the one with the lowest order will be picked by FOFPlatform.

  • access: public
boolean isEnabled ()
isFrontend (line 239)

Is this the public section of the component?

  • access: public
boolean isFrontend ()
isGlobalFOFCacheEnabled (line 306)

Is the global FOF cache enabled?

  • access: public
boolean isGlobalFOFCacheEnabled ()
loadTranslations (line 139)

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).

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

logs in a user

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

logs out a user

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

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

  • return: A simple array containing the resutls of the plugins triggered
  • access: public
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
setCache (line 277)

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
setErrorHandling (line 35)

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
supportsAjaxOrdering (line 254)

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

  • access: public
boolean supportsAjaxOrdering ()

Documentation generated on Tue, 19 Nov 2013 15:05:49 +0100 by phpDocumentor 1.4.3