class XF

Class xf Singleton Fabric The xf class is used to get access to helpers and instantiate other objects.

Traits

Trait ObjectManager XELOS Framework

Properties

protected array $object_cache Each object created by a success call of __call or __get will be saved into this property to avoid a multiple creation of same objects and minimize performance loss. If the multiple creation of objects is desirable e.g. in factory classes, the caching can be disabled by setting xf_trait::factory_mode to true. from ObjectManager
protected array[] $registry The instantiation of a requested object can be processed only if the class of the object is registered with the class name as key and its information as array in this property. The element should have at least the class name or the relative path to "class" folder. from ObjectManager
protected string $lib_class_dir This property contains the path to the folder served as root for all requested classes. This folder can contains other folder or classes. All requested and registered classes will be searched in this folder by concating this path with the relative path defined in the registration of the requested class. If the class is not included it will be done on the fly. from ObjectManager
protected string $lib_class_prefix An optional possibility to pretend a prefix for all registered classes. from ObjectManager
protected string $ns_class_prefix An optional possibility to pretend a namespace prefix for classes have no namespace yet. from ObjectManager
protected bool $factory_mode This property effects the object cache. By default it is set to false to enable the object cache for all requested objects. If this property is set true, the object cache will be disabled. from ObjectManager
protected array $injection_objects This is an assoc array and contains objects that will be injected into each requested object. Each containing object will be injected by the name of the key. E.g. ['mod' => $object] this would inject the property named mod with the value of $object. from ObjectManager
protected bool $auto_init This property controls if the init method of requested objects is called by this trait or not. from ObjectManager
DB $db
Lib $lib
IM $im
UI $ui
User $user
Config $config
Event $event
View $view
array $GPvars
int $grd_count
string $mode
mixed $mode_tunneled
mixed $cron_id
array $model_cache
System $system

Methods

xelos_object_manager_init(bool $lib_class_dir, string $lib_class_prefix = '', string $ns_prefix = '')

trait constructor This method have to be called from constructor of each class that uses this trait.

set_injection_objects(array $objects)

Add given objects to injection object list that will be inject into object by magic call. The array should consists of property name as key and object as value.

set_lib_class_dir($lib_class_dir)

Sets the directory where classes are stored.

set_lib_class_prefix($lib_class_prefix)

Sets the class name prefix.

string
get_lib_class_dir()

Returns the path to class directory.

string
get_lib_class_prefix()

Returns the defined prefix for all classes.

array
get_object_cache()

Returns an array containing all objects were requested.

bool
__isset($property)

Magic method.

__set($name, $value)

Magic method.

mixed
__get($class)

Magic method.

mixed
__call($class, $args)

Magic method.

static xf
instance()

Returns an instance of xf class.

init()

Initializes main xf components.

shutdown()

Global Shutdown Function being called on finishing Page Call

set_instantiation_closure(string $class, $callable)

No description

skip_init(string $component)

No description

Details

in ObjectManager at line 103
xelos_object_manager_init(bool $lib_class_dir, string $lib_class_prefix = '', string $ns_prefix = '')

trait constructor This method have to be called from constructor of each class that uses this trait.

It sets the defaults and all necessary properties.

Parameters

bool $lib_class_dir
string $lib_class_prefix e.g. 'xf_'
string $ns_prefix e.g. "XELOS\Framework\Lib\"

in ObjectManager at line 125
set_injection_objects(array $objects)

Add given objects to injection object list that will be inject into object by magic call. The array should consists of property name as key and object as value.

Parameters

array $objects

in ObjectManager at line 141
set_lib_class_dir($lib_class_dir)

Sets the directory where classes are stored.

This folder can contains other folder or classes. All requested and registered classes will be searched in this folder by concating this path with the relative path defined in the registration of the requested class. If the class is not included it will be done on the fly.

Parameters

$lib_class_dir

in ObjectManager at line 156
set_lib_class_prefix($lib_class_prefix)

Sets the class name prefix.

An optional possibility to pretend a prefix for all registered classes. This prefix is only required in the class name of the requested object. The registered class name should not contains this prefix. E.g. a class called xf_foobar should be registered as foobar.

Parameters

$lib_class_prefix

in ObjectManager at line 167
string get_lib_class_dir()

Returns the path to class directory.

Return Value

string

See also

xf_trait::lib_class_dir
xf_trait::get_lib_class_dir

in ObjectManager at line 177
string get_lib_class_prefix()

Returns the defined prefix for all classes.

Return Value

string

See also

xf_trait::lib_class_prefix

in ObjectManager at line 187
array get_object_cache()

Returns an array containing all objects were requested.

Return Value

array

See also

xf_trait::object_cache

in ObjectManager at line 199
bool __isset($property)

Magic method.

This method checks whether the property is defined or injected by __set. If not injected or defined, it will check the registry for an entry of requested property.

Parameters

$property

Return Value

bool

in ObjectManager at line 219
__set($name, $value)

Magic method.

Sets the given value by $name

Parameters

$name
$value

in ObjectManager at line 231
mixed __get($class)

Magic method.

First it checks if the requested property is defined and returns it if null. If not defined of null, it calls xf_trait::get_object and returns its return value.

Parameters

$class

Return Value

mixed

in ObjectManager at line 249
mixed __call($class, $args)

Magic method.

Returns the requested object. If the object is not cached, it will be instantiated with given arguments. This method calls xf_trait::get_object.

Parameters

$class
$args

Return Value

mixed

at line 130
static xf instance()

Returns an instance of xf class.

This class is a singleton.

Return Value

xf

at line 156
init()

Initializes main xf components.

First they will be instantiated and then initialized via implemented init method.

at line 222
shutdown()

Global Shutdown Function being called on finishing Page Call

at line 256
set_instantiation_closure(string $class, $callable)

Parameters

string $class
$callable

at line 263
skip_init(string $component)

Parameters

string $component