本文整理汇总了PHP中Magento\Framework\App\Config\Value::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Value::afterSave方法的具体用法?PHP Value::afterSave怎么用?PHP Value::afterSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Config\Value
的用法示例。
在下文中一共展示了Value::afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
/**
* Actions after save
*
* @return $this
*/
public function afterSave()
{
$result = parent::afterSave();
$valueConfig = ['' => ['is_required' => 0, 'is_visible' => 0], 'opt' => ['is_required' => 0, 'is_visible' => 1], '1' => ['is_required' => 0, 'is_visible' => 1], 'req' => ['is_required' => 1, 'is_visible' => 1]];
$value = $this->getValue();
if (isset($valueConfig[$value])) {
$data = $valueConfig[$value];
} else {
$data = $valueConfig[''];
}
if ($this->getScope() == 'websites') {
$website = $this->storeManager->getWebsite($this->getScopeCode());
$dataFieldPrefix = 'scope_';
} else {
$website = null;
$dataFieldPrefix = '';
}
foreach ($this->_getAttributeObjects() as $attributeObject) {
if ($website) {
$attributeObject->setWebsite($website);
$attributeObject->load($attributeObject->getId());
}
$attributeObject->setData($dataFieldPrefix . 'is_required', $data['is_required']);
$attributeObject->setData($dataFieldPrefix . 'is_visible', $data['is_visible']);
$attributeObject->save();
}
return $result;
}
示例2: afterSave
/**
* @return \Magento\Framework\Model\AbstractModel|void
*/
public function afterSave()
{
/** @var \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\Matrixrate $matrixRate */
$matrixRate = $this->_matrixrateFactory->create();
$matrixRate->uploadAndImport($this);
return parent::afterSave();
}
示例3: afterSave
/**
* Check and process robots file
*
* @return $this
*/
public function afterSave()
{
if ($this->getValue()) {
$this->_directory->writeFile($this->_file, $this->getValue());
}
return parent::afterSave();
}
示例4: testAfterSave
/**
* @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());
}
示例5: afterSave
/**
* 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();
}
示例6: afterSave
/**
* @return $this
*/
public function afterSave()
{
if ($this->isValueChanged()) {
$this->updateSuffixForUrlRewrites();
}
return parent::afterSave();
}
示例7: afterSave
/**
* 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();
}
示例8: afterSave
/**
* Clean compiled JS/CSS when updating configuration settings
*
* @return $this
*/
public function afterSave()
{
if ($this->isValueChanged()) {
$this->_mergeService->cleanMergedJsCss();
}
return parent::afterSave();
}
示例9: afterSave
/**
* @return $this
*/
public function afterSave()
{
/** @var \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate $tableRate */
$tableRate = $this->_tablerateFactory->create();
$tableRate->uploadAndImport($this);
return parent::afterSave();
}
示例10: afterSave
/**
* 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();
}
示例11: afterSave
/**
* 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;
}
示例12: afterSave
/**
* 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;
}
示例13: afterSave
/**
* 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();
}
示例14: afterSave
/**
* Delete custom admin url from configuration if "Use Custom Admin Url" option disabled
*
* @return $this
*/
public function afterSave()
{
$value = $this->getValue();
if (!$value) {
$this->_configWriter->delete(Custom::XML_PATH_SECURE_BASE_URL, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID);
$this->_configWriter->delete(Custom::XML_PATH_UNSECURE_BASE_URL, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID);
}
return parent::afterSave();
}
示例15: afterSave
/**
* Cron settings after save
*
* @return $this
*/
public function afterSave()
{
$cronExprString = '';
$time = explode(',', $this->_configValueFactory->create()->load('paypal/fetch_reports/time', 'path')->getValue());
if ($this->_configValueFactory->create()->load('paypal/fetch_reports/active', 'path')->getValue()) {
$interval = $this->_configValueFactory->create()->load(self::CRON_MODEL_PATH_INTERVAL, 'path')->getValue();
$cronExprString = "{$time[1]} {$time[0]} */{$interval} * *";
}
$this->_configValueFactory->create()->load(self::CRON_STRING_PATH, 'path')->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save();
return parent::afterSave();
}