newFromBuilder() public méthode

By default, this method will always return an instance of the calling class. However if post types have been registered with the Post class using the registerPostType() static method, this will now return an instance of that class instead. If the post type string from $attributes->post_type does not appear in the static $postTypes array, then the class instantiated will be the called class (the default behaviour of this method).
public newFromBuilder ( array $attributes = [], null $connection = null ) : mixed
$attributes array
$connection null
Résultat mixed
Exemple #1
0
 public function testPostTypeConstructor()
 {
     Post::registerPostType('video', 'Video');
     $post = new Post();
     $model = $post->newFromBuilder(['post_type' => 'video']);
     $this->assertInstanceOf("Video", $model);
 }