public function Transformer::addRules in Facebook Instant Articles 8.2
Same name and namespace in other branches
- 3.x src/Transformer.php \Drupal\fb_instant_articles\Transformer::addRules()
Adds rules from an array of rule information.
Parameters
array $rules: An array of transformer rule arrays. This is a PHP array representation of the JSON list of Rules information expected by parent::loadRules().
Throws
\ReflectionException In case the class specified by one of the given $rules cannot be found.
See also
\Facebook\InstantArticles\Transformer\Transformer::loadRules()
1 call to Transformer::addRules()
- Transformer::__construct in src/
Transformer.php - Transformer constructor.
File
- src/
Transformer.php, line 64
Class
- Transformer
- Encapsulates Drupal-specific logic when using the Transformer class.
Namespace
Drupal\fb_instant_articlesCode
public function addRules(array $rules) {
foreach ($rules as $rule) {
$class = $rule['class'];
try {
$factory_method = new \ReflectionMethod($class, 'createFrom');
} catch (\ReflectionException $e) {
$factory_method = new \ReflectionMethod('Facebook\\InstantArticles\\Transformer\\Rules\\' . $class, 'createFrom');
}
$this
->addRule($factory_method
->invoke(NULL, $rule));
}
}