'Create a blog entity', ]; $ret['blog-create-values'] = [ 'description' => 'Create a blog entity with values', ]; $ret['blog-delete'] = [ 'description' => 'Delete a blog entity by its id', ]; $ret['blog-load'] = [ 'description' => 'Load a blog entity by its id', ]; return $ret; } /** * Command callback for blog-create. */ function drush_blog_create() { $blog = Blog::create(); $blog->save(); } /** * Command callback for blog-create-values. */ function drush_blog_create_values() { $values = [ 'title' => 'Drupal user group', 'date' => (new \DateTime())->format(DATETIME_DATETIME_STORAGE_FORMAT), 'description' => [ 'value' => '
The monthly meeting of Drupalists is happening today!
', 'format' => 'restricted_html', ], ]; $blog = Blog::create($values); $blog->save(); } /** * Command callback for blog-delete. * * @param int $id * The id of a blog to delete. */ function drush_blog_delete($id) { $blog = Blog::load($id); if (!$blog) { return; } $blog->delete(); } /** * Command callback for blog-delete. * * @param int $id * The id of a blog to load and display. */ function drush_blog_load($id) { $blog = Blog::load($id); if (!$blog) { return; } echo "Blog id: " . $blog->id() . ", uuid: " . $blog->uuid() . "\n"; print_r($blog->toArray()); }