Search code examples
bolt-cmsifttt

Retrieve event content object link in bolt


I'm writing an extension which send notifications to IFTTT when a content is published on my bolt install.

Using callbacks in my extension, I can get the \Bolt\Content object linked to the raised event but how can I get its permalink ?

Here is the callback code :

public function postSaveCallback(\Bolt\Events\StorageEvent $event)
{
    $content = $event->getContent();

    // Payload 
    $payload = array(
        'value1' => $content->get('title'),
        'value2' => $content->get('link')
    );

    $this->sendRequest("published", $payload);
}

Variable $content->title is retrieved and has the given value, but $content->link is empty.


Solution

  • Ok, got it.

    link is not a variable but a function defined in Bolt\Content.

    So, I just need to call 'value2' => $content->link()