Backdrop now has a consistent way of performing all CRUD functions for entities, as well as accessing entity properties such as label, revision, id, etc.
This applies to:
Taxonomy Term (and Vocabulary) entities
User
Node
File
Example implementation:
Create a File entity:
$url = 'path/to/file.file_extension'; // Can be a stream wrapper, such as 'Public://myfile.txt'
$file = entity_create('file', array(
'fid' => NULL,
'uid' => 1,
'filename' => 'newfile.file',
'uri' => $url,
'filemime' => 'text/plain',
'filesize' => filesize($url),
'status' => 1,
'timestamp' => REQUEST_TIME,
));
$file->save();
Files entities are currently owned by System module. After completing this conversion, it's likely we will follow D8's suit here and move the hook_entity_info()
for files into File module after this conversion.
Drupal.org issue: https://drupal.org/node/1361226
Introduced in branch:
1.0.x
Introduced in version:
1.0.0
Impacts:
Module developers
Theme developers
Related Github Issues: