本文整理汇总了PHP中Magento\Framework\App\Config\ScopeConfigInterface::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ScopeConfigInterface::getValue方法的具体用法?PHP ScopeConfigInterface::getValue怎么用?PHP ScopeConfigInterface::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Config\ScopeConfigInterface
的用法示例。
在下文中一共展示了ScopeConfigInterface::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @return void
* @throws \Exception
*/
public function execute()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
$data = $this->getRequest()->getParams();
/* Get temporary credentials from session. */
$request_token = [];
$request_token['oauth_token'] = $this->scopeConfig->getValue('sama_twitterfeed/oauth/token', $storeScope);
$request_token['oauth_token_secret'] = $this->scopeConfig->getValue('sama_twitterfeed/oauth/token_secret', $storeScope);
/* If denied, bail. */
if (isset($data['denied'])) {
throw new Exception("Twitter denied permission");
}
/* If the oauth_token is not what we expect, bail. */
if (isset($data['oauth_token']) && $request_token['oauth_token'] !== $data['oauth_token']) {
throw new Exception("Unexpected Oauth token");
}
/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
$connection = new TwitterOAuth($this->_oAuthkey, $this->_oAuthsecret, $request_token['oauth_token'], $request_token['oauth_token_secret']);
/* Request access tokens from twitter */
$access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $data['oauth_verifier']));
/* If HTTP response is 200 continue otherwise send to connect page to retry */
if (200 == $connection->getLastHttpCode()) {
$this->_objectManager->get('Magento\\Framework\\App\\MutableScopeConfig')->setValue('sama_twitterfeed/oauth/access_token', $access_token);
$this->_objectManager->get('Magento\\Framework\\App\\MutableScopeConfig')->setValue('sama_twitterfeed/oauth/token_secret', null);
$this->_objectManager->get('Magento\\Framework\\App\\MutableScopeConfig')->setValue('sama_twitterfeed/oauth/token', null);
} else {
throw new Exception("Twitter Oauth API status code: {$connection->getLastHttpCode()}");
}
return;
}
示例2: getUrl
/**
* @param array $queryParams
* @return string
*/
public function getUrl(array $queryParams = [])
{
if (!$this->config->getValue('rss/config/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return '';
}
return $this->urlBuilder->getUrl('rss/feed/index', $queryParams);
}
示例3: create
/**
* @param \Magento\Sales\Model\Order\Shipment $shipment
* @param RequestInterface $request
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function create(\Magento\Sales\Model\Order\Shipment $shipment, RequestInterface $request)
{
$order = $shipment->getOrder();
$carrier = $this->carrierFactory->create($order->getShippingMethod(true)->getCarrierCode());
if (!$carrier->isShippingLabelsAvailable()) {
throw new \Magento\Framework\Exception\LocalizedException(__('Shipping labels is not available.'));
}
$shipment->setPackages($request->getParam('packages'));
$response = $this->labelFactory->create()->requestToShipment($shipment);
if ($response->hasErrors()) {
throw new \Magento\Framework\Exception\LocalizedException(__($response->getErrors()));
}
if (!$response->hasInfo()) {
throw new \Magento\Framework\Exception\LocalizedException(__('Response info is not exist.'));
}
$labelsContent = [];
$trackingNumbers = [];
$info = $response->getInfo();
foreach ($info as $inf) {
if (!empty($inf['tracking_number']) && !empty($inf['label_content'])) {
$labelsContent[] = $inf['label_content'];
$trackingNumbers[] = $inf['tracking_number'];
}
}
$outputPdf = $this->combineLabelsPdf($labelsContent);
$shipment->setShippingLabel($outputPdf->render());
$carrierCode = $carrier->getCarrierCode();
$carrierTitle = $this->scopeConfig->getValue('carriers/' . $carrierCode . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $shipment->getStoreId());
if (!empty($trackingNumbers)) {
$this->addTrackingNumbersToShipment($shipment, $trackingNumbers, $carrierCode, $carrierTitle);
}
}
示例4: isAllowed
/**
* Check if RSS feed allowed
*
* @return bool
*/
public function isAllowed()
{
if ($this->config->getValue('rss/order/status', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return true;
}
return false;
}
示例5: isStatusNotificationAllow
/**
* Check whether status notification is allowed
*
* @return bool
*/
public function isStatusNotificationAllow()
{
if ($this->_scopeConfig->getValue('rss/order/status_notified', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return true;
}
return false;
}
示例6: isHostBackend
/**
* Return whether the host from request is the backend host
* @return bool
*/
public function isHostBackend()
{
$backendUrl = $this->configInterface->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
$backendHost = parse_url(trim($backendUrl), PHP_URL_HOST);
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
return (strcasecmp($backendHost, $host) === 0);
}
示例7: toOptionArray
/**
* Return available payment methods
*
* @return array
*/
public function toOptionArray()
{
$methods = [];
//default empty value
$methods[] = ["value" => "", "label" => ""];
$accessToken = $this->scopeConfig->getValue(self::XML_PATH_ACCESS_TOKEN, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$clientId = $this->scopeConfig->getValue(self::XML_PATH_CLIENT_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$clientSecret = $this->scopeConfig->getValue(self::XML_PATH_CLIENT_SECRET, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$meHelper = $this->coreHelper;
if (empty($accessToken) && !$meHelper->isValidClientCredentials($clientId, $clientSecret)) {
return $methods;
}
//if accessToken is empty uses clientId and clientSecret to obtain it
if (empty($accessToken)) {
$accessToken = $meHelper->getAccessToken();
}
$country = $this->scopeConfig->getValue('payment/mercadopago/country', 'website', $this->_switcher->getWebsiteId());
$meHelper->log("Get payment methods by country... ", 'mercadopago');
$meHelper->log("API payment methods: " . "/v1/payment_methods?access_token=" . $accessToken, 'mercadopago');
$response = \MercadoPago_Core_Lib_RestClient::get('/sites/' . strtoupper($country) . '/payment_methods?marketplace=NONE');
$meHelper->log("API payment methods", 'mercadopago', $response);
if (isset($response['error'])) {
return $methods;
}
$response = $response['response'];
foreach ($response as $m) {
if (isset($m['id']) && $m['id'] != 'account_money') {
$methods[] = ['value' => $m['id'], 'label' => __($m['name'])];
}
}
return $methods;
}
示例8: create
/**
* {inheritdoc}
*/
public function create(array $arguments = [])
{
if (WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH)) {
return $this->objectManager->create(self::ENTITY_NAME, $arguments);
}
return $this->chainFactory->create($arguments);
}
示例9: create
/**
* {inheritdoc}
*/
public function create(array $arguments = [])
{
if (WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH)) {
return $this->_objectManager->create('Magento\\Developer\\Model\\View\\Asset\\PreProcessor\\DeveloperChain', $arguments);
}
return $this->chainFactory->create($arguments);
}
示例10: validate
/**
* Validate process
*
* @param \Magento\Framework\DataObject $object
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function validate($object)
{
$attributeCode = $this->getAttribute()->getName();
$postDataConfig = $object->getData('use_post_data_config') ?: [];
$isUseConfig = in_array($attributeCode, $postDataConfig);
if ($this->getAttribute()->getIsRequired()) {
$attributeValue = $object->getData($attributeCode);
if ($this->getAttribute()->isValueEmpty($attributeValue) && !$isUseConfig) {
return false;
}
}
if ($this->getAttribute()->getIsUnique()) {
if (!$this->getAttribute()->getEntity()->checkAttributeUniqueValue($this->getAttribute(), $object)) {
$label = $this->getAttribute()->getFrontend()->getLabel();
throw new \Magento\Framework\Exception\LocalizedException(__('The value of attribute "%1" must be unique.', $label));
}
}
if ($attributeCode == 'default_sort_by') {
$available = $object->getData('available_sort_by') ?: [];
$available = is_array($available) ? $available : explode(',', $available);
$data = !in_array('default_sort_by', $postDataConfig) ? $object->getData($attributeCode) : $this->_scopeConfig->getValue("catalog/frontend/default_sort_by", \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
if (!in_array($data, $available) && !in_array('available_sort_by', $postDataConfig)) {
throw new \Magento\Framework\Exception\LocalizedException(__('Default Product Listing Sort by does not exist in Available Product Listing Sort By.'));
}
}
return true;
}
示例11: _validate
/**
* Validate data
*
* @return bool
* @throws Exception
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _validate()
{
$sessionData = $_SESSION[self::VALIDATOR_KEY];
$validatorData = $this->_getSessionEnvironment();
if ($this->_scopeConfig->getValue(self::XML_PATH_USE_REMOTE_ADDR, $this->_scopeType) && $sessionData[self::VALIDATOR_REMOTE_ADDR_KEY] != $validatorData[self::VALIDATOR_REMOTE_ADDR_KEY]) {
throw new Exception('Invalid session ' . self::VALIDATOR_REMOTE_ADDR_KEY . ' value.');
}
if ($this->_scopeConfig->getValue(self::XML_PATH_USE_HTTP_VIA, $this->_scopeType) && $sessionData[self::VALIDATOR_HTTP_VIA_KEY] != $validatorData[self::VALIDATOR_HTTP_VIA_KEY]) {
throw new Exception('Invalid session ' . self::VALIDATOR_HTTP_VIA_KEY . ' value.');
}
$httpXForwardedKey = $sessionData[self::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY];
$validatorXForwarded = $validatorData[self::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY];
if ($this->_scopeConfig->getValue(self::XML_PATH_USE_X_FORWARDED, $this->_scopeType) && $httpXForwardedKey != $validatorXForwarded) {
throw new Exception('Invalid session ' . self::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY . ' value.');
}
if ($this->_scopeConfig->getValue(self::XML_PATH_USE_USER_AGENT, $this->_scopeType) && $sessionData[self::VALIDATOR_HTTP_USER_AGENT_KEY] != $validatorData[self::VALIDATOR_HTTP_USER_AGENT_KEY]) {
foreach ($this->_skippedAgentList as $agent) {
if (preg_match('/' . $agent . '/iu', $validatorData[self::VALIDATOR_HTTP_USER_AGENT_KEY])) {
return true;
}
}
throw new Exception('Invalid session ' . self::VALIDATOR_HTTP_USER_AGENT_KEY . ' value.');
}
return true;
}
示例12: setConfig
/**
* @return true
* @throws Exception
*/
public function setConfig()
{
$posId = $this->scopeConfig->getValue(Payupl::XML_PATH_POS_ID, 'store');
if ($posId) {
$this->posId = $posId;
} else {
throw new Exception('POS ID is empty.');
}
$keyMd5 = $this->scopeConfig->getValue(Payupl::XML_PATH_KEY_MD5, 'store');
if ($keyMd5) {
$this->keyMd5 = $keyMd5;
} else {
throw new Exception('Key MD5 is empty.');
}
$secondKeyMd5 = $this->scopeConfig->getValue(Payupl::XML_PATH_SECOND_KEY_MD5, 'store');
if ($secondKeyMd5) {
$this->secondKeyMd5 = $secondKeyMd5;
} else {
throw new Exception('Second key MD5 is empty.');
}
$posAuthKey = $this->scopeConfig->getValue(Payupl::XML_PATH_POS_AUTH_KEY, 'store');
if ($posAuthKey) {
$this->posAuthKey = $posAuthKey;
} else {
throw new Exception('POS auth key is empty.');
}
return true;
}
示例13: getConfig
/**
* {@inheritdoc}
*/
public function getConfig()
{
$showHide = [];
$enabled = $this->scopeConfiguration->getValue('sr_block_config/general/enabled', ScopeInterface::SCOPE_STORE);
$showHide['show_hide_custom_block'] = $enabled ? true : false;
return $showHide;
}
开发者ID:sohelrana09,项目名称:magento2-module-additional-shipping-block,代码行数:10,代码来源:CustomBlockConfigProvider.php
示例14: sendNotification
public function sendNotification($data)
{
if (!$data) {
return false;
}
$this->inlineTranslation->suspend();
try {
$postObject = new \Magento\Framework\DataObject();
$postObject->setData($data);
$error = false;
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
/* $from = [
'name' => '',
'email' => ''
];*/
$email_template = $this->scopeConfig->getValue('cadou/email/template');
if (empty($email_template)) {
$email_template = (string) 'cadou_email_template';
// this code we have mentioned in the email_templates.xml
}
$transport = $this->_transportBuilder->setTemplateIdentifier($email_template)->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => $this->storeManager->getDefaultStoreView()->getId()])->setTemplateVars(['data' => $postObject, 'subject' => $data['productname']])->setFrom($this->scopeConfig->getValue('contact/email/sender_email_identity', $storeScope))->addTo($data['email'], isset($data['fullname']) ? $data['fullname'] : $data['name'])->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
/*$this->messageManager->addSuccess(
__('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.')
);*/
return TRUE;
} catch (\Exception $e) {
$this->inlineTranslation->resume();
$this->messageManager->addError(__('We can\'t process your request right now. Sorry, that\'s all we know.' . $e->getMessage()));
return FALSE;
}
}
示例15: getLinksTitle
/**
* Return Links Section Title for order item
*
* @return string
*/
public function getLinksTitle()
{
if ($this->_purchasedLinks->getLinkSectionTitle()) {
return $this->_purchasedLinks->getLinkSectionTitle();
}
return $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}