本文整理汇总了PHP中Aimeos\MShop\Factory::createManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::createManager方法的具体用法?PHP Factory::createManager怎么用?PHP Factory::createManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aimeos\MShop\Factory
的用法示例。
在下文中一共展示了Factory::createManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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')));
}
示例2: 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(), 'customer/group');
}
return $this->manager;
}
示例3: 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());
}
示例4: 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;
}
示例5: 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'});
}
示例6: 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());
}
}
示例7: 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')));
}
示例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\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;
}
示例9: 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);
}
示例10: testAddProductNoCategory
public function testAddProductNoCategory()
{
$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
$item = $manager->findItem('ABCD');
$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
$this->object->addProduct($item->getId(), 5);
}
示例11: update
protected function update(array $list)
{
$pos = 0;
$map = array();
$manager = \Aimeos\MShop\Factory::createManager($this->additional, 'attribute');
$search = $manager->createSearch();
$search->setConditions($search->compare('==', 'attribute.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];
}
$typeid = $this->getTypeId('attribute/type', 'product', $entry['title']);
$item->setTypeId($typeid);
$item->setDomain('product');
$item->setCode($entry['value']);
$item->setLabel($entry['value']);
$item->setStatus(!(bool) $entry['hidden']);
$item->setPosition($pos++);
$manager->saveItem($item);
}
$manager->commit();
}
示例12: getStockItems
/**
* Returns the product properties for the given product ID
*
* @param string $prodid Unique product ID
* @return array Associative list of product stock items
*/
protected function getStockItems($prodid)
{
$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock');
$search = $manager->createSearch();
$search->setConditions($search->compare('==', 'product.stock.productid', $prodid));
return $manager->searchItems($search);
}
示例13: 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;
}
示例14: 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();
}
示例15: 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);
}