2018-02-08 18:28:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tainacan\Tests\Factories;
|
|
|
|
|
|
|
|
class Item_Metadata_Factory {
|
|
|
|
private $item_metadata;
|
|
|
|
|
2018-06-11 15:10:07 +00:00
|
|
|
public function create_item_metadata(\Tainacan\Entities\Item $item, \Tainacan\Entities\Metadatum $metadatum, $value = ''){
|
2018-04-11 14:18:55 +00:00
|
|
|
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
2018-07-17 15:51:59 +00:00
|
|
|
$this->item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $metadatum);
|
2018-02-08 18:28:30 +00:00
|
|
|
|
|
|
|
if (!empty($value))
|
2018-07-17 15:51:59 +00:00
|
|
|
$this->item_metadata->set_value($value);
|
2018-02-08 18:28:30 +00:00
|
|
|
|
2018-07-17 15:51:59 +00:00
|
|
|
if ($this->item_metadata->validate()) {
|
|
|
|
$this->item_metadata = $Tainacan_Item_Metadata->insert($this->item_metadata);
|
2018-02-08 18:28:30 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 15:51:59 +00:00
|
|
|
return $this->item_metadata; // If not validated, get_error() method should return the errors. Its up to the tests to use it or not
|
2018-02-08 18:28:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|