本文整理汇总了PHP中Magento\Framework\Module\Manager类的典型用法代码示例。如果您正苦于以下问题:PHP Manager类的具体用法?PHP Manager怎么用?PHP Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareCollection
/**
* @return $this
*/
protected function _prepareCollection()
{
if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
return $this;
}
$collection = $this->_collectionFactory->create()->addItemCountExpr()->joinCustomerName('customer')->orderByCreatedAt();
if ($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
if ($this->getParam('store')) {
$collection->addAttributeToFilter('store_id', $this->getParam('store'));
} else {
if ($this->getParam('website')) {
$storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
} else {
if ($this->getParam('group')) {
$storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
$collection->addAttributeToFilter('store_id', array('in' => $storeIds));
}
}
}
$collection->addRevenueToSelect();
} else {
$collection->addRevenueToSelect(true);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例2: afterGenerateXml
/**
* After generate Xml
*
* @param \Magento\Framework\View\LayoutInterface $subject
* @param \Magento\Framework\View\LayoutInterface $result
* @return \Magento\Framework\View\LayoutInterface
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) {
$this->checkoutSession->clearStorage();
}
return $result;
}
示例3: _prepareLayout
/**
* @return $this|void
*/
protected function _prepareLayout()
{
if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
return $this;
}
$isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
$period = $this->getRequest()->getParam('period', '24h');
/* @var $collection \Magento\Reports\Model\Resource\Order\Collection */
$collection = $this->_collectionFactory->create()->addCreateAtPeriodFilter($period)->calculateTotals($isFilter);
if ($this->getRequest()->getParam('store')) {
$collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
} else {
if ($this->getRequest()->getParam('website')) {
$storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$collection->addFieldToFilter('store_id', ['in' => $storeIds]);
} else {
if ($this->getRequest()->getParam('group')) {
$storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$collection->addFieldToFilter('store_id', ['in' => $storeIds]);
} elseif (!$collection->isLive()) {
$collection->addFieldToFilter('store_id', ['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]);
}
}
}
$collection->load();
$totals = $collection->getFirstItem();
$this->addTotal(__('Revenue'), $totals->getRevenue());
$this->addTotal(__('Tax'), $totals->getTax());
$this->addTotal(__('Shipping'), $totals->getShipping());
$this->addTotal(__('Quantity'), $totals->getQuantity() * 1, true);
}
示例4: _toHtml
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
if ($this->_moduleManager->isOutputEnabled('Magento_Checkout')) {
return '';
}
return parent::_toHtml();
}
示例5: execute
/**
* @param Observer $observer
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function execute(Observer $observer)
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
/** @var \Magento\Customer\Model\Data\Customer $customer */
$customer = $observer->getData('customer');
$customerGroupId = $customer->getGroupId();
$customerGroup = $this->groupRepository->getById($customerGroupId);
$customerTaxClassId = $customerGroup->getTaxClassId();
$this->customerSession->setCustomerTaxClassId($customerTaxClassId);
/** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
$addresses = $customer->getAddresses();
if (isset($addresses)) {
$defaultShippingFound = false;
$defaultBillingFound = false;
foreach ($addresses as $address) {
if ($address->isDefaultBilling()) {
$defaultBillingFound = true;
$this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
}
if ($address->isDefaultShipping()) {
$defaultShippingFound = true;
$this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
}
if ($defaultShippingFound && $defaultBillingFound) {
break;
}
}
}
}
}
示例6: _prepareLayout
/**
* @return $this|void
*/
protected function _prepareLayout()
{
if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
return $this;
}
$isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
$collection = $this->_collectionFactory->create()->calculateSales($isFilter);
if ($this->getRequest()->getParam('store')) {
$collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
} else {
if ($this->getRequest()->getParam('website')) {
$storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
} else {
if ($this->getRequest()->getParam('group')) {
$storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
}
}
}
$collection->load();
$sales = $collection->getFirstItem();
$this->addTotal(__('Lifetime Sales'), $sales->getLifetime());
$this->addTotal(__('Average Orders'), $sales->getAverage());
}
示例7: _toHtml
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
if (!$this->_checkoutHelper->canOnepageCheckout() || !$this->_moduleManager->isOutputEnabled('Magento_Checkout')) {
return '';
}
return parent::_toHtml();
}
示例8: afterGetOptionArray
/**
* Remove grouped product from list of visible product types
*
* @param \Magento\Catalog\Model\Product\Type $subject
* @param array $result
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetOptionArray(\Magento\Catalog\Model\Product\Type $subject, array $result)
{
if (!$this->moduleManager->isOutputEnabled('Magento_ConfigurableProduct')) {
unset($result[Configurable::TYPE_CODE]);
}
return $result;
}
示例9: getStockOption
/**
* Retrieve stock option array
*
* @return array
*/
public function getStockOption()
{
if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) {
return $this->stock->toOptionArray();
}
return [];
}
示例10: observe
/**
* @param \Magento\Framework\Event $event
* @return void
*/
public function observe($event)
{
if (!$this->moduleManager->isOutputEnabled('Magento_LayeredNavigation')) {
return;
}
/** @var \Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid $grid */
$grid = $event->getGrid();
$grid->addColumnAfter('is_filterable', array('header' => __('Use in Layered Navigation'), 'sortable' => true, 'index' => 'is_filterable', 'type' => 'options', 'options' => array('1' => __('Filterable (with results)'), '2' => __('Filterable (no results)'), '0' => __('No')), 'align' => 'center'), 'is_searchable');
}
示例11: testConvertWithDisabledModules
public function testConvertWithDisabledModules()
{
$testDom = $this->filePath . 'import.xml';
$dom = new \DOMDocument();
$dom->load($testDom);
$notExpectedArray = (include $this->filePath . 'import.php');
$this->moduleManager->expects($this->any())->method('isOutputEnabled')->willReturn(false);
$this->assertNotEquals($notExpectedArray, $this->model->convert($dom));
}
示例12: testAddFields
/**
* @dataProvider dataAddFields
*/
public function testAddFields($expected)
{
$this->moduleManagerMock->expects($this->once())->method('isOutputEnabled')->willReturn($expected['isOutputEnabled']);
$this->eventObserverMock->expects($this->exactly($expected['methods_count']))->method('getForm')->willReturn($this->formMock);
$element = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], [], '', false);
$this->formMock->expects($this->exactly($expected['methods_count']))->method('getElement')->with('base_fieldset')->willReturn($element);
$element->expects($this->exactly($expected['addField_count']))->method('addField');
$this->yesNoMock->expects($this->exactly($expected['yesno_count']))->method('toOptionArray');
$this->observerMock->execute($this->eventObserverMock);
}
示例13: getMagefanModules
/**
* Get Magefan Modules Info
*
* @return $this
*/
protected function getMagefanModules()
{
$modules = array();
foreach ($this->_moduleList->getAll() as $moduleName => $module) {
if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) {
$modules[$moduleName] = $module;
}
}
return $modules;
}
示例14: testAddSwatchAttributeType
/**
* @dataProvider dataAddSwatch
*/
public function testAddSwatchAttributeType($exp)
{
$this->moduleManagerMock->expects($this->once())->method('isOutputEnabled')->willReturn($exp['isOutputEnabled']);
$eventMock = $this->getMock('\\Magento\\Framework\\Event', ['getResponse'], [], '', false);
$this->eventObserverMock->expects($this->exactly($exp['methods_count']))->method('getEvent')->willReturn($eventMock);
$response = $this->getMock('\\Magento\\Framework\\DataObject', ['getTypes'], [], '', false);
$eventMock->expects($this->exactly($exp['methods_count']))->method('getResponse')->willReturn($response);
$response->expects($this->exactly($exp['methods_count']))->method('getTypes')->willReturn($exp['outputArray']);
$this->observerMock->execute($this->eventObserverMock);
}
示例15: testGetCustomerMissingCustomer
public function testGetCustomerMissingCustomer()
{
$moduleManager = $this->objectManager->get('Magento\\Framework\\Module\\Manager');
if ($moduleManager->isEnabled('Magento_PageCache')) {
$customerDataBuilder = $this->objectManager->create('Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder');
$customerData = $customerDataBuilder->setGroupId($this->_customerSession->getCustomerGroupId())->create();
$this->assertEquals($customerData, $this->_block->getCustomer());
} else {
$this->assertNull($this->_block->getCustomer());
}
}