You are here

public function Transformer::__construct in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 src/Transformer.php \Drupal\fb_instant_articles\Transformer::__construct()

Transformer constructor.

Wraps the Transformer object from the SDK to introduce a default set of rules any time it's instantiated, including an opportunity for other modules to alter the set of rules that are used.

Note the parent class does not have a constructor, so we do not call

parent::__construct();

.

Parameters

\Drupal\fb_instant_articles\TransformerRulesManager $transformer_rules_manager: Transformer rules manager service.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: Config factory service.

Throws

\ReflectionException In case the class specified by one of the loaded $rules cannot be found.

See also

hook_fb_instant_articles_transformer_rules_alter()

File

src/Transformer.php, line 40

Class

Transformer
Encapsulates Drupal-specific logic when using the Transformer class.

Namespace

Drupal\fb_instant_articles

Code

public function __construct(TransformerRulesManager $transformer_rules_manager, ConfigFactoryInterface $config_factory) {
  parent::__construct();
  $this->transformerRulesManager = $transformer_rules_manager;
  $this
    ->addRules($this->transformerRulesManager
    ->getRules());

  // Override the default timezone according to the site wide timezone.
  $config_data_default_timezone = $config_factory
    ->get('system.date')
    ->get('timezone.default');
  $default_time_zone = !empty($config_data_default_timezone) ? $config_data_default_timezone : @date_default_timezone_get();
  $this
    ->setDefaultDateTimeZone(new \DateTimeZone($default_time_zone));
}