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


PHP MShop\Factory类代码示例

本文整理汇总了PHP中Aimeos\MShop\Factory的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testProcess

 public function testProcess()
 {
     $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $search = $manager->createSearch();
     $search->setSlice(0, 1);
     $result = $manager->searchItems($search);
     if (($customerItem = reset($result)) === false) {
         throw new \RuntimeException('No customer item found');
     }
     $addrItem = $customerItem->getPaymentAddress();
     $addrItem->setEmail('unittest@aimeos.org');
     $basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $basketCntl->setAddress($type, $addrItem);
     $view = \TestHelperHtml::getView();
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, array('cs_option_account' => 1));
     $view->addHelper('param', $helper);
     $view->orderBasket = $basketCntl->get();
     $this->context->setView($view);
     $this->object->setView($view);
     $orderBaseStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     $orderBaseStub->expects($this->once())->method('saveItem');
     $customerStub->expects($this->once())->method('saveItem');
     \Aimeos\MShop\Factory::injectManager($this->context, 'customer', $customerStub);
     \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $orderBaseStub);
     $this->object->process();
 }
开发者ID:aimeos,项目名称:ai-client-html,代码行数:28,代码来源:StandardTest.php

示例2: testSave

 public function testSave()
 {
     $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
     $propManager = \Aimeos\MShop\Factory::createManager($this->context, 'product/property');
     $typeManager = \Aimeos\MShop\Factory::createManager($this->context, 'product/property/type');
     $item = $manager->findItem('CNC');
     $item->setCode('jqadm-test-property');
     $item->setId(null);
     $manager->saveItem($item);
     $typeid = $typeManager->findItem('package-height', array(), 'product')->getId();
     $param = array('characteristic' => array('property' => array('product.property.id' => array(''), 'product.property.typeid' => array($typeid), 'product.property.value' => array('10.0'))));
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
     $this->view->addHelper('param', $helper);
     $this->view->item = $item;
     $result = $this->object->save();
     $search = $propManager->createSearch();
     $search->setConditions($search->compare('==', 'product.property.parentid', $item->getId()));
     $items = $propManager->searchItems($search);
     $manager->deleteItem($item->getId());
     $this->assertNull($this->view->get('errors'));
     $this->assertNull($result);
     $this->assertEquals(1, count($items));
     $this->assertEquals(null, reset($items)->getLanguageId());
     $this->assertEquals('10.0', reset($items)->getValue());
 }
开发者ID:aimeos,项目名称:ai-admin-jqadm,代码行数:25,代码来源:StandardTest.php

示例3: update

 /**
  * Receives a notification from a publisher object
  *
  * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  */
 public function update(\Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null)
 {
     if (!$order instanceof \Aimeos\MShop\Order\Item\Base\Iface) {
         $msg = $this->getContext()->getI18n()->dt('mshop', 'Object is not of required type "%1$s"');
         throw new \Aimeos\MShop\Plugin\Exception(sprintf($msg, '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface'));
     }
     $notAvailable = array();
     if (self::$lock === false) {
         self::$lock = true;
         $couponManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon');
         foreach ($order->getCoupons() as $code => $products) {
             $search = $couponManager->createSearch(true);
             $expr = array($search->compare('==', 'coupon.code.code', $code), $search->getConditions());
             $search->setConditions($search->combine('&&', $expr));
             $search->setSlice(0, 1);
             $results = $couponManager->searchItems($search);
             if (($couponItem = reset($results)) !== false) {
                 $couponProvider = $couponManager->getProvider($couponItem, $code);
                 $couponProvider->updateCoupon($order);
             } else {
                 $notAvailable[$code] = 'coupon.gone';
             }
         }
         self::$lock = false;
     }
     if (count($notAvailable) > 0) {
         $codes = array('coupon' => $notAvailable);
         $msg = $this->getContext()->getI18n()->dt('mshop', 'Coupon in basket is not available any more');
         throw new \Aimeos\MShop\Plugin\Provider\Exception($msg, -1, null, $codes);
     }
     return true;
 }
开发者ID:aimeos,项目名称:aimeos-core,代码行数:39,代码来源:Coupon.php

示例4: testSave

 public function testSave()
 {
     $typeManager = \Aimeos\MShop\Factory::createManager($this->context, 'text/type');
     $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
     $item = $manager->findItem('CNC');
     $item->setCode('jqadm-test');
     $item->setId(null);
     $manager->saveItem($item);
     $param = array('text' => array('langid' => array('de'), 'name' => array('listid' => '', 'content' => 'test name'), 'short' => array('listid' => '', 'content' => 'short desc'), 'long' => array('listid' => '', 'content' => 'long desc'), 'url' => array('listid' => '', 'content' => 'url segment'), 'meta-keyword' => array('listid' => '', 'content' => 'meta keywords'), 'meta-description' => array('listid' => '', 'content' => 'meta desc')));
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
     $this->view->addHelper('param', $helper);
     $this->view->item = $item;
     $result = $this->object->save();
     $item = $manager->getItem($item->getId(), array('text'));
     $manager->deleteItem($item->getId());
     $this->assertNull($this->view->get('errors'));
     $this->assertNull($result);
     $this->assertEquals(6, count($item->getListItems()));
     foreach ($item->getListItems('text') as $listItem) {
         $this->assertEquals('text', $listItem->getDomain());
         $this->assertEquals('default', $listItem->getType());
         $refItem = $listItem->getRefItem();
         $this->assertEquals('de', $refItem->getLanguageId());
     }
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:25,代码来源:StandardTest.php

示例5: getManager

 /**
  * Returns the manager the controller is using.
  *
  * @return \Aimeos\MShop\Common\Manager\Iface Manager object
  */
 protected function getManager()
 {
     if ($this->manager === null) {
         $this->manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'supplier/address');
     }
     return $this->manager;
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:12,代码来源:Standard.php

示例6: testSave

 public function testSave()
 {
     $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
     $item = $manager->findItem('CNE');
     $item->setCode('jqadm-test-download');
     $item->setId(null);
     $manager->saveItem($item);
     $param = array('download' => array('product.lists.id' => '', 'product.lists.status' => '1', 'attribute.label' => 'test'));
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
     $this->view->addHelper('param', $helper);
     $file = $this->getMockBuilder('\\Psr\\Http\\Message\\UploadedFileInterface')->getMock();
     $file->expects($this->any())->method('getError')->will($this->returnValue(UPLOAD_ERR_OK));
     $request = $this->getMockBuilder('\\Psr\\Http\\Message\\ServerRequestInterface')->getMock();
     $request->expects($this->any())->method('getUploadedFiles')->will($this->returnValue(array('download' => array('file' => $file))));
     $helper = new \Aimeos\MW\View\Helper\Request\Standard($this->view, $request);
     $this->view->addHelper('request', $helper);
     $this->view->item = $item;
     $this->object->expects($this->once())->method('storeFile')->will($this->returnValue('test/file.ext'));
     $attributeStub = $this->getMockBuilder('\\Aimeos\\MShop\\Attribute\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     $attributeStub->expects($this->once())->method('saveItem');
     \Aimeos\MShop\Factory::injectManager($this->context, 'attribute', $attributeStub);
     \Aimeos\MShop\Factory::setCache(true);
     $result = $this->object->save();
     \Aimeos\MShop\Factory::setCache(false);
     $item = $manager->getItem($item->getId(), array('attribute'));
     $manager->deleteItem($item->getId());
     $this->assertNull($this->view->get('errors'));
     $this->assertNull($result);
     $this->assertEquals(1, count($item->getListItems('attribute', 'hidden')));
 }
开发者ID:aimeos,项目名称:ai-admin-jqadm,代码行数:30,代码来源:StandardTest.php

示例7: testSave

 public function testSave()
 {
     $manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
     $item = $manager->findItem('CNC');
     $item->setCode('jqadm-test-image');
     $item->setId(null);
     $manager->saveItem($item);
     $param = array('image' => array('product.lists.id' => array(''), 'media.languageid' => array('de'), 'media.label' => array('test')));
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
     $this->view->addHelper('param', $helper);
     $files = array('image' => array('files' => array(array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => 0))));
     $helper = $this->getMockBuilder('\\Aimeos\\MW\\View\\Helper\\Request\\Standard')->setConstructorArgs(array($this->view, '', '', null, $files))->setMethods(array('checkUploadedFile'))->getMock();
     $this->view->addHelper('request', $helper);
     $this->view->item = $item;
     $name = 'AdminJQAdmProductImageSave';
     $this->context->getConfig()->set('controller/common/media/name', $name);
     $cntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Media\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('add'))->getMock();
     \Aimeos\Controller\Common\Media\Factory::injectController('\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub);
     $cntlStub->expects($this->once())->method('add');
     $mediaStub = $this->getMockBuilder('\\Aimeos\\MShop\\Media\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     \Aimeos\MShop\Factory::injectManager($this->context, 'media', $mediaStub);
     $mediaStub->expects($this->once())->method('saveItem');
     \Aimeos\MShop\Factory::setCache(true);
     $result = $this->object->save();
     \Aimeos\MShop\Factory::setCache(false);
     $item = $manager->getItem($item->getId(), array('media'));
     $manager->deleteItem($item->getId());
     $this->assertNull($this->view->get('errors'));
     $this->assertNull($result);
     $this->assertEquals(1, count($item->getListItems('media')));
 }
开发者ID:ajbm6,项目名称:aimeos-core,代码行数:31,代码来源:StandardTest.php

示例8: update

 /**
  * Receives a notification from a publisher object
  *
  * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  * @throws \Aimeos\MShop\Plugin\Exception in case of faulty configuration or parameters
  * @return bool true if attributes have been added successfully
  */
 public function update(\Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null)
 {
     if (!$order instanceof \Aimeos\MShop\Order\Item\Base\Iface) {
         $msg = $this->getContext()->getI18n()->dt('mshop', 'Object is not of required type "%1$s"');
         throw new \Aimeos\MShop\Plugin\Exception(sprintf($msg, '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface'));
     }
     if (!$value instanceof \Aimeos\MShop\Order\Item\Base\Product\Iface) {
         $msg = $this->getContext()->getI18n()->dt('mshop', 'Object is not of required type "%1$s"');
         throw new \Aimeos\MShop\Plugin\Exception(sprintf($msg, '\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface'));
     }
     $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
     $config = $this->getItemBase()->getConfig();
     foreach ($config as $key => $properties) {
         $keyElements = explode('.', $key);
         if ($keyElements[0] !== 'product' || count($keyElements) < 3) {
             $msg = $this->getContext()->getI18n()->dt('mshop', 'Configuration invalid');
             throw new \Aimeos\MShop\Plugin\Exception($msg);
         }
         $productSubManager = $productManager->getSubManager($keyElements[1]);
         $search = $productSubManager->createSearch(true);
         $cond = array();
         $cond[] = $search->compare('==', $key, $value->getProductId());
         $cond[] = $search->getConditions();
         $search->setConditions($search->combine('&&', $cond));
         $result = $productSubManager->searchItems($search);
         foreach ($result as $item) {
             $attributes = $this->addAttributes($item, $value, $properties);
             $value->setAttributes($attributes);
         }
     }
     return true;
 }
开发者ID:aimeos,项目名称:aimeos-core,代码行数:41,代码来源:PropertyAdd.php

示例9: testGetBody

 public function testGetBody()
 {
     $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer');
     $this->context->setUserId($manager->findItem('UTC001')->getId());
     $output = $this->object->getBody();
     $this->assertStringStartsWith('<section class="aimeos account-profile">', $output);
 }
开发者ID:aimeos,项目名称:ai-client-html,代码行数:7,代码来源:StandardTest.php

示例10: update

 /**
  * Receives a notification from a publisher object
  *
  * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  * @throws \Aimeos\MShop\Plugin\Provider\Exception if checks fail
  * @return bool true if checks succeed
  */
 public function update(\Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null)
 {
     $class = '\\Aimeos\\MShop\\Order\\Item\\Base\\Iface';
     if (!$order instanceof $class) {
         throw new \Aimeos\MShop\Plugin\Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $class = '\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface';
     if (!$value instanceof $class) {
         throw new \Aimeos\MShop\Plugin\Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $config = $this->getItemBase()->getConfig();
     if ($config === array()) {
         return true;
     }
     $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
     $criteria = $productManager->createSearch(true);
     $expr = array();
     $expr[] = $criteria->compare('==', 'product.id', $value->getProductId());
     $expr[] = $criteria->getConditions();
     foreach ($config as $property => $value) {
         $expr[] = $criteria->compare('==', $property, $value);
     }
     $criteria->setConditions($criteria->combine('&&', $expr));
     $result = $productManager->searchItems($criteria);
     if (reset($result) === false) {
         $code = array('product' => array_keys($config));
         throw new \Aimeos\MShop\Plugin\Provider\Exception(sprintf('Product matching given properties not found'), -1, null, $code);
     }
     return true;
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:39,代码来源:PropertyMatch.php

示例11: isAvailable

 /**
  * Checks if the the basket weight is ok for the service provider.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
  * @return boolean True if payment provider can be used, false if not
  */
 public function isAvailable(\Aimeos\MShop\Order\Item\Base\Iface $basket)
 {
     $context = $this->getContext();
     $prodMap = array();
     $basketWeight = 0;
     foreach ($basket->getProducts() as $basketItem) {
         $prodId = $basketItem->getProductId();
         // basket can contain a product several times in different basket items
         if (!isset($prodMap[$prodId])) {
             $prodMap[$prodId] = 0.0;
         }
         $prodMap[$prodId] += $basketItem->getQuantity();
     }
     $propertyManager = \Aimeos\MShop\Factory::createManager($context, 'product/property');
     $search = $propertyManager->createSearch(true);
     $expr = array($search->compare('==', 'product.property.parentid', array_keys($prodMap)), $search->compare('==', 'product.property.type.code', 'package-weight'), $search->getConditions());
     $search->setConditions($search->combine('&&', $expr));
     $search->setSlice(0, 0x7fffffff);
     // if more than 100 products are in the basket
     foreach ($propertyManager->searchItems($search) as $property) {
         $basketWeight += (double) $property->getValue() * $prodMap[$property->getParentId()];
     }
     if ($this->checkWeightScale($basketWeight) === false) {
         return false;
     }
     return $this->getProvider()->isAvailable($basket);
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:33,代码来源:Weight.php

示例12: update

 protected function update(array $list)
 {
     $map = array();
     $manager = \Aimeos\MShop\Factory::createManager($this->additional, 'product/property');
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'product.property.code', array_keys($list)));
     $search->setSlice(0, count($list));
     foreach ($manager->searchItems($search) as $id => $item) {
         $map[$item->getCode()] = $item;
     }
     $manager->begin();
     foreach ($list as $code => $entry) {
         if (!isset($map[$code])) {
             $item = $manager->createItem();
         } else {
             $item = $map[$code];
         }
         $item->setParentId('...');
         $item->setValue($entry['value']);
         $item->setStatus(!(bool) $entry['hidden']);
         $item->setTypeId($this->getTypeId('product/property/type', 'product', $entry['title']));
         $manager->saveItem($item);
     }
     $manager->commit();
 }
开发者ID:aimeoscom,项目名称:ai-migrate-txcommerce,代码行数:25,代码来源:TxCommerceMigrateProperties.php

示例13: testSaveItemLabelContent

 public function testSaveItemLabelContent()
 {
     $typeManager = \Aimeos\MShop\Factory::createManager(\TestHelperExtjs::getContext(), 'text/type');
     $criteria = $typeManager->createSearch();
     $criteria->setSlice(0, 1);
     $result = $typeManager->searchItems($criteria);
     if (($type = reset($result)) === false) {
         throw new \Exception('No type item found');
     }
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('text.content' => 'controller test text', 'text.domain' => 'product', 'text.typeid' => $type->getId(), 'text.languageid' => 'de', 'text.status' => 1));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('text.content' => 'controller test text')))));
     $saved = $this->object->saveItems($saveParams);
     $searched = $this->object->searchItems($searchParams);
     $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'text.id'});
     $this->object->deleteItems($deleteParams);
     $result = $this->object->searchItems($searchParams);
     $this->assertInternalType('object', $saved['items']);
     $this->assertNotNull($saved['items']->{'text.id'});
     $this->assertEquals($saved['items']->{'text.id'}, $searched['items'][0]->{'text.id'});
     $this->assertEquals($saved['items']->{'text.content'}, $searched['items'][0]->{'text.content'});
     $this->assertEquals($saved['items']->{'text.domain'}, $searched['items'][0]->{'text.domain'});
     $this->assertEquals($saved['items']->{'text.typeid'}, $searched['items'][0]->{'text.typeid'});
     $this->assertEquals($saved['items']->{'text.content'}, $searched['items'][0]->{'text.label'});
     $this->assertEquals($saved['items']->{'text.languageid'}, $searched['items'][0]->{'text.languageid'});
     $this->assertEquals($saved['items']->{'text.status'}, $searched['items'][0]->{'text.status'});
     $this->assertEquals(1, count($searched['items']));
     $this->assertEquals(0, count($result['items']));
     $this->assertEquals('controller test text', $saved['items']->{'text.label'});
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:29,代码来源:StandardTest.php

示例14: bootstrap

 public static function bootstrap()
 {
     set_error_handler('TestHelperExtjs::errorHandler');
     self::getAimeos();
     \Aimeos\MShop\Factory::setCache(false);
     \Aimeos\Controller\ExtJS\Factory::setCache(false);
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:7,代码来源:TestHelperExtjs.php

示例15: testProcess

 public function testProcess()
 {
     $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
     $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
     $search = $manager->createSearch();
     $search->setSlice(0, 1);
     $result = $manager->searchItems($search);
     if (($customerItem = reset($result)) === false) {
         throw new \Exception('No customer item found');
     }
     $addrItem = $customerItem->getPaymentAddress();
     $addrItem->setEmail('unittest@aimeos.org');
     $mailStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\None')->disableOriginalConstructor()->getMock();
     $mailMsgStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\Message\\None')->disableOriginalConstructor()->disableOriginalClone()->getMock();
     $mailStub->expects($this->once())->method('createMessage')->will($this->returnValue($mailMsgStub));
     $mailStub->expects($this->once())->method('send');
     $this->context->setMail($mailStub);
     $basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
     $basketCntl->setAddress($type, $addrItem);
     $view = \TestHelperHtml::getView();
     $view->orderBasket = $basketCntl->get();
     $this->context->setView($view);
     $this->object->setView($view);
     $orderBaseStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
     $orderBaseStub->expects($this->once())->method('saveItem');
     $customerStub->expects($this->once())->method('saveItem');
     \Aimeos\MShop\Factory::injectManager($this->context, 'customer', $customerStub);
     \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $orderBaseStub);
     $this->object->process();
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:31,代码来源:StandardTest.php


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