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


PHP EEM_Base::ensure_is_obj方法代码示例

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


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

示例1: populate_model_obj

 /**
  * Mostly the same as populate_defaults , except takes a model object as input, not an array,
  * and also sets the form's _model_object
  * @param EE_Base_Class $model_obj
  * @return void
  */
 public function populate_model_obj($model_obj)
 {
     $model_obj = $this->_model->ensure_is_obj($model_obj);
     $this->_model_object = $model_obj;
     $defaults = $model_obj->model_field_array();
     foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) {
         $form_inputs = $this->inputs();
         if (isset($form_inputs[$relation_name])) {
             if ($relation_obj instanceof EE_Belongs_To_Relation) {
                 //then we only expect there to be one
                 $related_item = $this->_model_object->get_first_related($relation_name);
                 $defaults[$relation_name] = $related_item->ID();
             } else {
                 $related_items = $this->_model_object->get_many_related($relation_name);
                 $ids = array();
                 foreach ($related_items as $related_item) {
                     $ids[] = $related_item->ID();
                 }
                 $defaults[$relation_name] = $ids;
             }
         }
     }
     $this->populate_defaults($defaults);
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:30,代码来源:EE_Model_Form_Section.form.php

示例2: ensure_is_obj

 /**
  * Overrides parent ot also check by the slug
  * @see EEM_Base::ensure_is_obj()
  * @param string|int|EE_Payment_Method $base_class_obj_or_id
  * @param boolean                      $ensure_is_in_db
  * @return EE_Payment_Method
  * @throws EE_Error
  */
 public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE)
 {
     //first: check if it's a slug
     if (is_string($base_class_obj_or_id)) {
         $obj = $this->get_one_by_slug($base_class_obj_or_id);
         if ($obj) {
             return $obj;
         }
     }
     //ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID)
     try {
         return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db);
     } catch (EE_Error $e) {
         //handle it outside the catch
     }
     throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id));
 }
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:25,代码来源:EEM_Payment_Method.model.php


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