PHP 클래스 Gdn_Factory, vanilla

A factory used to create most objects in the core library. If you have your own object that implements some base portion of the library you can install it in the factory make sure your own object has the same properties/methods as the core object and then install it into this factory.
파일 보기 프로젝트 열기: vanilla/vanilla

보호된 프로퍼티들

프로퍼티 타입 설명
$_Dependencies The property dependancies for the factory.
$_Objects The object definitions for the factory.

공개 메소드들

메소드 설명
__construct ( )
all ( ) : array Get all currently defined factories
cleanup ( ) Clean up the factory's objects
exists ( string $Alias ) : boolean Checks whether or not a factory alias exists.
factory ( $Alias, $Args = null ) Creates an object with mapped to the name.
install ( string $Alias, string $ClassName, string $Path = '', string $FactoryType = Gdn::FactorySingleton, $Data = null ) Install a class to the factory.
installDependency ( string $Alias, string $PropertyName, string $SourceAlias ) Install a dependency for the factory.
search ( string $search ) : array Search installed factories by fnmatch
uninstall ( string $Alias ) Uninstall a factory definition.
uninstallDependency ( string $Alias, string $PropertyName = null ) Uninstall a dependency definition.

보호된 메소드들

메소드 설명
_instantiateObject ( $Alias, string $ClassName, array $Args = null ) Instantiate a new object.

비공개 메소드들

메소드 설명
setDependancies ( $Alias, $Object )

메소드 상세

__construct() 공개 메소드

public __construct ( )

_instantiateObject() 보호된 메소드

Instantiate a new object.
protected _instantiateObject ( $Alias, string $ClassName, array $Args = null )
$ClassName string The name of the class to instantiate.
$Args array The arguments to pass to the constructor. Note: This function currently only supports a maximum of 8 arguments.

all() 공개 메소드

Get all currently defined factories
public all ( ) : array
리턴 array

cleanup() 공개 메소드

Also calls 'Cleanup' on compatible instances.
public cleanup ( )

exists() 공개 메소드

Checks whether or not a factory alias exists.
public exists ( string $Alias ) : boolean
$Alias string The alias of the factory to check for.
리턴 boolean Whether or not a factory definintion exists.

factory() 공개 메소드

Creates an object with mapped to the name.
public factory ( $Alias, $Args = null )
$Alias The class code of the object to create.
$Args The arguments to pass to the constructor of the object.

install() 공개 메소드

Install a class to the factory.
public install ( string $Alias, string $ClassName, string $Path = '', string $FactoryType = Gdn::FactorySingleton, $Data = null )
$Alias string An alias for the class that will be used to retreive instances of it.
$ClassName string The actual name of the class.
$Path string The path to the class' file. You can prefix the path with ~ to start at the application root (PATH_ROOT).
$FactoryType string The way objects will be instantiated for the class. One of (Gdn::FactoryInstance, Gdn::FactoryPrototype, Gdn::FactorySingleton).
  • Gdn::FactoryInstance: A new instance of the class will be created when the factory is called.
  • Gdn::FactoryPrototype: A clone of a prototype will be created when the factory is called. The prototype must be passed into the $Data argument.
  • Gdn::FactorySingleton: A singleton instance, stored in the factory will be returned when the factory is called. The instance can be passed to the $Data argument on installation, or it will be lazy created when first accessed. You can also pass an array to $Data and it will be used as the arguments for the lazy construction.

installDependency() 공개 메소드

This method provides support for simple dependency injection. When an object with dependencies is created then the factory will call inline{@link Gdn_Factory::Factory()} for each dependency and set the object properties before returning it. Those dependencies can also have their own dependencies which will all be set when the object is returned.
public installDependency ( string $Alias, string $PropertyName, string $SourceAlias )
$Alias string The alias of the class that will have the dependency.
$PropertyName string The name of the property on the class that will have the dependency.
$SourceAlias string The alias of the class that will provide the value of the property when objects are instantiated.

uninstall() 공개 메소드

Uninstall a factory definition.
public uninstall ( string $Alias )
$Alias string The object alias to uninstall.

uninstallDependency() 공개 메소드

Uninstall a dependency definition.
public uninstallDependency ( string $Alias, string $PropertyName = null )
$Alias string The object alias to uninstall the dependency for.
$PropertyName string The name of the property dependency to uninstall. Note: If $PropertyName is null then all of the dependencies will be uninstalled for $Alias.

프로퍼티 상세

$_Dependencies 보호되어 있는 프로퍼티

The property dependancies for the factory.
protected $_Dependencies

$_Objects 보호되어 있는 프로퍼티

The object definitions for the factory.
protected $_Objects