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


PHP CategoryModel::populateModel方法代码示例

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


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

示例1: onBeforeSaveCategory

 /**
  * Handle the onBeforeSaveCategory event.
  *
  * @param Event $event
  */
 public function onBeforeSaveCategory(Event $event)
 {
     // Get category id to save
     $id = $event->params['category']->id;
     if (!$event->params['isNewCategory']) {
         // Get old category from db
         $category = CategoryModel::populateModel(CategoryRecord::model()->findById($id));
         // Get fields
         $this->before = $this->fields($category);
     } else {
         // Get fields
         $this->before = $this->fields($event->params['category'], true);
     }
 }
开发者ID:boboldehampsink,项目名称:auditlog,代码行数:19,代码来源:AuditLog_CategoryService.php

示例2: populateElementModel

 /**
  * @inheritDoc IElementType::populateElementModel()
  *
  * @param array $row
  *
  * @return array
  */
 public function populateElementModel($row)
 {
     return CategoryModel::populateModel($row);
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:11,代码来源:CategoryElementType.php

示例3: log

 /**
  * Initialize the category saving/deleting events.
  */
 public function log()
 {
     // Get values before saving
     craft()->on('categories.onBeforeSaveCategory', function (Event $event) {
         // Get category id to save
         $id = $event->params['category']->id;
         if (!$event->params['isNewCategory']) {
             // Get old category from db
             $category = CategoryModel::populateModel(CategoryRecord::model()->findById($id));
             // Get fields
             craft()->auditLog_category->before = craft()->auditLog_category->fields($category);
         } else {
             // Get fields
             craft()->auditLog_category->before = craft()->auditLog_category->fields($event->params['category'], true);
         }
     });
     // Get values after saving
     craft()->on('categories.onSaveCategory', function (Event $event) {
         // Get saved category
         $category = $event->params['category'];
         // Get fields
         craft()->auditLog_category->after = craft()->auditLog_category->fields($category);
         // New row
         $log = new AuditLogRecord();
         // Get user
         $user = craft()->userSession->getUser();
         // Set user id
         $log->userId = $user ? $user->id : null;
         // Set element type
         $log->type = ElementType::Category;
         // Set origin
         $log->origin = craft()->request->isCpRequest() ? craft()->config->get('cpTrigger') . '/' . craft()->request->path : craft()->request->path;
         // Set before
         $log->before = craft()->auditLog_category->before;
         // Set after
         $log->after = craft()->auditLog_category->after;
         // Set status
         $log->status = $event->params['isNewCategory'] ? AuditLogModel::CREATED : AuditLogModel::MODIFIED;
         // Save row
         $log->save(false);
         // Callback
         craft()->auditLog->elementHasChanged(ElementType::Category, $category->id, craft()->auditLog_category->before, craft()->auditLog_category->after);
     });
     // Get values before deleting
     craft()->on('categories.onBeforeDeleteCategory', function (Event $event) {
         // Get deleted category
         $category = $event->params['category'];
         // Get fields
         craft()->auditLog_category->before = craft()->auditLog_category->fields($category);
         craft()->auditLog_category->after = craft()->auditLog_category->fields($category, true);
         // New row
         $log = new AuditLogRecord();
         // Set user id
         $log->userId = craft()->userSession->getUser()->id;
         // Set element type
         $log->type = ElementType::Category;
         // Set origin
         $log->origin = craft()->request->isCpRequest() ? craft()->config->get('cpTrigger') . '/' . craft()->request->path : craft()->request->path;
         // Set before
         $log->before = craft()->auditLog_category->before;
         // Set after
         $log->after = craft()->auditLog_category->after;
         // Set status
         $log->status = AuditLogModel::DELETED;
         // Save row
         $log->save(false);
         // Callback
         craft()->auditLog->elementHasChanged(ElementType::Category, $category->id, craft()->auditLog_category->before, craft()->auditLog_category->after);
     });
 }
开发者ID:webremote,项目名称:auditlog,代码行数:73,代码来源:AuditLog_CategoryService.php


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