Zend Framework  2.4
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ModuleManager Class Reference

Module manager. More...

Public Member Functions

 __construct ($modules, EventManagerInterface $eventManager=null)
 Constructor.
 
 onLoadModules ()
 Handle the loadModules event.
 
 loadModules ()
 Load the provided modules.
 
 loadModule ($module)
 Load a specific module by name.
 
 getLoadedModules ($loadModules=false)
 Get an array of the loaded modules.
 
 getModule ($moduleName)
 Get an instance of a module class by the module name.
 
 getModules ()
 Get the array of module names that this manager should load.
 
 setModules ($modules)
 Set an array or Traversable of module names that this module manager should load.
 
 getEvent ()
 Get the module event.
 
 setEvent (ModuleEvent $event)
 Set the module event.
 
 setEventManager (EventManagerInterface $events)
 Set the event manager instance used by this module manager.
 
 getEventManager ()
 Retrieve the event manager.
 

Public Attributes

const EVENT_BOOTSTRAP = 'bootstrap'
 #@+ Reference to Zend::EVENT_BOOTSTRAP
 

Protected Member Functions

 loadModuleByName ($event)
 Load a module with the name.
 
 attachDefaultListeners ()
 Register the default event listeners.
 

Protected Attributes

 $loadedModules = array()
 
 $events
 
 $event
 
 $loadFinished
 
 $modules = array()
 
 $modulesAreLoaded = false
 

Detailed Description

Module manager.

Constructor & Destructor Documentation

__construct (   $modules,
EventManagerInterface  $eventManager = null 
)

Constructor.

Parameters
array | Traversable$modules
EventManagerInterface$eventManager

Member Function Documentation

attachDefaultListeners ( )
protected

Register the default event listeners.

Returns
ModuleManager
getEvent ( )

Get the module event.

Returns
ModuleEvent
getEventManager ( )

Retrieve the event manager.

Lazy-loads an EventManager instance if none registered.

Returns
EventManagerInterface

Implements EventsCapableInterface.

getLoadedModules (   $loadModules = false)

Get an array of the loaded modules.

Parameters
bool$loadModulesIf true, load modules if they're not already
Returns
array An array of Module objects, keyed by module name

Implements ModuleManagerInterface.

getModule (   $moduleName)

Get an instance of a module class by the module name.

Parameters
string$moduleName
Returns
mixed
getModules ( )

Get the array of module names that this manager should load.

Returns
array

Implements ModuleManagerInterface.

loadModule (   $module)

Load a specific module by name.

Parameters
string | array$module
Exceptions
Exception\RuntimeExceptionloadModule.resolve loadModule
Returns
mixed Module's Module class

Implements ModuleManagerInterface.

loadModuleByName (   $event)
protected

Load a module with the name.

Parameters
\Zend\EventManager\EventInterface$event
Returns
mixed module instance
Exceptions
Exception\RuntimeException
loadModules ( )

Load the provided modules.

loadModules loadModules.post

Returns
ModuleManager

Having a dedicated .post event abstracts the complexity of priorities from the user. Users can attach to the .post event and be sure that important things like config merging are complete without having to worry if they set a low enough priority.

Implements ModuleManagerInterface.

onLoadModules ( )

Handle the loadModules event.

Returns
void
setEvent ( ModuleEvent  $event)

Set the module event.

Parameters
ModuleEvent$event
Returns
ModuleManager
setEventManager ( EventManagerInterface  $events)

Set the event manager instance used by this module manager.

Parameters
EventManagerInterface$events
Returns
ModuleManager

Implements EventManagerAwareInterface.

setModules (   $modules)

Set an array or Traversable of module names that this module manager should load.

Parameters
mixed$modulesarray or Traversable of module names
Exceptions
Exception\InvalidArgumentException
Returns
ModuleManager

Implements ModuleManagerInterface.

Member Data Documentation

$event
protected
$events
protected
$loadedModules = array()
protected
$loadFinished
protected
$modules = array()
protected
$modulesAreLoaded = false
protected
const EVENT_BOOTSTRAP = 'bootstrap'

#@+ Reference to Zend::EVENT_BOOTSTRAP