示例#1
0
 public function __construct(IContainer $aParent, $aCallback)
 {
     if (!is_callable($aCallback)) {
         throw new Exception(__CLASS__ . "() 的参数 \$aCallback 必须是一个回调函数,传入的参数类型为:%s", Type::reflectType($aCallback));
     }
     $arrBingo = self::searching($aParent, $aCallback);
     parent::__construct($arrBingo);
 }
示例#2
0
 public function add($callback, $arrArgvs = array())
 {
     if (!is_callable($callback)) {
         throw new Exception(__METHOD__ . "()的参数\$callback必须为回调函数类型,传入的类型为:%s", Type::reflectType($callback));
     }
     if (!is_array($arrArgvs)) {
         $arrArgvs = array($arrArgvs);
     }
     array_unshift($this->arrFilters, array($callback, $arrArgvs));
 }
示例#3
0
 public function add($object, $sName = null, $bTakeover = true)
 {
     if ($object === $this) {
         return;
     }
     if (!$this->accept($object)) {
         throw new Exception(__METHOD__ . "() 方法无法接受 %s 类型的参数", Type::reflectType($object));
     }
     if (!in_array($object, $this->arrObjects, is_object($object))) {
         $this->arrObjects[] = $object;
         $this->attach($object, $sName, $bTakeover);
     }
     return $object;
 }
示例#4
0
 private function &findJoinedTable(&$sToken, ParseState $aParseState)
 {
     for (end($aParseState->arrTree); $prevToken = current($aParseState->arrTree); prev($aParseState->arrTree)) {
         if (!is_array($prevToken)) {
             throw new SqlParserException($aParseState, "join 前的 token 类型无效:%s", Type::reflectType($prevToken));
         } else {
             switch ($prevToken['expr_type']) {
                 // bingo
                 case 'table':
                 case 'subquery':
                     $pos = key($aParseState->arrTree);
                     return $aParseState->arrTree[$pos];
                     break;
                 case 'join_expression':
                     // nothing todo
                     break;
                 default:
                     break;
             }
         }
     }
     throw new SqlParserException($aParseState, "遇到无效的join,无法为 join 子句确定对应的数据表表达式");
 }
示例#5
0
 public static function setSingleton(self $aInstance = null, $sClass = null)
 {
     if (!$sClass) {
         $sClass = get_called_class();
     }
     // 移除全局实例
     if (!$aInstance) {
         unset(self::$arrGlobalInstancs[$sClass]);
     }
     if (!$aInstance instanceof static) {
         throw new Exception('%s::setSingleton() 设置的单件实例必须为一个 %s 类型的对象,传入的对象类型为:%s', array($sClass, $sClass, Type::reflectType($aInstance)));
     }
     self::$arrGlobalInstancs[$sClass] = $aInstance;
 }
示例#6
0
文件: View.php 项目: JeCat/framework
 /**
  *
  * @param unknown_type $sTemplate
  * @wiki /MVC模式/视图/视图的组合模式
  * 
  * view可以是一个,也可以是多个,也就是说view可以是一个容易,是多个view的集合,通过<views/>标签,可以将view遍历显示出来.
  *
  */
 public function add($object, $sName = null, $bTakeover = true)
 {
     if (!$object instanceof IView) {
         throw new Exception("参数 \$object 必须为 IView 对像,传入的类型为:%s", Type::reflectType($object));
     }
     if (!$sName) {
         $sName = $object->name();
     }
     if ($this->hasName($sName)) {
         throw new Exception("名称为:%s 的子视图在视图 %s 中已经存在,无法添加同名的子视图", array($sName, $this->name()));
     }
     if ($bTakeover) {
         $this->messageQueue()->addChildHolder($object);
     }
     parent::add($object, $sName, $bTakeover);
 }