php Magento-Framework-App-Config-Value类(方法)实例源码

下面列出了php Magento-Framework-App-Config-Value 类(方法)源码代码实例,从而了解它的用法。

作者:pradeep-wagent    项目:magento   
/**
  * Invalidate WebApi cache if needed.
  * 
  * @param \Magento\Framework\App\Config\Value $subject
  * @param \Magento\Framework\App\Config\Value $result
  * @return \Magento\Framework\App\Config\Value
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterAfterSave(\Magento\Framework\App\Config\Value $subject, \Magento\Framework\App\Config\Value $result)
 {
     if ($subject->getPath() == \Magento\WebapiSecurity\Model\Plugin\AnonymousResourceSecurity::XML_ALLOW_INSECURE && $subject->isValueChanged()) {
         $this->cacheTypeList->invalidate(\Magento\Framework\App\Cache\Type\Webapi::TYPE_IDENTIFIER);
     }
     return $result;
 }

作者:pradeep-wagent    项目:magento   
/**
  * After save handler
  *
  * @param \Magento\Framework\App\Config\Value $subject
  * @param mixed $result
  *
  * @return mixed
  */
 public function afterSave(\Magento\Framework\App\Config\Value $subject, $result)
 {
     if ($subject->isValueChanged()) {
         $this->_eavIndexerProcessor->markIndexerAsInvalid();
     }
     return $result;
 }

作者:BlackIkeEagl    项目:magento2-continuousph   
public function testProcess()
 {
     $path = 'design/head/logo';
     $value = 'path/to/logo';
     $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path, ['value' => $value])->willReturn($this->backendModel);
     $this->backendModel->expects($this->once())->method('afterLoad');
     $this->backendModel->expects($this->once())->method('getValue')->willReturn($value);
     $this->assertEquals($value, $this->valueProcessor->process($value, $path));
 }

作者:Doabilit    项目:magento2de   
public function testProcess()
 {
     $path = 'design/head/logo';
     $value = 'path/to/logo';
     $scope = 'websites';
     $scopeId = 1;
     $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path, ['value' => $value, 'field_config' => ['path' => $path], 'scope' => $scope, 'scope_id' => $scopeId])->willReturn($this->backendModel);
     $this->backendModel->expects($this->once())->method('afterLoad');
     $this->backendModel->expects($this->once())->method('getValue')->willReturn($value);
     $this->assertEquals($value, $this->valueProcessor->process($value, $scope, $scopeId, ['path' => $path]));
 }

作者:BlackIkeEagl    项目:magento2-continuousph   
public function testCreate()
 {
     $scope = 'website';
     $scopeId = 1;
     $data = ['scope' => $scope, 'scopeId' => $scopeId, 'value' => 'value', 'config' => ['path' => 'design/head/default_title', 'backend_model' => 'Magento\\Framework\\App\\Config\\Value']];
     $this->metadataProviderMock->expects($this->once())->method('get')->willReturn(['head_default_title' => ['path' => 'design/head/default_title']]);
     $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->collection);
     $this->collection->expects($this->once())->method('addPathsFilter')->with(['head_default_title' => 'design/head/default_title']);
     $this->collection->expects($this->once())->method('addFieldToFilter')->with('scope', $scope);
     $this->collection->expects($this->once())->method('addScopeIdFilter')->with($scopeId);
     $this->collection->expects($this->once())->method('getData')->willReturn([['config_id' => 1, 'path' => 'design/head/default_title']]);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\Config\\Value', ['data' => ['path' => 'design/head/default_title', 'scope' => $scope, 'scope_id' => $scopeId, 'field_config' => $data['config'], 'config_id' => 1]])->willReturn($this->backendModel);
     $this->backendModel->expects($this->once())->method('setValue')->willReturn('value');
     $this->assertSame($this->backendModel, $this->model->create($data));
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * Clean compiled JS/CSS when updating configuration settings
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->isValueChanged()) {
         $this->_mergeService->cleanMergedJsCss();
     }
     return parent::afterSave();
 }

作者:pradeep-wagent    项目:magento   
/**
  * @param int $callNumber
  * @param string $oldValue
  * @dataProvider afterSaveDataProvider
  */
 public function testAfterSave($callNumber, $oldValue)
 {
     $this->cacheTypeListMock->expects($this->exactly($callNumber))->method('invalidate');
     $this->configMock->expects($this->any())->method('getValue')->willReturn($oldValue);
     $this->model->setValue('some_value');
     $this->assertInstanceOf(get_class($this->model), $this->model->afterSave());
 }

作者:nja7    项目:magento   
/**
  * @return $this
  */
 public function afterSave()
 {
     if ($this->isValueChanged()) {
         $this->updateSuffixForUrlRewrites();
     }
     return parent::afterSave();
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * Validate minimum product qty value
  *
  * @return $this
  */
 public function beforeSave()
 {
     parent::beforeSave();
     $minQty = (int) $this->getValue() >= 0 ? (int) $this->getValue() : (int) $this->getOldValue();
     $this->setValue((string) $minQty);
     return $this;
 }

作者:shabbirvividad    项目:magento   
/**
  * Check and process robots file
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->getValue()) {
         $this->_directory->writeFile($this->_file, $this->getValue());
     }
     return parent::afterSave();
 }

作者:pradeep-wagent    项目:magento   
/**
  * Invalidate cache type, when value was changed
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->isValueChanged()) {
         $this->cacheTypeList->invalidate(\Magento\Framework\View\Element\AbstractBlock::CACHE_GROUP);
     }
     return parent::afterSave();
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * Cron settings after save
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function afterSave()
 {
     $enabled = $this->getData('groups/log/fields/enabled/value');
     $time = $this->getData('groups/log/fields/time/value');
     $frequency = $this->getData('groups/log/fields/frequency/value');
     $frequencyWeekly = \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY;
     $frequencyMonthly = \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY;
     if ($enabled) {
         $cronExprArray = [intval($time[1]), intval($time[0]), $frequency == $frequencyMonthly ? '1' : '*', '*', $frequency == $frequencyWeekly ? '1' : '*'];
         $cronExprString = join(' ', $cronExprArray);
     } else {
         $cronExprString = '';
     }
     try {
         /** @var $configValue \Magento\Framework\App\Config\ValueInterface */
         $configValue = $this->_configValueFactory->create();
         $configValue->load(self::CRON_STRING_PATH, 'path');
         $configValue->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save();
         /** @var $configValue \Magento\Framework\App\Config\ValueInterface */
         $configValue = $this->_configValueFactory->create();
         $configValue->load(self::CRON_MODEL_PATH, 'path');
         $configValue->setValue($this->_runModelPath)->setPath(self::CRON_MODEL_PATH)->save();
     } catch (\Exception $e) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.'));
     }
     return parent::afterSave();
 }

作者:pradeep-wagent    项目:magento   
/**
  * @return $this
  */
 public function beforeSave()
 {
     if (is_array($this->getValue())) {
         $this->setValue(serialize($this->getValue()));
     }
     return parent::beforeSave();
 }

作者:aies    项目:magento   
/**
  * Validate minimum product qty value
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     $minQty = (int) $this->getValue() >= 0 ? (int) $this->getValue() : (int) $this->getOldValue();
     $this->setValue((string) $minQty);
     return $this;
 }

作者:nja7    项目:magento   
/**
  * Save EAV default value after save
  *
  * @return $this
  */
 public function afterSave()
 {
     $result = parent::afterSave();
     $attributeObject = $this->eavConfig->getAttribute('customer', 'disable_auto_group_change');
     $attributeObject->setData('default_value', $this->getValue());
     $attributeObject->save();
     return $result;
 }

作者:ytorby    项目:magento2-geo-store-switche   
/**
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function beforeSave()
 {
     if (!empty($this->getValue()) && !$this->_isRegexp($this->getValue())) {
         $this->messageManager->addNotice(__('Invalid regular expression: %value', ['value' => $this->getValue()]));
         $this->setValue(null);
     }
     return parent::beforeSave();
 }

作者:whoopl    项目:magento2-testin   
/**
  * Validate specified value against frontend area
  *
  * @return $this
  */
 public function beforeSave()
 {
     if ('' != $this->getValue()) {
         $design = clone $this->_design;
         $design->setDesignTheme($this->getValue(), \Magento\Framework\App\Area::AREA_FRONTEND);
     }
     return parent::beforeSave();
 }

作者:shabbirvividad    项目:magento   
/**
  * After save call
  * Invalidate catalog search index if engine was changed
  *
  * @return $this
  */
 public function afterSave()
 {
     parent::afterSave();
     if ($this->isValueChanged()) {
         $this->indexerRegistry->get(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)->invalidate();
     }
     return $this;
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * Set status 'invalidate' for blocks and other output caches
  *
  * @return $this
  */
 public function afterSave()
 {
     $types = array_keys($this->_config->getValue(self::XML_PATH_INVALID_CACHES, \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
     if ($this->isValueChanged()) {
         $this->cacheTypeList->invalidate($types);
     }
     return parent::afterSave();
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * Prepare and store cron settings after save
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->isValueChanged()) {
         $this->_resetNotificationFlag(\Magento\Tax\Model\Config::XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT);
         $this->_resetNotificationFlag(\Magento\Tax\Model\Config::XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY);
     }
     return parent::afterSave();
 }


问题


面经


文章

微信
公众号

扫码关注公众号