Flarum\Core\Post::boot PHP Method

boot() public static method

public static boot ( )
    public static function boot()
    {
        parent::boot();
        // When a post is created, set its type according to the value of the
        // subclass. Also give it an auto-incrementing number within the
        // discussion.
        static::creating(function (Post $post) {
            $post->type = $post::$type;
            $post->number = ++$post->discussion->number_index;
            $post->discussion->save();
        });
        static::deleted(function (Post $post) {
            $post->raise(new PostWasDeleted($post));
        });
        static::addGlobalScope(new RegisteredTypesScope());
    }