Overview

Namespaces

  • None
  • Xmf
    • Database
    • Module
      • Helper
    • Template
  • Xoops
    • Auth
    • Core
      • Cache
      • Database
        • Logging
        • Schema
      • Exception
      • Handler
        • Scheme
      • Kernel
        • Dtype
        • Handlers
        • Model
      • Lists
      • Locale
        • Punic
      • Service
        • Contract
      • Session
      • Text
        • Sanitizer
          • Extensions
      • Theme
        • Plugins
    • Form
    • Html
    • Locale
    • Module
      • Helper
      • Plugin

Classes

  • Assets
  • ComposerUtility
  • Events
  • FilterInput
  • FixedGroups
  • HttpRequest
  • Logger
  • MediaUploader
  • MimeTypes
  • PreloadItem
  • Psr0ClassLoader
  • Psr4ClassLoader
  • Random
  • Registry
  • Request
  • Security
  • XoopsTpl
  • Yaml

Interfaces

  • AttributeInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class Events

Xoops Event processing, including preload mechanism

Direct known subclasses

XoopsPreload
Namespace: Xoops\Core
Package: Xoops\Core
Category: Xoops\Core\Events
Copyright: 2013 XOOPS Project (http://xoops.org)
License: GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
Author: trabis lusopoemas@gmail.com
Author: Richard Griffith richard@geekwright.com
Version: Release: 1.0
Since: 1.0
Link: http://xoops.org
Located at oops_lib/Xoops/Core/Events.php
Methods summary
protected
# __construct( )

Constructor

Constructor

public static Xoops\Core\Events
# getInstance( )

Allow one instance only!

Allow one instance only!

Returns

Xoops\Core\Events
instance
protected
# initializeListeners( )

initializePreloads - Initialize listeners with preload mapped events.

initializePreloads - Initialize listeners with preload mapped events.

We suppress event processing during establishing listener map. A a cache miss (on system_modules_active, for example) triggers regeneration, which may trigger events that listeners are not prepared to handle. In such circumstances, module level class mapping will not have been done.

protected
# setPreloads( )

Get list of all available preload files

Get list of all available preload files

protected
# setEvents( )

Load all preload files and add all listener methods to eventListeners

Load all preload files and add all listener methods to eventListeners

Preload classes contain methods based on event names. We extract those method names and store to compare against when an event is triggered.

Example: An event is triggered as 'core.include.common.end' A PreloadItem class can listen for this event by declaring a static method 'eventCoreIncludeCommonEnd()'

PreloadItem class files can be named for the specific source of the events, such as core.php, system.php, etc. In such case the class name is built from the concatenation of the module name, the source and the literal 'Preload'. This mechanism is now considered deprecated. As an example, a module named 'Example' can listen for 'core' events with a file named preloads/core.php, containing a class ExampleCorePreload

The prefered preload definition is the unified preloads/preload.php file containing a single PreloadItem class name concatenating the module name and the literal 'Preload'. This class can listen for events from any source.

public
# triggerEvent( string $eventName, mixed $args = array() )

Trigger a specific event

Trigger a specific event

Parameters

$eventName
Name of the event to trigger
$args
Method arguments
protected string
# toInternalEventName( string $eventName )

toInternalEventName - convert event name to internal form i.e. core.include.common.end becomes coreincludecommonend

toInternalEventName - convert event name to internal form i.e. core.include.common.end becomes coreincludecommonend

Parameters

$eventName
the event name

Returns

string
converted name
public
# addListener( string $eventName, callable $callback )

addListener - add a listener, providing a callback for a specific event.

addListener - add a listener, providing a callback for a specific event.

Parameters

$eventName
the event name
$callback
any callable acceptable for call_user_func
public array
# getEvents( )

getEvents - for debugging only, return list of event listeners

getEvents - for debugging only, return list of event listeners

Returns

array
of events and listeners
public boolean
# hasListeners( string $eventName )

hasListeners - for debugging only, return list of event listeners

hasListeners - for debugging only, return list of event listeners

Parameters

$eventName
event name

Returns

boolean
true if one or more listeners are registered for the event
Properties summary
protected array $preloadList

$preloadList array containing information about the event observers

$preloadList array containing information about the event observers

# array()
protected array $eventListeners

$eventListeners - $eventListeners['eventName'][]=Closure key is event name, value is array of callables

$eventListeners - $eventListeners['eventName'][]=Closure key is event name, value is array of callables

# array()
protected boolean $eventsEnabled

Type

bool $eventsEnabled
# true
API documentation generated by ApiGen