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


PHP Jam::behavior_prefix方法代码示例

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


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

示例1: finalize

 /**
  * This is called after initialization to
  * finalize any changes to the meta object.
  *
  * @param  string  $model
  * @return
  */
 public function finalize($model)
 {
     if ($this->_initialized) {
         return;
     }
     // Set the name of a possible behavior class
     $behavior_class = Jam::behavior_prefix() . Jam::capitalize_class_name($model);
     // See if we have a special behavior class to use
     if (class_exists($behavior_class)) {
         // Load behavior
         $behavior = new $behavior_class();
         if (!in_array($behavior, $this->_behaviors)) {
             // Add to behaviors
             $this->_behaviors[] = $behavior;
         }
     }
     foreach ($this->_behaviors as $name => $behavior) {
         if (!$behavior instanceof Jam_Behavior) {
             throw new Kohana_Exception('Behavior at index [ :key ] is not an instance of Jam_Behavior, :type found.', array(':type' => is_object($behavior) ? 'instance of ' . get_class($behavior) : gettype($behavior), ':key' => $name));
         }
         // Initialize behavior
         $behavior->initialize($this, $name);
     }
     // Allow modification of this meta object by the behaviors
     $this->_events->trigger('meta.before_finalize', $this);
     // Ensure certain fields are not overridden
     $this->_model = $model;
     $this->_defaults = array();
     if (!$this->_errors_filename) {
         // Default errors filename to the model's name
         $this->_errors_filename = 'validators/' . $this->_model;
     }
     // Table should be a sensible default
     if (empty($this->_table)) {
         $this->_table = Inflector::plural($model);
     }
     // Can we set a sensible foreign key?
     if (empty($this->_foreign_key)) {
         $this->_foreign_key = $model . '_id';
     }
     if (empty($this->_unique_key) and method_exists(Jam::class_name($this->_model), 'unique_key')) {
         $this->_unique_key = Jam::class_name($this->_model) . '::unique_key';
     }
     foreach ($this->_fields as $column => $field) {
         // Ensure a default primary key is set
         if ($field instanceof Jam_Field and $field->primary and empty($this->_primary_key)) {
             $this->_primary_key = $column;
         }
         // Ensure a default plymorphic key is set
         if ($field instanceof Jam_Field_Polymorphic and empty($this->_polymorphic_key)) {
             $this->_polymorphic_key = $column;
         }
     }
     foreach ($this->_associations as $column => &$association) {
         $association->initialize($this, $column);
     }
     foreach ($this->_fields as $column => &$field) {
         $field->initialize($this, $column);
         $this->_defaults[$column] = $field->default;
     }
     if (!$this->_collection and $class = Jam::collection_prefix() . Jam::capitalize_class_name($this->_model) and class_exists($class)) {
         $this->_collection = $class;
     }
     // Meta object is initialized and no longer writable
     $this->_initialized = TRUE;
     // Final meta callback
     $this->_events->trigger('meta.after_finalize', $this);
 }
开发者ID:openbuildings,项目名称:jam,代码行数:75,代码来源:Meta.php


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