本文整理汇总了PHP中Magento\Framework\ObjectManagerInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerInterface::get方法的具体用法?PHP ObjectManagerInterface::get怎么用?PHP ObjectManagerInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManagerInterface
的用法示例。
在下文中一共展示了ObjectManagerInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReadOperation
/**
* @param string $entityType
* @return Operation\ReadInterface
* @throws \Exception
*/
public function getReadOperation($entityType)
{
if (!isset($this->operations[$entityType]['read'])) {
return $this->objectManager->get($this->operations['default']['read']);
}
return $this->objectManager->get($this->operations[$entityType]['read']);
}
示例2: testGetGridParentHtml
public function testGetGridParentHtml()
{
$this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Cart', '', []);
$mockCollection = $this->getMockBuilder('\\Magento\\Framework\\Data\\Collection')->disableOriginalConstructor()->getMock();
$this->_block->setCollection($mockCollection);
$this->assertContains("<div class=\"admin__data-grid-header admin__data-grid-toolbar\"", $this->_block->getGridParentHtml());
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->fileSystem = $this->objectManager->get(\Magento\Framework\Filesystem::class);
$this->productResource = $this->objectManager->create(\Magento\Catalog\Model\ResourceModel\Product::class);
}
示例4: _getCache
/**
* Create cache model
*
* @return CacheInterface
*/
protected function _getCache()
{
if (null == $this->_cache) {
$this->_cache = $this->_objectManager->get('Magento\\Framework\\App\\Cache');
}
return $this->_cache;
}
示例5: validateComposerJsonFile
/**
* Validate a composer.json under the given path
*
* @param string $path path to composer.json
*/
private function validateComposerJsonFile($path)
{
/** @var \Magento\Framework\Composer\MagentoComposerApplicationFactory $appFactory */
$appFactory = self::$objectManager->get('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory');
$app = $appFactory->create();
$app->runComposerCommand(['command' => 'validate'], $path);
}
示例6: _getTzDelta
/**
* MOBI-504: don't retrieve session depended objects from Object Manager
*
* @return \Magento\Framework\Stdlib\DateTime\DateTime
*/
private function _getTzDelta()
{
if (is_null($this->tzDelta)) {
$this->tzDelta = $this->manObj->get(\Magento\Framework\Stdlib\DateTime\DateTime::class);
}
return $this->tzDelta;
}
示例7: getAdditionalRowsCount
/**
* Calculate the largest links block
*
* @param array $additionalRowsCount
* @param int $productId
* @return array|mixed
*/
public function getAdditionalRowsCount($additionalRowsCount, $productId)
{
foreach ($this->customizers as $className) {
$additionalRowsCount = $this->objectManager->get($className)->getAdditionalRowsCount($additionalRowsCount, $productId);
}
return $additionalRowsCount;
}
示例8: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @throws \Magento\Framework\Exception\LocalizedException
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$omParams = $_SERVER;
$omParams[StoreManager::PARAM_RUN_CODE] = 'admin';
$omParams[Store::CUSTOM_ENTRY_POINT_PARAM] = true;
$this->objectManager = $this->objectManagerFactory->create($omParams);
$area = FrontNameResolver::AREA_CODE;
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManager->get('Magento\\Framework\\App\\State');
$appState->setAreaCode($area);
$configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
$this->objectManager->configure($configLoader->load($area));
$output->writeln('Import started');
$time = microtime(true);
/** @var \FireGento\FastSimpleImport\Model\Importer $importerModel */
$importerModel = $this->objectManager->create('FireGento\\FastSimpleImport\\Model\\Importer');
$productsArray = $this->getEntities();
$importerModel->setBehavior($this->getBehavior());
$importerModel->setEntityCode($this->getEntityCode());
$adapterFactory = $this->objectManager->create('FireGento\\FastSimpleImport\\Model\\Adapters\\NestedArrayAdapterFactory');
$importerModel->setImportAdapterFactory($adapterFactory);
try {
$importerModel->processImport($productsArray);
} catch (\Exception $e) {
$output->writeln($e->getMessage());
}
$output->write($importerModel->getLogTrace());
$output->write($importerModel->getErrorMessages());
$output->writeln('Import finished. Elapsed time: ' . round(microtime(true) - $time, 2) . 's' . "\n");
$this->afterFinishImport();
}
示例9: create
/**
* Create data helper
*
* @param string $area
* @return \Magento\Authorizenet\Helper\Backend\Data|\Magento\Authorizenet\Helper\Data
* @throws LocalizedException
*/
public function create($area)
{
if (!isset($this->helperMap[$area])) {
throw new LocalizedException(__(sprintf('For this area <%s> no suitable helper', $area)));
}
return $this->objectManager->get($this->helperMap[$area]);
}
示例10: testStockItemPUTWithWrongInput
/**
* @param array $newData
* @param array $expectedResult
* @param array $fixtureData
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
* @dataProvider saveStockItemBySkuWithWrongInputDataProvider
*/
public function testStockItemPUTWithWrongInput($newData, $expectedResult, $fixtureData)
{
$stockItemOld = $this->getStockItemBySku($fixtureData);
$productSku = 'simple1';
$itemId = $stockItemOld['item_id'];
$resourcePath = str_replace([':productSku', ':itemId'], [$productSku, $itemId], self::RESOURCE_PUT_PATH);
$serviceInfo = ['rest' => ['resourcePath' => $resourcePath, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT], 'soap' => ['service' => 'catalogInventoryStockRegistryV1', 'serviceVersion' => self::SERVICE_VERSION, 'operation' => 'catalogInventoryStockRegistryV1UpdateStockItemBySku']];
/** @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemDetailsDo */
$stockItemDetailsDo = $this->objectManager->get('Magento\\CatalogInventory\\Api\\Data\\StockItemInterfaceFactory')->create();
/** @var \Magento\Framework\Api\DataObjectHelper $dataObjectHelper */
$dataObjectHelper = $this->objectManager->get('Magento\\Framework\\Api\\DataObjectHelper');
$dataObjectHelper->populateWithArray($stockItemDetailsDo, $newData, '\\Magento\\CatalogInventory\\Api\\Data\\StockItemInterface');
$data = $stockItemDetailsDo->getData();
$data['show_default_notification_message'] = false;
$arguments = ['productSku' => $productSku, 'stockItem' => $data];
$this->assertEquals($stockItemOld['item_id'], $this->_webApiCall($serviceInfo, $arguments));
/** @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory */
$stockItemFactory = $this->objectManager->get('Magento\\CatalogInventory\\Api\\Data\\StockItemInterfaceFactory');
$stockItem = $stockItemFactory->create();
/** @var \Magento\CatalogInventory\Model\ResourceModel\Stock\Item $stockItemResource */
$stockItemResource = $this->objectManager->get('Magento\\CatalogInventory\\Model\\ResourceModel\\Stock\\Item');
$stockItemResource->loadByProductId($stockItem, $stockItemOld['product_id'], $stockItemOld['stock_id']);
$expectedResult['item_id'] = $stockItem->getItemId();
$this->assertEquals($expectedResult, array_intersect_key($stockItem->getData(), $expectedResult));
}
示例11: prolongAction
/**
* Prolong session
*
* @return string
*/
public function prolongAction()
{
try {
if ($this->objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) {
/** @var \Magento\Framework\App\State $adminAppState */
$adminAppState = $this->objectManager->get('Magento\Framework\App\State');
$adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN);
/* @var \Magento\Backend\Model\Auth\Session $session */
$sessionConfig = $this->objectManager->get('Magento\Backend\Model\Session\AdminConfig');
$sessionConfig->setCookiePath('/setup');
$session = $this->objectManager->create(
'Magento\Backend\Model\Auth\Session',
[
'sessionConfig' => $sessionConfig,
'appState' => $adminAppState
]
);
$session->prolong();
return \Zend_Json::encode(['success' => true]);
}
} catch (\Exception $e) {
}
return \Zend_Json::encode(['success' => false]);
}
示例12: 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');
}
示例13: 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;
}
示例14: getOperation
/**
* Returns operation by name by entity type
*
* @param string $entityType
* @param string $operationName
* @return object
*/
public function getOperation($entityType, $operationName)
{
if (!isset($this->operations[$entityType][$operationName])) {
return $this->objectManager->get($this->operations['default'][$operationName]);
}
return $this->objectManager->get($this->operations[$entityType][$operationName]);
}
示例15: _getSubject
/**
* Retrieve subject
*
* @return \Magento\Config\Model\Config\Structure\SearchInterface
*/
protected function _getSubject()
{
if (!$this->_subject) {
$this->_subject = $this->_objectManager->get('Magento\\Config\\Model\\Config\\Structure');
}
return $this->_subject;
}