Open rbraun75 opened 7 years ago
Adding a filter as described on https://developers.facebook.com/docs/instant-articles/other-formats throws an Exception:
InvalidArgumentException: Method expects this value ----[ NULL ]---- to be one of the types ====[ string(10) "DOMElement" ]==== in Facebook\InstantArticles\Validators\Type::throwException() (line 182 of [...]/vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Validators/Type.php). Facebook\InstantArticles\Validators\Type::is(NULL, 'DOMElement', 1) (Line: 39) Facebook\InstantArticles\Validators\Type::enforce(NULL, 'DOMElement') (Line: 589) Facebook\InstantArticles\AMP\AMPContext->addItem(NULL) (Line: 444) Facebook\InstantArticles\AMP\AMPArticle->transformArticleContent(Object) (Line: 264) Facebook\InstantArticles\AMP\AMPArticle->transformInstantArticle(Object) (Line: 189) Facebook\InstantArticles\AMP\AMPArticle->toDOMElement(Object) (Line: 38) Facebook\InstantArticles\Elements\Element->render('', 1) (Line: 145) Facebook\InstantArticles\AMP\AMPArticle->render() (Line: 67)
Code:
$amp_article = AMPArticle::create($instant_article_html, $properties); $amp_article->getObserver()->addFilter( 'IA_IMAGE', function ( /*DOMElement*/ $amp_image, /*Facebook\InstantArticles\Elements\Image*/ $ia_image, /*AMPContext*/ $context ) { // filter code }, 10, 3 ); $amp_string = $amp_article->render();
Adding a filter throws no exception and filter is executed.
Problem noticed
Adding a filter as described on https://developers.facebook.com/docs/instant-articles/other-formats throws an Exception:
Code:
Expected result
Adding a filter throws no exception and filter is executed.