コード例 #1
0
ファイル: Link.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     if ($this->_moduleManager->isOutputEnabled('Magento_Checkout')) {
         return '';
     }
     return parent::_toHtml();
 }
コード例 #2
0
ファイル: Plugin.php プロジェクト: Atlis/docker-magento2
 /**
  * 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;
 }
コード例 #3
0
ファイル: Link.php プロジェクト: aiesh/magento2
 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (!$this->_checkoutHelper->canOnepageCheckout() || !$this->_moduleManager->isOutputEnabled('Magento_Checkout')) {
         return '';
     }
     return parent::_toHtml();
 }
コード例 #4
0
ファイル: Observer.php プロジェクト: aiesh/magento2
 /**
  * @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');
 }
コード例 #5
0
 /**
  * Retrieve files
  *
  * Filter out theme files that belong to inactive modules or ones explicitly configured to not produce any output
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $result = array();
     foreach ($this->subject->getFiles($theme, $filePath) as $file) {
         if ($this->moduleManager->isOutputEnabled($file->getModule())) {
             $result[] = $file;
         }
     }
     return $result;
 }
コード例 #6
0
ファイル: Tabs.php プロジェクト: aiesh/magento2
 /**
  * @param \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs $subject
  * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection $result
  *
  * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterGetGroupCollection(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs $subject, $result)
 {
     if (!$this->_moduleManager->isOutputEnabled('Magento_RecurringPayment')) {
         foreach ($result as $key => $group) {
             if ($group->getAttributeGroupCode() === 'recurring-payment') {
                 $result->removeItemByKey($key);
             }
         }
     }
     return $result;
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_LayeredNavigation')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form\AbstractForm $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('front_fieldset');
     $fieldset->addField('is_filterable', 'select', ['name' => 'is_filterable', 'label' => __("Use in Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => [['value' => '0', 'label' => __('No')], ['value' => '1', 'label' => __('Filterable (with results)')], ['value' => '2', 'label' => __('Filterable (no results)')]]]);
     $fieldset->addField('is_filterable_in_search', 'select', ['name' => 'is_filterable_in_search', 'label' => __("Use in Search Results Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => $this->optionList->toOptionArray()]);
     $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'title' => __('Position in Layered Navigation'), 'note' => __('Position of attribute in layered navigation block.'), 'class' => 'validate-digits']);
 }
コード例 #8
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_Swatches')) {
         return;
     }
     /** @var \Magento\Framework\DataObject $response */
     $response = $observer->getEvent()->getResponse();
     $types = $response->getTypes();
     $types[] = ['value' => \Magento\Swatches\Model\Swatch::SWATCH_TYPE_VISUAL_ATTRIBUTE_FRONTEND_INPUT, 'label' => __('Visual Swatch'), 'hide_fields' => ['is_unique', 'is_required', 'frontend_class', '_scope', '_default_value', '_front_fieldset']];
     $types[] = ['value' => \Magento\Swatches\Model\Swatch::SWATCH_TYPE_TEXTUAL_ATTRIBUTE_FRONTEND_INPUT, 'label' => __('Text Swatch'), 'hide_fields' => ['is_unique', 'is_required', 'frontend_class', '_scope', '_default_value', '_front_fieldset']];
     $response->setTypes($types);
 }
コード例 #9
0
ファイル: Visibility.php プロジェクト: smile-sa/elasticsuite
 /**
  * Check a configuration element visibility
  *
  * @param \Magento\Config\Model\Config\Structure\AbstractElement $element The config composite element
  * @param string                                                 $scope   The element scope
  *
  * @return bool
  */
 public function isVisible(\Magento\Config\Model\Config\Structure\AbstractElement $element, $scope)
 {
     if ($element->getAttribute('if_module_enabled') && !$this->moduleManager->isOutputEnabled($element->getAttribute('if_module_enabled'))) {
         return false;
     }
     $showInScope = [ContainerScopeInterface::SCOPE_DEFAULT => $element->getAttribute('showInDefault'), ContainerScopeInterface::SCOPE_CONTAINERS => $element->getAttribute('showInContainer'), ContainerScopeInterface::SCOPE_STORE_CONTAINERS => $element->getAttribute('showInStore')];
     if ($this->storeManager->isSingleStoreMode()) {
         $result = !$element->getAttribute('hide_in_single_store_mode') && array_sum($showInScope);
         return $result;
     }
     return !empty($showInScope[$scope]);
 }
コード例 #10
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_Swatches')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('base_fieldset');
     $yesnoSource = $this->yesNo->toOptionArray();
     $fieldset->addField('update_product_preview_image', 'select', ['name' => 'update_product_preview_image', 'label' => __('Update Product Preview Image'), 'title' => __('Update Product Preview Image'), 'note' => __('Filtering by this attribute will update the product image on catalog page'), 'values' => $yesnoSource], 'is_filterable');
     $fieldset->addField('use_product_image_for_swatch', 'select', ['name' => 'use_product_image_for_swatch', 'label' => __('Use Product Image for Swatch if Possible'), 'title' => __('Use Product Image for Swatch if Possible'), 'note' => __('Allows use fallback logic for replacing swatch image with product swatch or base image'), 'values' => $yesnoSource], 'is_filterable');
 }
コード例 #11
0
ファイル: AbstractHelper.php プロジェクト: vasiljok/magento2
 /**
  * Check whether or not the module output is enabled in Configuration
  *
  * @param string $moduleName Full module name
  * @return boolean
  * @deprecated use \Magento\Framework\Module\Manager::isOutputEnabled()
  */
 public function isModuleOutputEnabled($moduleName = null)
 {
     if ($moduleName === null) {
         $moduleName = $this->_getModuleName();
     }
     return $this->_moduleManager->isOutputEnabled($moduleName);
 }
コード例 #12
0
 /**
  * Convert dom node tree to array
  *
  * @param \DOMDocument $source
  * @return array
  * @throws \InvalidArgumentException
  */
 public function convert($source)
 {
     $output = ['entities' => []];
     /** @var \DOMNodeList $entities */
     $entities = $source->getElementsByTagName('entity');
     /** @var \DOMNode $entityConfig */
     foreach ($entities as $entityConfig) {
         $attributes = $entityConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $label = $attributes->getNamedItem('label')->nodeValue;
         $behaviorModel = $attributes->getNamedItem('behaviorModel')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         if (!$this->moduleManager->isOutputEnabled(Classes::getClassModuleName($model))) {
             continue;
         }
         $output['entities'][$name] = ['name' => $name, 'label' => $label, 'behaviorModel' => $behaviorModel, 'model' => $model, 'types' => [], 'relatedIndexers' => []];
     }
     /** @var \DOMNodeList $entityTypes */
     $entityTypes = $source->getElementsByTagName('entityType');
     /** @var \DOMNode $entityTypeConfig */
     foreach ($entityTypes as $entityTypeConfig) {
         $attributes = $entityTypeConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         $entity = $attributes->getNamedItem('entity')->nodeValue;
         if (isset($output['entities'][$entity])) {
             $output['entities'][$entity]['types'][$name] = ['name' => $name, 'model' => $model];
         }
     }
     /** @var \DOMNodeList $relatedIndexers */
     $relatedIndexers = $source->getElementsByTagName('relatedIndexer');
     /** @var \DOMNode $relatedIndexerConfig */
     foreach ($relatedIndexers as $relatedIndexerConfig) {
         $attributes = $relatedIndexerConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $entity = $attributes->getNamedItem('entity')->nodeValue;
         if (isset($output['entities'][$entity])) {
             $output['entities'][$entity]['relatedIndexers'][$name] = ['name' => $name];
         }
     }
     return $output;
 }
コード例 #13
0
 /**
  * Convert dom node tree to array
  *
  * @param \DOMDocument $source
  * @return array
  * @throws \InvalidArgumentException
  */
 public function convert($source)
 {
     $output = ['entities' => [], 'fileFormats' => []];
     /** @var \DOMNodeList $entities */
     $entities = $source->getElementsByTagName('entity');
     /** @var \DOMNode $entityConfig */
     foreach ($entities as $entityConfig) {
         $attributes = $entityConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $label = $attributes->getNamedItem('label')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         if (!$this->moduleManager->isOutputEnabled(Classes::getClassModuleName($model))) {
             continue;
         }
         $entityAttributeFilterType = $attributes->getNamedItem('entityAttributeFilterType')->nodeValue;
         $output['entities'][$name] = ['name' => $name, 'label' => $label, 'model' => $model, 'types' => [], 'entityAttributeFilterType' => $entityAttributeFilterType];
     }
     /** @var \DOMNodeList $entityTypes */
     $entityTypes = $source->getElementsByTagName('entityType');
     /** @var \DOMNode $entityTypeConfig */
     foreach ($entityTypes as $entityTypeConfig) {
         $attributes = $entityTypeConfig->attributes;
         $model = $attributes->getNamedItem('model')->nodeValue;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $entity = $attributes->getNamedItem('entity')->nodeValue;
         if (isset($output['entities'][$entity])) {
             $output['entities'][$entity]['types'][$name] = ['name' => $name, 'model' => $model];
         }
     }
     /** @var \DOMNodeList $fileFormats */
     $fileFormats = $source->getElementsByTagName('fileFormat');
     /** @var \DOMNode $fileFormatConfig */
     foreach ($fileFormats as $fileFormatConfig) {
         $attributes = $fileFormatConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         $label = $attributes->getNamedItem('label')->nodeValue;
         $output['fileFormats'][$name] = ['name' => $name, 'model' => $model, 'label' => $label];
     }
     return $output;
 }
コード例 #14
0
 /**
  * Check whether element should be displayed
  *
  * @return bool
  */
 public function isVisible()
 {
     if (isset($this->_data['if_module_enabled']) && !$this->moduleManager->isOutputEnabled($this->_data['if_module_enabled'])) {
         return false;
     }
     $showInScope = [\Magento\Store\Model\ScopeInterface::SCOPE_STORE => $this->_hasVisibilityValue('showInStore'), \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE => $this->_hasVisibilityValue('showInWebsite'), ScopeConfigInterface::SCOPE_TYPE_DEFAULT => $this->_hasVisibilityValue('showInDefault')];
     if ($this->_storeManager->isSingleStoreMode()) {
         $result = !$this->_hasVisibilityValue('hide_in_single_store_mode') && array_sum($showInScope);
         return $result;
     }
     return !empty($showInScope[$this->_scope]);
 }
コード例 #15
0
 /**
  * Get Filtered Modules by Options selected
  * @param $moduleList
  * @param $inputEnabled
  * @return array
  */
 protected function getModulesByCriteria($moduleList, $inputEnabled)
 {
     $moduleInfo = array();
     $modules = array_intersect_key($this->fullModuleList->getAll(), $moduleList);
     foreach ($modules as $module) {
         $vendor = current(explode("_", $module['name']));
         $title = $module['name'];
         $version = $module['setup_version'];
         $enabled = $this->moduleManager->isEnabled($title) ? 'Y' : 'N';
         $outputEnabled = $this->moduleManager->isOutputEnabled($title) ? 'Y' : 'N';
         if ($inputEnabled) {
             if ($inputEnabled == strtolower($enabled)) {
                 $moduleInfo[] = array($vendor, $title, $version, $enabled, $outputEnabled);
             }
         } else {
             $moduleInfo[] = array($vendor, $title, $version, $enabled, $outputEnabled);
         }
     }
     return $moduleInfo;
 }
コード例 #16
0
ファイル: Collect.php プロジェクト: pradeep-wagento/magento2
 /**
  * Collects required data about the modules
  *
  * @param bool $refresh
  * @return array
  */
 public function getModuleData($refresh = true)
 {
     $callback = function (Module $value) {
         return $value->getName();
     };
     $configModules = $this->getAllModules();
     /** @var Module[] $dbModuleArray */
     $dbModuleArray = $this->moduleCollectionFactory->create()->getItems();
     $nameValues = array_map($callback, $dbModuleArray);
     $moduleChanges = [];
     foreach ($configModules as $moduleName => $module) {
         unset($module['sequence']);
         $state = $this->getState($moduleName);
         $active = $this->getActive($moduleName);
         $module['state'] = $state;
         $module['active'] = $active;
         if (!in_array($moduleName, $nameValues)) {
             $moduleChanges[] = $this->getNewModuleChanges($moduleName, $active, $module['setup_version'], $state);
         } else {
             $dbModule = $dbModuleArray[array_search($moduleName, $nameValues)];
             $changeTest = $dbModule->getData();
             $changes = array_diff($module, $changeTest);
             $changesCleanArray = $this->getCleanChangesArray($changes);
             if (count($changesCleanArray) > 0 || $this->moduleManager->isOutputEnabled($changeTest['name']) && $module['setup_version'] != null) {
                 $data = ['entity_id' => $changeTest['entity_id'], 'name' => $changeTest['name'], 'active' => $active, 'setup_version' => $module['setup_version'], 'state' => $state];
                 if ($refresh) {
                     $dbModule->setData($data);
                     $dbModule->save();
                 }
                 $moduleChanges[] = ['name' => $data['name'], 'setup_version' => $data['setup_version'], 'type' => $state];
             }
         }
     }
     $arrayModuleNames = array_keys($configModules);
     $uninstalledModuleChanges = $this->setUninstalledModuleChanges($dbModuleArray, $arrayModuleNames);
     if (is_array($uninstalledModuleChanges)) {
         $moduleChanges[] = $uninstalledModuleChanges;
     }
     $finalObject = $this->getFinalCounts($moduleChanges);
     return $finalObject;
 }
コード例 #17
0
ファイル: Item.php プロジェクト: aiesh/magento2
 /**
  * Check whether item is disabled. Disabled items are not shown to user
  *
  * @return bool
  */
 public function isDisabled()
 {
     return !$this->_moduleManager->isOutputEnabled($this->_moduleName) || !$this->_isModuleDependenciesAvailable() || !$this->_isConfigDependenciesAvailable();
 }
コード例 #18
0
 /**
  * Newsletter module availability
  *
  * @return bool
  */
 public function isNewsletterEnabled()
 {
     return $this->_moduleManager->isOutputEnabled('Magento_Newsletter');
 }
コード例 #19
0
 /**
  * @param bool $configValue
  * @param string $moduleName
  * @param bool $expectedResult
  * @dataProvider isOutputEnabledCustomConfigPathDataProvider
  */
 public function testIsOutputEnabledCustomConfigPath($configValue, $moduleName, $expectedResult)
 {
     $this->_moduleList->expects($this->any())->method('getModule')->will($this->returnValue(array('name' => $moduleName)));
     $this->_outputConfig->expects($this->at(0))->method('isSetFlag')->with(self::XML_PATH_OUTPUT_ENABLED)->will($this->returnValue($configValue));
     $this->assertEquals($expectedResult, $this->_model->isOutputEnabled($moduleName));
 }
コード例 #20
0
 /**
  * @param bool $configValue
  * @param bool $expectedResult
  * @dataProvider isOutputEnabledCustomConfigPathDataProvider
  */
 public function testIsOutputEnabledCustomConfigPath($configValue, $expectedResult)
 {
     $this->_moduleList->expects($this->once())->method('has')->will($this->returnValue(true));
     $this->_outputConfig->expects($this->at(0))->method('isSetFlag')->with(self::XML_PATH_OUTPUT_ENABLED)->will($this->returnValue($configValue));
     $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_Two'));
 }