add some documentation

This commit is contained in:
Jacson Passold 2018-01-18 12:28:20 -02:00
parent 9788debde2
commit 221adb35e6
1 changed files with 22 additions and 0 deletions

View File

@ -2,16 +2,30 @@
namespace Tainacan\Traits;
use Tainacan\Entities;
use Tainacan\Entities\Collection;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// used by Item, Event, Field
/**
* Defines Collection and Items relation
* @author medialab
*
*/
trait Entity_Collection_Relation {
/**
*
* @return int collection item ID
*/
public function get_collection_id() {
return $this->get_mapped_property('collection_id');
}
/**
* Return Collection from relation
* @return \Entities\Collection|NULL Return Collection or null on errors
*/
public function get_collection() {
if (isset($this->collection) && $this->collection instanceof Entities\Collection)
return $this->collection;
@ -26,11 +40,19 @@ trait Entity_Collection_Relation {
return null;
}
/**
* Set collection ID
* @param int $value
*/
public function set_collection_id($value) {
$this->collection = null;
$this->set_mapped_property('collection_id', $value);
}
/**
* set collection object and id
* @param Entities\Collection $collection
*/
public function set_collection(Entities\Collection $collection) {
$this->collection = $collection;
$this->set_collection_id($collection->get_id());