本文整理汇总了PHP中Aimeos\MW\View\Iface::value方法的典型用法代码示例。如果您正苦于以下问题:PHP Iface::value方法的具体用法?PHP Iface::value怎么用?PHP Iface::value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aimeos\MW\View\Iface
的用法示例。
在下文中一共展示了Iface::value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateItems
/**
* Updates existing product image references or creates new ones
*
* @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters
*/
protected function updateItems(\Aimeos\MW\View\Iface $view)
{
$id = $view->item->getId();
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
$mediaManager = \Aimeos\MShop\Factory::createManager($context, 'media');
$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
$cntl = \Aimeos\Controller\Common\Media\Factory::createController($context);
$listIds = (array) $view->param('image/product.lists.id', array());
$listItems = $manager->getItem($id, array('media'))->getListItems('media', 'default');
$mediaItem = $this->createItem();
$listItem = $this->createListItem($id);
$files = $view->value($view->request()->getUploadedFiles(), 'image/files', array());
$num = 0;
foreach ($listIds as $idx => $listid) {
if (!isset($listItems[$listid])) {
$litem = $listItem;
$litem->setId(null);
if (($file = $view->value($files, $num)) !== null) {
$item = $mediaItem;
$item->setId(null);
$cntl->add($item, $file);
$num++;
} else {
throw new \Aimeos\Admin\JQAdm\Exception(sprintf('No file uploaded for %1$d. new image', $num + 1));
}
} else {
$litem = $listItems[$listid];
$item = $litem->getRefItem();
}
$item->setLabel($view->param('image/media.label/' . $idx));
$item->setLanguageId($view->param('image/media.languageid/' . $idx));
$mediaManager->saveItem($item);
$litem->setPosition($idx);
$litem->setRefId($item->getId());
$listManager->saveItem($litem, false);
}
$this->cleanupItems($listItems, $listIds);
}
示例2: updateItems
/**
* Updates existing product image references or creates new ones
*
* @param \Aimeos\MW\View\Iface $view View object with helpers and assigned parameters
*/
protected function updateItems(\Aimeos\MW\View\Iface $view)
{
$id = $view->item->getId();
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
$mediaManager = \Aimeos\MShop\Factory::createManager($context, 'media');
$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
$mediaTypeManager = \Aimeos\MShop\Factory::createManager($context, 'media/type');
$listTypeManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type');
$cntl = \Aimeos\Controller\Common\Media\Factory::createController($context);
$listIds = (array) $view->param('image/product.lists.id', array());
$listItems = $manager->getItem($id, array('media'))->getListItems('media');
$listItem = $listManager->createItem();
$listItem->setTypeId($listTypeManager->findItem('default', array(), 'media')->getId());
$listItem->setDomain('media');
$listItem->setParentId($id);
$listItem->setStatus(1);
$mediaItem = $mediaManager->createItem();
$mediaItem->setTypeId($mediaTypeManager->findItem('default', array(), 'product')->getId());
$mediaItem->setDomain('product');
$mediaItem->setStatus(1);
$files = $view->value($view->request()->getUploadedFiles(), 'image/files', array());
$files = is_array($files) ? $files : array($files);
$num = 0;
foreach ($listIds as $idx => $listid) {
if (!isset($listItems[$listid])) {
$litem = $listItem;
$litem->setId(null);
if (($file = $view->value($files, $num)) === null) {
throw new \Aimeos\Admin\JQAdm\Exception(sprintf('No uploaded file for %1$d. new entry ', $num));
}
$cntl->add($mediaItem, $file);
$num++;
} else {
$litem = $listItems[$listid];
$item = $litem->getRefItem();
}
$mediaItem->setLabel($view->param('image/media.label/' . $idx));
$mediaItem->setLanguageId($view->param('image/media.languageid/' . $idx));
$mediaManager->saveItem($mediaItem);
$litem->setPosition($idx);
$litem->setRefId($mediaItem->getId());
$listManager->saveItem($litem, false);
}
$rmIds = array();
$rmListIds = array_diff(array_keys($listItems), $listIds);
foreach ($rmListIds as $rmListId) {
$item = $listItems[$rmListId]->getRefItem();
$cntl->delete($item);
$rmIds[] = $item->getId();
}
$listManager->deleteItems($rmListIds);
$mediaManager->deleteItems($rmIds);
}