Author: XE Developers (developers@xpressengine.com)
コード例 #1
0
 /**
  * 주어진 프록시설정에 해당하는 클래스파일이 존재하는지 확인한다.
  * checkFileTime가 설정돼 있으면 파일시간을 체크하여 판단한다.
  *
  * @param ProxyConfig $config 프록시 설정
  *
  * @return bool 클래스파일이 존재할 경우 true를 반환한다.
  */
 public function existProxyFile(ProxyConfig $config)
 {
     if ($this->hasProxyFile($config->getProxyName()) === false) {
         return false;
     }
     if ($this->checkFileTime === false) {
         return true;
     }
     $targetPath = $config->getTargetPath();
     $proxyPath = $this->getProxyPath($config->getProxyName());
     if (filemtime($targetPath) < filemtime($proxyPath)) {
         return true;
     }
 }
コード例 #2
0
 /**
  * 주어진 프록시 클래스 템플릿 코드의 메소드 선언부를 변환한다.
  *
  * @param string      $code   프록시 클래스 탬플릿 코드
  * @param ProxyConfig $config 동적으로 생성하려는 프록시 클래스 정보
  *
  * @return string
  */
 public function apply($code, ProxyConfig $config)
 {
     foreach ($config->getTargetMethods() as $method) {
         if ($method->isStatic()) {
             continue;
         }
         $name = $method->getName();
         $methodDef = '    public';
         $methodDef .= ' function ';
         $methodDef .= $method->returnsReference() ? ' & ' : '';
         $methodDef .= $name;
         $methodDef .= $this->renderParams($method);
         $methodDef .= $this->renderMethodBody($name === '__call');
         $code = $this->appendToClass($code, $methodDef);
     }
     return $code;
 }
コード例 #3
0
 /**
  * 주어진 프록시 클래스 템플릿 코드의 클래스 선언부를 변환한다.
  *
  * @param string      $code   프록시 클래스 탬플릿 코드
  * @param ProxyConfig $config 동적으로 생성하려는 프록시 클래스 정보
  *
  * @return string
  */
 public function apply($code, ProxyConfig $config)
 {
     $code = str_replace('class Proxy', 'class ' . $config->getProxyName() . ' extends ' . $config->getTargetName(), $code);
     return $code;
 }
コード例 #4
0
 public function testGetTargetPath()
 {
     $config = new ProxyConfig('\\Xpressengine\\Tests\\ProxyConfigTest\\TestTargetClass');
     $path = $config->getTargetPath();
     $this->assertEquals(__FILE__, $path);
 }