本文整理汇总了PHP中Magento\Framework\ObjectManagerInterface::addSharedInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerInterface::addSharedInstance方法的具体用法?PHP ObjectManagerInterface::addSharedInstance怎么用?PHP ObjectManagerInterface::addSharedInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManagerInterface
的用法示例。
在下文中一共展示了ObjectManagerInterface::addSharedInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpThemeFallback
/**
* Setup the theme fallback structure and set the Vendor/custom_theme as the current theme for 'fixturestore' store
*
* @param $area
*/
protected function setUpThemeFallback($area)
{
$themes = ['frontend' => 'Vendor/custom_theme'];
$design = $this->_objectManager->create('Magento\\Theme\\Model\\View\\Design', ['themes' => $themes]);
$this->_objectManager->addSharedInstance($design, 'Magento\\Theme\\Model\\View\\Design');
// It is important to test from both areas, as emails will get sent from both, so we need to ensure that the
// inline CSS files get loaded properly from both areas.
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area);
$collection = $this->_objectManager->create('Magento\\Theme\\Model\\Resource\\Theme\\Collection');
// Hard-coding theme as we want to test the fallback structure to ensure that the parent/grandparent themes of
// Vendor/custom_theme will be checked for CSS files
$themeId = $collection->getThemeByFullPath('frontend/Vendor/custom_theme')->getId();
$this->_objectManager->get('Magento\\Framework\\App\\Config\\MutableScopeConfigInterface')->setValue(\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID, $themeId, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'fixturestore');
$this->_model->setDesignConfig(['area' => 'frontend', 'store' => $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore('fixturestore')->getId()]);
}
示例2: setUpAdminThemeFallback
/**
* Setup the theme fallback structure and set the Vendor_EmailTest/custom_theme as the current theme for
* 'fixturestore' store
*/
protected function setUpAdminThemeFallback()
{
$themes = [BackendFrontNameResolver::AREA_CODE => 'Vendor_EmailTest/custom_theme'];
$design = $this->objectManager->create('Magento\\Theme\\Model\\View\\Design', ['themes' => $themes]);
$this->objectManager->addSharedInstance($design, 'Magento\\Theme\\Model\\View\\Design');
/** @var \Magento\Theme\Model\Theme\Registration $registration */
$registration = $this->objectManager->get('Magento\\Theme\\Model\\Theme\\Registration');
$registration->register();
// The Vendor_EmailTest/custom_theme adminhtml theme is set in the
// dev/tests/integration/testsuite/Magento/Email/Model/_files/design/themes.php file, as it must be set
// before the adminhtml area is loaded below.
Bootstrap::getInstance()->loadArea(BackendFrontNameResolver::AREA_CODE);
/** @var \Magento\Store\Model\Store $adminStore */
$adminStore = $this->objectManager->create('Magento\\Store\\Model\\Store')->load(Store::ADMIN_CODE);
$this->model->setDesignConfig(['area' => 'adminhtml', 'store' => $adminStore->getId()]);
}