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


PHP Kit::get方法代码示例

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


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

示例1: onLoad

 /**
  * (non-PHPdoc)
  * @see BPCPageAbstract::onLoad()
  */
 public function onLoad($param)
 {
     parent::onLoad($param);
     if (!$this->isPostBack) {
         $this->kit = Kit::get($this->Request['kitId']);
         if (!$this->kit instanceof Kit) {
             die('Invalid Kit!');
         }
         if (isset($_REQUEST['pdf']) && intval($_REQUEST['pdf']) === 1) {
             $file = EntityToPDF::getPDF($this->kit);
             header('Content-Type: application/pdf');
             // The PDF source is in original.pdf
             readfile($file);
             die;
         }
         if (isset($_REQUEST['printlater']) && intval($_REQUEST['printlater']) === 1) {
             $this->getClientScript()->registerEndScript('printlater', 'window.print();');
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:24,代码来源:Controller.php

示例2: saveItem

 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $kit = !isset($param->CallbackParameter->id) ? new Kit() : Kit::get(trim($param->CallbackParameter->id));
         if (!$kit instanceof Kit) {
             throw new Exception('Invalid Kit passed in!');
         }
         if (!isset($param->CallbackParameter->productId) || !($product = Product::get(trim($param->CallbackParameter->productId))) instanceof Product) {
             throw new Exception('Invalid Kit Product passed in!');
         }
         if (!isset($param->CallbackParameter->items) || count($items = $param->CallbackParameter->items) === 0) {
             throw new Exception('No Kit Components passed in!');
         }
         $task = null;
         if (isset($param->CallbackParameter->taskId) && !($task = Task::get(trim($param->CallbackParameter->taskId))) instanceof Task) {
             throw new Exception('Invalid Task passed in!');
         }
         $underCostReason = '';
         if (isset($param->CallbackParameter->underCostReason) && ($underCostReason = trim($param->CallbackParameter->underCostReason)) === '') {
             throw new Exception('UnderCostReason is Required!');
         }
         $isNewKit = false;
         if (trim($kit->getId()) === '') {
             $kit = Kit::create($product, $task);
             $isNewKit = true;
         } else {
             $kit->setTask($task)->save();
         }
         //add all the components
         foreach ($items as $item) {
             if (!($componentProduct = Product::get(trim($item->productId))) instanceof Product) {
                 continue;
             }
             if (($componentId = trim($item->id)) === '' && intval($item->active) === 1) {
                 $kit->addComponent($componentProduct, intval($item->qty));
             } else {
                 if (($kitComponent = KitComponent::get($componentId)) instanceof KitComponent) {
                     if ($kitComponent->getKit()->getId() !== $kit->getId()) {
                         continue;
                     }
                     if (intval($item->active) === 0) {
                         //deactivation
                         $kitComponent->setActive(false)->save();
                     } else {
                         $kitComponent->setQty(intval($item->qty))->save();
                     }
                 }
             }
         }
         if (trim($underCostReason) !== '') {
             $kit->addComment('The reason for continuing bulding this kit, when its cost is greater than its unit price: ' . $underCostReason, Comments::TYPE_WORKSHOP);
         }
         if ($isNewKit === true) {
             $kit->finishedAddingComponents();
         }
         $results['url'] = '/kit/' . $kit->getId() . '.html' . (trim($_SERVER['QUERY_STRING']) === '' ? '' : '?' . $_SERVER['QUERY_STRING']);
         if ($isNewKit === true) {
             $results['printUrl'] = '/print/kit/' . $kit->getId() . '.html?printlater=1';
         }
         $results['createdFromNew'] = $isNewKit;
         $results['item'] = $kit->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . '<pre>' . $ex->getTraceAsString() . '</pre>';
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:74,代码来源:Controller.php


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