2013-04-18 4 views
1

프로젝트/index.php에젠드 프레임 워크의 일부 코드를 이해하려고 노력

<?php 
error_reporting(E_ALL|E_STRICT); 
date_default_timezone_set('Europe/London'); 
set_include_path('.' . PATH_SEPARATOR . './library' 
. PATH_SEPARATOR . './application/models/' 
. PATH_SEPARATOR . get_include_path()); 
include "Zend/Loader.php"; 
Zend_Loader::loadClass('Zend_Controller_Front'); 
// setup controller 
$frontController = Zend_Controller_Front::getInstance(); 
$frontController->throwExceptions(true); 
$frontController->setControllerDirectory('./application/controllers'); 
// run! 
$frontController->dispatch(); 
?> 

젠드/컨트롤러/Front.php

<?php 
... 
class Zend_Controller_Front 
{ 
... 
    protected static $_instance = null; 
... 
    protected $_throwExceptions = false; 
... 
    protected function __construct() 
     { 
      $this->_plugins = new Zend_Controller_Plugin_Broker(); 
     } 
... 
    public static function getInstance() 
     { 
      if (null === self::$_instance) { 
        self::$_instance = new self(); 
      } 

     return self::$_instance; 
     } 
... 
    public function throwExceptions($flag = null) 
     { 
      if ($flag !== null) { 
        $this->_throwExceptions = (bool) $flag; 
        return $this; 
      } 

      return $this->_throwExceptions; 
     } 
... 
} 
... 
?> 

질문 :

  1. $this->_plugins = new Zend_Controller_Plugin_Broker(); 뭐라고이다 이 수업의 사용 : Zend_Controller_Plugin_Broker? 그것은 프로젝트/index.php에서 anyhing하지 않는 것 같습니다
  2. public function throwExceptions($flag = null)$flag !== null, return $this; 동안 $flag == null, return $this->_throwExceptions;? 둘 다 왜 이걸 돌려주지 않니?
  3. $frontController->setControllerDirectory('./application/controllers'); "." 현재 디렉토리를 의미합니까? 우리는 왜 "."을 가질 필요가 있습니까?

답변

1

이 클래스의 용도는 무엇입니까? Zend_Controller_Plugin_Broker?

컨트롤러 플러그인 관리 용입니다. $front->registerPlugin()으로 전화하면 플러그인 브로커가 통화를 처리합니다. 자세한 내용은 http://framework.zend.com/manual/1.12/en/zend.controller.plugins.html을 참조하십시오.

왜 $ flag! == null, return $ this; while $ flag == null, return this this -> _ throwExceptions ;?

이 기능을 사용하면 두 가지 용도로 사용할 수 있습니다. 매개 변수없이 호출하면 throwExceptions의 현재 값이 반환됩니다. 매개 변수로 호출하면 값을 설정합니다.

$ frontController-> setControllerDirectory ('./ application/controllers'); "." 현재 디렉토리를 의미합니까? 우리는 왜 "."을 가질 필요가 있습니까?

왜 안 되니? 경로가 현재 디렉토리에 상대적임을 명확하게합니다.

관련 문제