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


PHP ModelBase::fromArray方法代码示例

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


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

示例1: fromArray

 /**
  * Redo the following three functions to pull from a common ValidationFields array that contains information 
  * about if they're required, what their rules are and whether or not they should be visible in an array version of the model.
  */
 public static function fromArray(array $arr, $mode = "add")
 {
     $res = parent::fromArray($arr, $mode);
     return $res;
 }
开发者ID:nadeemshafique,项目名称:entrada-1x,代码行数:9,代码来源:ObservershipReflection.class.php

示例2: fromArray

 /**
  * Redo the following three functions to pull from a common ValidationFields array that contains information 
  * about if they're required, what their rules are and whether or not they should be visible in an array version of the model.
  */
 public static function fromArray(array $arr, $mode = "add", $proxy_id = false)
 {
     global $ENTRADA_USER;
     $res = parent::fromArray($arr, $mode);
     if ($res && $mode != "fetch") {
         //due to the way generate_calendars works this is a necessary step
         $res->start = isset($res->observership_start_date) ? strtotime($res->observership_start_date) : (isset($res->start) ? $res->start : 0);
         $res->end = isset($res->observership_finish_date) ? strtotime($res->observership_finish_date) : (isset($res->end) ? $res->end : 0);
         if (!$res->start) {
             add_error("<strong>Observership Start</strong> is a required field. Please ensure you've provided a value.");
             $res->VALID = false;
         }
         if ($ENTRADA_USER->getGroup() != "staff" && $ENTRADA_USER->getGroup() != "medtech" && $res->start < strtotime(date("Y-m-d", time()))) {
             add_error("Entry of historical observerships is not available, any entered observership must start tomorrow or later.");
             $res->VALID = false;
         }
         if ($ENTRADA_USER->getGroup() == "staff" || $ENTRADA_USER->getGroup() == "medtech") {
             $res->status = "approved";
         }
         if (!$res->end) {
             $res->end = $res->start;
         }
         if ($res->end < $res->start) {
             add_error("<strong>Observership Start</strong> is before <strong>Observership End</strong>.");
             $res->VALID = false;
         }
         //if proxy id set, map it to the field used by Model/database
         if (isset($arr["preceptor_associated_director"]) && $arr["preceptor_associated_director"]) {
             $res->preceptor_proxy_id = (int) $arr["preceptor_associated_director"];
             $res->preceptor_firstname = "";
             $res->preceptor_lastname = "";
             $res->preceptor_email = "";
         } elseif (!(isset($arr["preceptor_associated_director"]) && $arr["preceptor_associated_director"]) && !(isset($arr["preceptor_firstname"]) && $arr["preceptor_firstname"] && isset($arr["preceptor_lastname"]) && $arr["preceptor_lastname"] && isset($arr["preceptor_email"]) && $arr["preceptor_email"])) {
             //if no proxy id, and no manually entered data, data is invalid and error needs to display
             add_error("<strong>Preceptor</strong> is a required field. Please ensure you've provided a value.");
             $res->VALID = false;
         } else {
             $res->preceptor_proxy_id = "";
         }
         if (isset($arr["activity_type"]) && $arr["activity_type"] == "ipobservership") {
             if (!isset($arr["observership_details"]) || !$arr["observership_details"] || trim($arr["observership_details"]) == "") {
                 add_error("<strong>Observership Details</strong> is a required field. Please ensure you've provided a value.");
                 $res->VALID = false;
             }
         }
         if (!isset($arr["activity_type"]) || trim($arr["activity_type"]) == "") {
             add_error("<strong>Activity Type</strong> is a required field. Please ensure you've provided a value.");
         }
         if (!isset($arr["clinical_discipline"]) || trim($arr["clinical_discipline"]) == "") {
             add_error("<strong>Eligible Clinical Disciplines</strong> is a required field. Please ensure you've provided a value.");
         }
         if (!isset($arr["organisation"]) || trim($arr["organisation"]) == "") {
             add_error("<strong>Organisation</strong> is a required field. Please ensure you've provided a value.");
         }
         if (!isset($arr["address_l1"]) || trim($arr["address_l1"]) == "") {
             add_error("<strong>Address Line 1</strong> is a required field. Please ensure you've provided a value.");
         }
         if (!isset($arr["city"]) || trim($arr["city"]) == "") {
             add_error("<strong>City</strong> is a required field. Please ensure you've provided a value.");
         }
         if (trim($arr["prov_state"]) == "0") {
             add_error("<strong>Province</strong> is a required field. Please ensure you've provided a value.");
         }
         if ($mode == "add") {
             if (!isset($arr["read"]) || !trim($arr["read"])) {
                 add_error("You must agree to the procedures and regulations of the Student Observership policy.");
                 $res->VALID = false;
             }
         }
         $res->student_id = $proxy_id ? $proxy_id : $ENTRADA_USER->getActiveId();
     }
     return $res;
 }
开发者ID:nadeemshafique,项目名称:entrada-1x,代码行数:77,代码来源:Observership.class.php


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