PHP code example of clarkwinkelmann / flarum-ext-scout
1. Go to this page and download the library: Download clarkwinkelmann/flarum-ext-scout library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
clarkwinkelmann / flarum-ext-scout example snippets
use ClarkWinkelmann\Scout\Extend\Scout;
use Acme\Event\SubtitleRenamed;
return [
(new Scout(Discussion::class))
->listenSaved(SubtitleRenamed::class, function (SubtitleRenamed $event) {
return $event->discussion;
})
->attributes(function (Discussion $discussion): array {
return [
'subtitle' => $discussion->subtitle,
];
}),
];
use ClarkWinkelmann\Scout\ScoutModelWrapper;
use Flarum\Discussion\Discussion;
/**
* @var Discussion $discussion
*/
$discussion->subtitle = 'New value';
$discussion->save();
(new ScoutModelWrapper($discussion))->scoutObserverSaved();