PHP Class Xpressengine\Interception\InterceptionHandler

Author: XE Developers ([email protected])
Afficher le fichier Open project: xpressengine/xpressengine Class Usage Examples

Protected Properties

Свойство Type Description
$advisorCollection advisor 저장소. 이 클래스를 통해 등록되는 모든 advisor는 AdvisorCollection에 저장된다.
$loader Xpressengine\Interception\Proxy\Loader\Loader
$passes Xpressengine\Interception\Proxy\Pass\Pass
$proxyGenerator Xpressengine\Interception\Proxy\ProxyGenerator
$proxyList array proxy가 생성된 클래스 목록 key는 target class name, value는 proxy class name을 저장한다.

Méthodes publiques

Méthode Description
__construct ( AdvisorCollection $advisorCollection, ProxyGenerator $generator ) constructor
addAdvisor ( array | string $pointCut, array | string $advisorInfo, Closure $advice ) : Advisor advisor의 구성정보를 파라메터로 입력받아 advisorCollection에 추가한다.
clearProxies ( ) : void 기생성된 Proxy 파일을 모두 삭제한다.
getAdvisorCollection ( ) : AdvisorCollection
getProxyList ( ) : array 생성된 proxy class 리스트를 반환한다.
proxy ( string $targetClass, string | null $alias = null ) : string 타겟 클래스의 프록시 클래스를 생성하여 로드하고, 생성된 프록시 클래스 이름을 반환한다.

Méthodes protégées

Méthode Description
resolveAdvisorInfo ( array $advisorInfo ) : array addAdvisor 메소드를 통해 입력받은 advisorInfo에서 정보를 추출한다.

Private Methods

Méthode Description
resolveAfterAdvisor ( string | array $priority ) : string | array | null advisorInfo에서 after advisor name을 추출한다.
resolveBeforeAdvisor ( string | array $priority ) : string | array | null advisorInfo에서 before advisor name을 추출한다.

Method Details

__construct() public méthode

constructor
public __construct ( AdvisorCollection $advisorCollection, ProxyGenerator $generator )
$advisorCollection AdvisorCollection advisor 저장소
$generator Xpressengine\Interception\Proxy\ProxyGenerator 프록시 생성기

addAdvisor() public méthode

이 함수를 직접 호출하는 대신 intercept() 헬퍼함수를 사용하십시오.
public addAdvisor ( array | string $pointCut, array | string $advisorInfo, Closure $advice ) : Advisor
$pointCut array | string advisor의 point cut을 지정한다. point cut은 [타겟클래스명]@[메소드명] 형태의 string 또는, string array 형식을 가진다. 예: 'Document@insertDocument' 또는 ['Document@insertDocument', 'Document@updateDocument']
$advisorInfo array | string advisor의 이름을 지정한다. 필요한 경우 before, after advisor의 이름을 지정하여 우선순위를 지정할 수 있다. 예: 'spamfilter.insertDocument' - advisor 이름으로 spamfilter.insertDocument를 지정 ['spamfilter.insertDocument' => 'mailing.insertDocument'] - before advisor로 mailing.insertDocument를 지정, mailing이 먼저 실행된 후, spamfilter가 실행된다.
$advice Closure advisor가 작동할 때 실행될 코드를 지정한다. Closure 형식으로 지정한다. 예: function($target, $arg1, $arg2, $arg3) { $target($arg1, $arg2, $arg3); }
Résultat Advisor 추가된 advisor

clearProxies() public méthode

기생성된 Proxy 파일을 모두 삭제한다.
public clearProxies ( ) : void
Résultat void

getAdvisorCollection() public méthode

public getAdvisorCollection ( ) : AdvisorCollection
Résultat AdvisorCollection

getProxyList() public méthode

생성된 proxy class 리스트를 반환한다.
public getProxyList ( ) : array
Résultat array

proxy() public méthode

만약 어떤 클래스에 interception을 적용하고 싶을 때 이 메소드를 사용하면 된다. $targetClassName = 'My\Namespace\PostManager'; $proxyClass = XeInterception::proxy($targetClass, 'Post'); $postManager = new $proxyClass(); 두번째 파라메터를 사용하여 타겟클래스의 alias 이름을 등록할 수 있다. alias 이름을 지정하면, 타겟 클래스에 interception을 등록할 때, alias 이름을 사용할 수 있다. Post alias를 사용 intercept('Post@insert', 'spam_filter', function(){...});
public proxy ( string $targetClass, string | null $alias = null ) : string
$targetClass string 타겟 클래스
$alias string | null 타겟 클래스의 별칭
Résultat string

resolveAdvisorInfo() protected méthode

추출되는 정보는 advisor의 이름, advisor의 before, after 관계의 다른 advisor 목록이다.
protected resolveAdvisorInfo ( array $advisorInfo ) : array
$advisorInfo array 정보를 추출할 배열
Résultat array 추출된 정보

Property Details

$advisorCollection protected_oe property

advisor 저장소. 이 클래스를 통해 등록되는 모든 advisor는 AdvisorCollection에 저장된다.
protected $advisorCollection

$loader protected_oe property

protected Loader,Xpressengine\Interception\Proxy\Loader $loader
Résultat Xpressengine\Interception\Proxy\Loader\Loader

$passes protected_oe property

protected Pass,Xpressengine\Interception\Proxy\Pass $passes
Résultat Xpressengine\Interception\Proxy\Pass\Pass

$proxyGenerator protected_oe property

protected ProxyGenerator,Xpressengine\Interception\Proxy $proxyGenerator
Résultat Xpressengine\Interception\Proxy\ProxyGenerator

$proxyList protected_oe property

proxy가 생성된 클래스 목록 key는 target class name, value는 proxy class name을 저장한다.
protected array $proxyList
Résultat array