本文整理汇总了PHP中Magento\Framework\ObjectManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::get方法的具体用法?PHP ObjectManager::get怎么用?PHP ObjectManager::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getSubject
/**
* Retrieve subject
*
* @return \Magento\Backend\Model\Config\Structure\SearchInterface
*/
protected function _getSubject()
{
if (!$this->_subject) {
$this->_subject = $this->_objectManager->get('Magento\\Backend\\Model\\Config\\Structure');
}
return $this->_subject;
}
示例2: testGetGridParentHtml
public function testGetGridParentHtml()
{
$this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Cart', '', array());
$mockCollection = $this->getMockBuilder('\\Magento\\Framework\\Data\\Collection')->disableOriginalConstructor()->getMock();
$this->_block->setCollection($mockCollection);
$this->assertContains("<div class=\"grid-actions\">", $this->_block->getGridParentHtml());
}
示例3: setUp
public function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_persistentSession = $this->_objectManager->get('Magento\\Persistent\\Helper\\Session');
$this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
$this->_model = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\Session', ['persistentSession' => $this->_persistentSession, 'customerSession' => $this->_customerSession]);
}
示例4: modifyPrice
/**
* Modify price
*
* @param mixed $price
* @param Product $product
* @return mixed
*/
public function modifyPrice($price, Product $product)
{
foreach ($this->modifiers as $modifierClass) {
$price = $this->objectManager->get($modifierClass)->modifyPrice($price, $product);
}
return $price;
}
示例5: setUp
protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->helper = $this->objectManager->get('Magento\\Catalog\\Helper\\Data');
$this->taxRuleFixtureFactory = new TaxRuleFixtureFactory();
$this->scopeConfig = $this->objectManager->get('Magento\\Framework\\App\\MutableScopeConfig');
}
示例6: get
/**
* Get Installer Db type instance
*
* @param string $type
* @return \Magento\Install\Model\Installer\Db\AbstractDb | bool
* @throws \InvalidArgumentException
*/
public function get($type)
{
if (!empty($type) && isset($this->_types[(string) $type])) {
return $this->_objectManager->get($this->_types[(string) $type]);
}
return false;
}
示例7: __wakeup
public function __wakeup()
{
$this->pluginLocator = \Magento\Framework\App\ObjectManager::getInstance();
$this->pluginList = $this->pluginLocator->get('Magento\\Framework\\Interception\\PluginList');
$this->chain = $this->pluginLocator->get('Magento\\Framework\\Interception\\Chain');
$this->subjectType = get_parent_class($this);
}
示例8: testApplyAllDataUpdates
public function testApplyAllDataUpdates()
{
/*reset versions*/
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\ResourceInterface')->setDbVersion('adminnotification_setup', false);
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\ResourceInterface')->setDataVersion('adminnotification_setup', false);
$this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup');
$this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox'));
$this->_model->getConnection()->dropTable($this->_model->getTable('admin_system_messages'));
/** @var \Magento\Framework\Cache\FrontendInterface $cache */
$cache = $this->_objectManager->get('Magento\\Framework\\App\\Cache\\Type\\Config');
$cache->clean();
try {
/* This triggers plugin to be executed */
$this->dispatch('index/index');
} catch (\Exception $e) {
$this->fail("Impossible to continue other tests, because database is broken: {$e}");
}
try {
$tableData = $this->_model->getConnection()->describeTable($this->_model->getTable('adminnotification_inbox'));
$this->assertNotEmpty($tableData);
} catch (\Exception $e) {
$this->fail("Impossible to continue other tests, because database is broken: {$e}");
}
$this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version'));
$this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version'));
}
示例9: setUp
public function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_persistentSession = $this->_objectManager->get('Magento\\Persistent\\Helper\\Session');
$this->_cookieMock = $this->getMock('Magento\\Framework\\Stdlib\\Cookie', array('set'), array(), '', false);
$this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
$this->_model = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\Session', array('persistentSession' => $this->_persistentSession, 'cookie' => $this->_cookieMock, 'customerSession' => $this->_customerSession));
}
示例10: create
/**
* Create specification instance
*
* @param string $specificationClass
* @return SpecificationInterface
* @throws \InvalidArgumentException
*/
public function create($specificationClass)
{
$specification = $this->objectManager->get($specificationClass);
if (!$specification instanceof SpecificationInterface) {
throw new \InvalidArgumentException('Specification must implement SpecificationInterface');
}
return $specification;
}
示例11: create
/**
* Provide custom price model with basic validation
*
* @param string $name
* @return \Magento\Catalog\Model\Product\CatalogPriceInterface
* @throws \UnexpectedValueException
*/
public function create($name)
{
$customPriceModel = $this->objectManager->get($name);
if (!$customPriceModel instanceof \Magento\Catalog\Model\Product\CatalogPriceInterface) {
throw new \UnexpectedValueException('Class ' . $name . ' should be an instance of \\Magento\\Catalog\\Model\\Product\\CatalogPriceInterface');
}
return $customPriceModel;
}
示例12: get
/**
* Gets product of particular type
*
* @param string $className
* @param array $data
* @return \Magento\Catalog\Model\Product\Type\AbstractType
* @throws \Magento\Framework\Model\Exception
*/
public function get($className, array $data = array())
{
$product = $this->_objectManager->get($className, $data);
if (!$product instanceof \Magento\Catalog\Model\Product\Type\AbstractType) {
throw new \Magento\Framework\Model\Exception($className . ' doesn\'t extends \\Magento\\Catalog\\Model\\Product\\Type\\AbstractType');
}
return $product;
}
示例13: setUp
public function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var \Magento\Persistent\Helper\Session $persistentSessionHelper */
$this->_persistentSessionHelper = $this->_objectManager->create('Magento\\Persistent\\Helper\\Session');
$this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
$this->_block = $this->_objectManager->create('Magento\\Persistent\\Block\\Header\\Additional');
}
示例14: setUp
protected function setUp()
{
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Multishipping\\Block\\Checkout\\Overview', 'checkout_overview', array('data' => array('renderer_template' => 'Magento_Multishipping::checkout/item/default.phtml', 'row_renderer_template' => 'Magento_Multishipping::checkout/overview/item.phtml')));
$this->_block->addChild('renderer.list', '\\Magento\\Framework\\View\\Element\\RendererList');
$this->_block->getChildBlock('renderer.list')->addChild('default', '\\Magento\\Checkout\\Block\\Cart\\Item\\Renderer', array('template' => 'cart/item/default.phtml'));
}
示例15: setUp
public function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
$this->_customerAccountService = $this->_objectManager->create('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface');
$this->_persistentSessionHelper = $this->_objectManager->create('Magento\\Persistent\\Helper\\Session');
$this->_observer = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\EmulateCustomer', ['customerAccountService' => $this->_customerAccountService, 'persistentSession' => $this->_persistentSessionHelper]);
}