Flarum\Core\Post::setModel PHP Method

setModel() public static method

Set the model for the given post type.
public static setModel ( string $type, string $model ) : void
$type string The post type.
$model string The class name of the model for that type.
return void
    public static function setModel($type, $model)
    {
        static::$models[$type] = $model;
    }

Usage Example

コード例 #1
0
 public function registerPostTypes()
 {
     $models = ['Flarum\\Core\\Post\\CommentPost', 'Flarum\\Core\\Post\\DiscussionRenamedPost'];
     $this->app->make('events')->fire(new ConfigurePostTypes($models));
     foreach ($models as $model) {
         Post::setModel($model::$type, $model);
     }
 }