本文整理汇总了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();');
}
}
}
示例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);
}