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


PHP Iface::request方法代码示例

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


在下文中一共展示了Iface::request方法的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);
 }
开发者ID:skyheights,项目名称:aimeos-core,代码行数:44,代码来源:Standard.php

示例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);
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:59,代码来源:Standard.php


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