commerce-8.x-2.8/src/Resolver/DefaultCountryResolver.php

src/Resolver/DefaultCountryResolver.php
<?php

namespace Drupal\commerce\Resolver;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\commerce\Country;

/**
 * Returns the site's default country.
 */
class DefaultCountryResolver implements CountryResolverInterface {

  /**
   * The configuration factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new DefaultCountryResolver object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function resolve() {
    $country_code = $this->configFactory->get('system.date')->get('country.default');
    return new Country($country_code);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc