当前位置: 首页>>代码示例>>PHP>>正文


PHP Sprig::__construct方法代码示例

本文整理汇总了PHP中Sprig::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Sprig::__construct方法的具体用法?PHP Sprig::__construct怎么用?PHP Sprig::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sprig的用法示例。


在下文中一共展示了Sprig::__construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Initialize the fields and add MPTT field defaults if not specified
  * @return void
  */
 protected function __construct()
 {
     // Initialize sprig (this will call _init() in the model)
     parent::__construct();
     // Check we don't have a composite primary Key
     if (is_array($this->pk())) {
         throw new Sprig_Exception('Sprig_MPTT does not support composite primary keys');
     }
     // Check Sprig MPTT fields exist, if not add defaults
     foreach ($this->_fields as $name => $field) {
         // Check the field extends Sprig_Field_MPTT
         if ($field instanceof Sprig_Field_MPTT) {
             if ($field instanceof Sprig_Field_MPTT_Left) {
                 $this->left_column = $name;
             } elseif ($field instanceof Sprig_Field_MPTT_Right) {
                 $this->right_column = $name;
             } elseif ($field instanceof Sprig_Field_MPTT_Level) {
                 $this->level_column = $name;
             } elseif ($field instanceof Sprig_Field_MPTT_Scope) {
                 $this->scope_column = $name;
             }
         } elseif ($field instanceof Sprig_Field_MPTT_Related and !array_key_exists($name, $this->related) or !$field instanceof Sprig_Field_MPTT_Related and array_key_exists($name, $this->related)) {
             unset($this->_fields[$name]);
         }
     }
     // If any of the MPTT fields havn't been defined, create defaults
     if (is_null($this->left_column)) {
         $this->left_column = 'lft';
         $this->_fields['lft'] = new Sprig_Field_MPTT_Left(array('column' => 'lft'));
     }
     if (is_null($this->right_column)) {
         $this->right_column = 'rgt';
         $this->_fields['rgt'] = new Sprig_Field_MPTT_Right(array('column' => 'rgt'));
     }
     if (is_null($this->level_column)) {
         $this->level_column = 'lvl';
         $this->_fields['lvl'] = new Sprig_Field_MPTT_Level(array('column' => 'lvl'));
     }
     if (is_null($this->scope_column)) {
         $this->scope_column = 'scope';
         $this->_fields['scope'] = new Sprig_Field_MPTT_Scope(array('column' => 'scope'));
     }
     $suffixes = array('root', 'parent', 'ancestors', 'children', 'first_child', 'last_child', 'descendants', 'siblings', 'leaves');
     while (list($field) = each($this->related) and list(, $suffix) = each($suffixes)) {
         if (!array_key_exists($field, $this->_fields)) {
             $sprig_field = 'Sprig_Field_MPTT_' . ucwords($suffix);
             $this->_fields[$field] = new $sprig_field(array('model' => $this->_model));
         }
     }
     // Check we have default values for all (MPTT) fields (otherwise we cause errors)
     foreach ($this->_fields as $name => $field) {
         if ($field instanceof Sprig_Field_MPTT and !isset($this->_original[$name])) {
             $this->_original[$name] = NULL;
         }
     }
 }
开发者ID:ascseb,项目名称:sprig-mptt,代码行数:60,代码来源:mptt.php

示例2: __construct

 /**
  * Initialize the fields and add MPTT field defaults if not specified
  * @return void
  */
 protected function __construct()
 {
     // Initialize sprig (this will call _init() in the model)
     parent::__construct();
     // Check we don't have a composite primary Key
     if (is_array($this->pk())) {
         throw new Sprig_Exception('Sprig_MPTT does not support composite primary keys');
     }
     // Check Sprig MPTT fields exist, if not add defaults
     foreach ($this->_fields as $name => $field) {
         // Check the field extends Sprig_Field_MPTT
         if ($field instanceof Sprig_Field_MPTT) {
             if ($field instanceof Sprig_Field_MPTT_Left) {
                 $this->left_column = $name;
             } elseif ($field instanceof Sprig_Field_MPTT_Right) {
                 $this->right_column = $name;
             } elseif ($field instanceof Sprig_Field_MPTT_Level) {
                 $this->level_column = $name;
             } elseif ($field instanceof Sprig_Field_MPTT_Scope) {
                 $this->scope_column = $name;
             }
         }
     }
     // If any of the MPTT fields havn't been defined, create defaults
     if (is_null($this->left_column)) {
         $this->left_column = 'lft';
         $this->_fields['lft'] = new Sprig_Field_MPTT_Left(array('column' => 'lft'));
     }
     if (is_null($this->right_column)) {
         $this->right_column = 'rgt';
         $this->_fields['rgt'] = new Sprig_Field_MPTT_Right(array('column' => 'rgt'));
     }
     if (is_null($this->level_column)) {
         $this->level_column = 'lvl';
         $this->_fields['lvl'] = new Sprig_Field_MPTT_Level(array('column' => 'lvl'));
     }
     if (is_null($this->scope_column)) {
         $this->scope_column = 'scope';
         $this->_fields['scope'] = new Sprig_Field_MPTT_Scope(array('column' => 'scope'));
     }
     // Check we have default values for all (MPTT) fields (otherwise we cause errors)
     foreach ($this->_fields as $name => $field) {
         if ($field instanceof Sprig_Field_MPTT and !isset($this->_original[$name])) {
             $this->_original[$name] = NULL;
         }
     }
 }
开发者ID:banks,项目名称:sprig-mptt,代码行数:51,代码来源:mptt.php

示例3: __construct

 public function __construct($id = NULL)
 {
     $this->_columns = Kohana::config($this->_config)->columns;
     $this->_user_model = Kohana::config($this->_config)->user_model;
     parent::__construct($id);
 }
开发者ID:smgladkovskiy,项目名称:A1,代码行数:6,代码来源:user.php


注:本文中的Sprig::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。