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


PHP ObjectManager::create方法代码示例

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


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

示例1: createState

 /**
  * Create state object
  *
  * @param string $cardType
  * @return \Magento\Centinel\Model\AbstractState|false
  */
 public function createState($cardType)
 {
     if (!isset($this->_stateClassMap[$cardType])) {
         return false;
     }
     return $this->_objectManager->create($this->_stateClassMap[$cardType]);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:StateFactory.php

示例2: create

 /**
  * Create new calculator
  *
  * @param string $type Type of calculator
  * @param int $storeId
  * @param Address $billingAddress
  * @param Address $shippingAddress
  * @param null|int $customerTaxClassId
  * @param null|int $customerId
  * @return \Magento\Tax\Model\Calculation\AbstractCalculator
  * @throws \InvalidArgumentException
  */
 public function create($type, $storeId, Address $billingAddress = null, Address $shippingAddress = null, $customerTaxClassId = null, $customerId = null)
 {
     switch ($type) {
         case self::CALC_UNIT_BASE:
             $className = 'Magento\\Tax\\Model\\Calculation\\UnitBaseCalculator';
             break;
         case self::CALC_ROW_BASE:
             $className = 'Magento\\Tax\\Model\\Calculation\\RowBaseCalculator';
             break;
         case self::CALC_TOTAL_BASE:
             $className = 'Magento\\Tax\\Model\\Calculation\\TotalBaseCalculator';
             break;
         default:
             throw new \InvalidArgumentException('Unknown calculation type: ' . $type);
     }
     /** @var \Magento\Tax\Model\Calculation\AbstractCalculator $calculator */
     $calculator = $this->objectManager->create($className, ['storeId' => $storeId]);
     if (null != $shippingAddress) {
         $calculator->setShippingAddress($shippingAddress);
     }
     if (null != $billingAddress) {
         $calculator->setBillingAddress($billingAddress);
     }
     if (null != $customerTaxClassId) {
         $calculator->setCustomerTaxClassId($customerTaxClassId);
     }
     if (null != $customerId) {
         $calculator->setCustomerId($customerId);
     }
     return $calculator;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:43,代码来源:CalculatorFactory.php

示例3: create

 /**
  * Create link builder instance
  *
  * @param string $instance
  * @param array $arguments
  * @return CopyConstructorInterface
  * @throws \InvalidArgumentException
  */
 public function create($instance, array $arguments = array())
 {
     if (!is_subclass_of($instance, '\\Magento\\Catalog\\Model\\Product\\CopyConstructorInterface')) {
         throw new \InvalidArgumentException($instance . ' does not implement \\Magento\\Catalog\\Model\\Product\\CopyConstructorInterface');
     }
     return $this->objectManager->create($instance, $arguments);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:CopyConstructorFactory.php

示例4: setUp

 protected function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->builder = $this->objectManager->create('Magento\\Tax\\Service\\V1\\Data\\QuoteDetailsBuilder');
     $this->itemBuilder = $this->objectManager->create('Magento\\Tax\\Service\\V1\\Data\\QuoteDetails\\ItemBuilder');
     $this->addressBuilder = $this->objectManager->create('\\Magento\\Customer\\Service\\V1\\Data\\AddressBuilder');
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:7,代码来源:QuoteDetailsBuilderTest.php

示例5: create

 /**
  * Create handler instance
  *
  * @param string $instance
  * @param array $arguments
  * @return object
  * @throws \InvalidArgumentException
  */
 public function create($instance, array $arguments = array())
 {
     if (!is_subclass_of($instance, '\\Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper\\HandlerInterface')) {
         throw new \InvalidArgumentException($instance . ' does not implement ' . 'Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper\\HandlerInterface');
     }
     return $this->objectManager->create($instance, $arguments);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:HandlerFactory.php

示例6: _getSubject

 /**
  * Retrieve subject
  *
  * @return \Magento\Backend\Model\Config\Structure\Element\Group
  */
 protected function _getSubject()
 {
     if (!$this->_subject) {
         $this->_subject = $this->_objectManager->create('Magento\\Backend\\Model\\Config\\Structure\\Element\\Group');
     }
     return $this->_subject;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Proxy.php

示例7: setUp

 public function setUp()
 {
     $directoryList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Filesystem\\DirectoryList', array('root' => \Magento\Framework\App\Filesystem::ROOT_DIR, 'directories' => array(\Magento\Framework\App\Filesystem::MODULES_DIR => array('path' => dirname(__DIR__)))));
     $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Filesystem', array('directoryList' => $directoryList));
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_model = $this->_objectManager->create('Magento\\Persistent\\Model\\Persistent\\Config', array('filesystem' => $filesystem));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:ConfigTest.php

示例8: testInitForm

 public function testInitForm()
 {
     $this->setupExistingCustomerData();
     $block = $this->_objectManager->create('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Addresses');
     /** @var Addresses $block */
     $block = $block->initForm();
     /** @var \Magento\Framework\Data\Form $form */
     $form = $block->getForm();
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Fieldset', $form->getElement('address_fieldset'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('prefix'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('firstname'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('middlename'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('lastname'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('suffix'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('company'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Multiline', $form->getElement('street'));
     $this->assertEquals(2, $form->getElement('street')->getLineCount());
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('city'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Select', $form->getElement('country_id'));
     $this->assertEquals('US', $form->getElement('country_id')->getValue());
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('region'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Hidden', $form->getElement('region_id'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('postcode'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('telephone'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('fax'));
     $this->assertInstanceOf('Magento\\Framework\\Data\\Form\\Element\\Text', $form->getElement('vat_id'));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:27,代码来源:AddressesTest.php

示例9: setUp

 protected function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_builder = $this->_objectManager->create('Magento\\Customer\\Service\\V1\\Data\\CustomerDetailsBuilder');
     $this->_customerBuilder = $this->_objectManager->create('Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder');
     $this->_addressBuilder = $this->_objectManager->create('Magento\\Customer\\Service\\V1\\Data\\AddressBuilder');
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:CustomerDetailsBuilderTest.php

示例10: create

 /**
  * @param string $className
  * @return \Magento\ImportExport\Model\Export\Entity\AbstractEntity|\Magento\ImportExport\Model\Export\AbstractEntity
  * @throws \InvalidArgumentException
  */
 public function create($className)
 {
     if (!$className) {
         throw new \InvalidArgumentException('Incorrect class name');
     }
     return $this->_objectManager->create($className);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Factory.php

示例11: create

 /**
  * @param string $type
  * @return \Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface
  * @throws \InvalidArgumentException
  */
 public function create($type)
 {
     if (!isset($this->classByType[$type])) {
         throw new \InvalidArgumentException($type . ' is unknown type');
     }
     return $this->_objectManager->create($this->classByType[$type]);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:CalculatorFactory.php

示例12: create

 /**
  * @param string $indexerInstanceName
  * @return \Magento\Index\Model\Indexer\AbstractIndexer|null
  */
 public function create($indexerInstanceName)
 {
     if ($indexerInstanceName) {
         return $this->_objectManager->create($indexerInstanceName);
     }
     return null;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Factory.php

示例13: create

 /**
  * Create layer filter
  *
  * @param string $className
  * @param array $data
  * @return \Magento\Catalog\Model\Layer\Filter\Attribute
  * @throws \Magento\Framework\Model\Exception
  */
 public function create($className, array $data = array())
 {
     $filter = $this->_objectManager->create($className, $data);
     if (!$filter instanceof \Magento\Catalog\Model\Layer\Filter\AbstractFilter) {
         throw new \Magento\Framework\Model\Exception($className . ' doesn\'t extends \\Magento\\Catalog\\Model\\Layer\\Filter\\AbstractFilter');
     }
     return $filter;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Factory.php

示例14: create

 /**
  * Create price model for product of particular type
  *
  * @param string $className
  * @param array $data
  * @return \Magento\Catalog\Model\Product\Type\Price
  * @throws \Magento\Framework\Model\Exception
  */
 public function create($className, array $data = array())
 {
     $price = $this->_objectManager->create($className, $data);
     if (!$price instanceof \Magento\Catalog\Model\Product\Type\Price) {
         throw new \Magento\Framework\Model\Exception($className . ' doesn\'t extends \\Magento\\Catalog\\Model\\Product\\Type\\Price');
     }
     return $price;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Factory.php

示例15: create

 /**
  * Creates new instances of payment method models
  *
  * @param string $className
  * @param array $data
  * @return \Magento\Payment\Model\MethodInterface
  * @throws \Magento\Framework\Model\Exception
  */
 public function create($className, $data = array())
 {
     $method = $this->_objectManager->create($className, $data);
     if (!$method instanceof \Magento\Payment\Model\MethodInterface) {
         throw new \Magento\Framework\Model\Exception(sprintf("%s class doesn't implement \\Magento\\Payment\\Model\\MethodInterface", $className));
     }
     return $method;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Factory.php


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