public function TransformerExtender::addRules in Facebook Instant Articles 7.2
Adds rules from an array of rule information.
@todo Propose adding this method upstream to the FB Instant SDK parent.
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().
See also
TransformerExtender::__construct()
\Facebook\InstantArticles\Transformer\Transformer::loadRules()
1 call to TransformerExtender::addRules()
- TransformerExtender::__construct in src/
TransformerExtender.php - Transformer constructor.
File
- src/
TransformerExtender.php, line 50 - Contains \Drupal\fb_instant_articles\TransformerExtender.
Class
- TransformerExtender
- Encapsulates Drupal-specific logic when using the Transformer class.
Namespace
Drupal\fb_instant_articlesCode
public function addRules(array $rules) {
foreach ($rules as $rules) {
$clazz = $rules['class'];
try {
$factory_method = new \ReflectionMethod($clazz, 'createFrom');
} catch (\ReflectionException $e) {
$factory_method = new \ReflectionMethod('Facebook\\InstantArticles\\Transformer\\Rules\\' . $clazz, 'createFrom');
}
$this
->addRule($factory_method
->invoke(null, $rules));
}
}