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


PHP ObjectManagerInterface::get方法代码示例

本文整理汇总了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']);
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:12,代码来源:OrchestratorPool.php

示例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());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:CartTest.php

示例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);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:AbstractProductExportImportTestCase.php

示例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;
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:12,代码来源:Proxy.php

示例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);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:ComposerTest.php

示例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;
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_core,代码行数:12,代码来源:Date.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Composite.php

示例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();
 }
开发者ID:firegento,项目名称:FireGento_FastSimpleImport2_Demo,代码行数:37,代码来源:AbstractImportCommand.php

示例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]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:DataFactory.php

示例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));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:32,代码来源:StockItemTest.php

示例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]);
    }
开发者ID:razbakov,项目名称:magento2,代码行数:30,代码来源:Session.php

示例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');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:DataTest.php

示例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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Composite.php

示例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]);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:14,代码来源:OperationPool.php

示例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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:Proxy.php


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