This commit is contained in:
weryques 2017-12-05 16:08:13 -02:00
parent a77593cba4
commit 8e829de4e8
3 changed files with 21 additions and 15 deletions

View File

@ -210,25 +210,24 @@ class Log extends Entity {
* @throws \Exception
* @return \Tainacan\Entities\Log
*/
public static function create($msn = false, $desc = '', $new_value = null, $old_value = null)
{
public static function create($msn = false, $desc = '', $new_value = null, $old_value = null) {
$log = new Log();
$log->set_title($msn);
$log->set_description($desc);
$log->set_status('publish'); //TODO may be private
if(!is_null($new_value))
{
if(!is_null($new_value)) {
$type = gettype($new_value);
$log->set_value($new_value);
if(!is_null($old_value)) $log->set_old_value($old_value);
}
elseif($msn === false)
{
elseif($msn === false) {
throw new \Exception('msn or new_value is need to log');
}
global $Tainacan_Logs;
if ($log->validate()) {
return $Tainacan_Logs->insert($log);
} else {

View File

@ -56,11 +56,13 @@ abstract class Repository {
public function get_name() {
return str_replace('Tainacan\Repositories\\', '', get_class($this));
}
/**
*
*
* @param \Tainacan\Entities\Entity $obj
*
* @return \Tainacan\Entities\Entity
* @throws \Exception
*/
public function insert($obj) {
// validate
@ -168,7 +170,7 @@ abstract class Repository {
*
*
* @param array $args [description]
* @return Array $args new $args array with mapped properties
* @return array $args new $args array with mapped properties
*/
public function parse_fetch_args($args = []) {
@ -209,11 +211,16 @@ abstract class Repository {
return $args;
}
public function get_default_properties($map)
{
if(is_array($map))
{
/**
* Return default properties
*
* @param $map
*
* @return array
*/
public function get_default_properties($map) {
if(is_array($map)) {
$map['status'] = [
'map' => 'post_status',
'title' => __('Status', 'tainacan'),

View File

@ -102,7 +102,7 @@ class Terms extends Repository {
*
* @param array $args WP_Query args || int $args the term id
* @param array $taxonomies Array Entities\Taxonomy || Array int terms IDs || int collection id || Entities\Taxonomy taxonomy object
* @return Array of Entities\Term objects || Entities\Term
* @return array of Entities\Term objects || Entities\Term
*/
public function fetch( $args = [], $taxonomies = []){