Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

Adding a filter (for example IA_IMAGE) throws an exception. #26

Open
rbraun75 opened this issue Aug 24, 2017 · 0 comments
Open

Adding a filter (for example IA_IMAGE) throws an exception. #26

rbraun75 opened this issue Aug 24, 2017 · 0 comments
Labels

Comments

@rbraun75
Copy link

Problem noticed

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();

Expected result

Adding a filter throws no exception and filter is executed.

@timjacobi timjacobi added the bug label Dec 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants