convert code to namespaces basis
This commit is contained in:
parent
e444acf532
commit
f66ed5c3f1
|
@ -29,40 +29,54 @@ require_once(VENDOR_DIR . 'autoload.php');
|
|||
spl_autoload_register('tainacan_autoload');
|
||||
|
||||
function tainacan_autoload($class_name){
|
||||
foreach(DIRS as $dir){
|
||||
$class_path = explode('\\', $class_name);
|
||||
$class_name = end($class_path);
|
||||
if(count($class_path) == 1 ) {
|
||||
foreach(DIRS as $dir) {
|
||||
$file = $dir . 'class-'. strtolower(str_replace('_', '-' , $class_name)) . '.php';
|
||||
if(file_exists($file)){
|
||||
if(file_exists($file)) {
|
||||
require_once($file);
|
||||
}
|
||||
// else if($class_name == 'Respect\Validation\Validator'){
|
||||
// requiere_once(VENDOR_DIR . 'autoload.php');
|
||||
// }
|
||||
}
|
||||
}
|
||||
elseif ($class_path[0] == 'Tainacan') {
|
||||
$dir = strtolower(CLASSES_DIR.implode(DIRECTORY_SEPARATOR, array_slice($class_path, 1, count($class_path) -2) )).'/';
|
||||
$dir = str_replace('_', '-', $dir);
|
||||
//var_dump($dir);
|
||||
$file = $dir . 'class-tainacan-'. strtolower(str_replace('_', '-' , $class_name)) . '.php';
|
||||
//var_dump($file);
|
||||
if(file_exists($file)) {
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global $Tainacan_Collections;
|
||||
$Tainacan_Collections = new Tainacan_Collections();
|
||||
$Tainacan_Collections = new \Tainacan\Repositories\Collections();
|
||||
|
||||
global $Tainacan_Item_Metadata;
|
||||
$Tainacan_Item_Metadata = new Tainacan_Item_Metadata();
|
||||
$Tainacan_Item_Metadata = new \Tainacan\Repositories\Item_Metadata();
|
||||
|
||||
global $Tainacan_Metadatas;
|
||||
$Tainacan_Metadatas = new Tainacan_Metadatas();
|
||||
$Tainacan_Metadatas = new \Tainacan\Repositories\Metadatas();
|
||||
|
||||
global $Tainacan_Filters;
|
||||
$Tainacan_Filters = new Tainacan_Filters();
|
||||
$Tainacan_Filters = new \Tainacan\Repositories\Filters();
|
||||
|
||||
global $Tainacan_Taxonomies;
|
||||
$Tainacan_Taxonomies = new Tainacan_Taxonomies();
|
||||
$Tainacan_Taxonomies = new \Tainacan\Repositories\Taxonomies();
|
||||
|
||||
global $Tainacan_Items;
|
||||
$Tainacan_Items = new Tainacan_Items();
|
||||
$Tainacan_Items = new \Tainacan\Repositories\Items();
|
||||
|
||||
global $Tainacan_Terms;
|
||||
$Tainacan_Terms = new Tainacan_Terms();
|
||||
$Tainacan_Terms = new \Tainacan\Repositories\Terms();
|
||||
|
||||
global $Tainacan_Logs;
|
||||
$Tainacan_Logs = new Tainacan_Logs();
|
||||
$Tainacan_Logs = new \Tainacan\Repositories\Logs();
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan;
|
||||
|
||||
class Tainacan_Entity {
|
||||
class Entity {
|
||||
|
||||
var $repository;
|
||||
var $errors = [];
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan;
|
||||
|
||||
class Tainacan_Repository {
|
||||
class Repository {
|
||||
|
||||
function find_by($prop, $value) {
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Collection extends Tainacan_Entity {
|
||||
class Collection extends \Tainacan\Entity {
|
||||
|
||||
function __construct($which = 0) {
|
||||
|
||||
|
@ -11,14 +14,14 @@ class Tainacan_Collection extends Tainacan_Entity {
|
|||
|
||||
if (is_numeric($which) && $which > 0) {
|
||||
$post = get_post($which);
|
||||
if ($post instanceof WP_Post) {
|
||||
if ($post instanceof \WP_Post) {
|
||||
$this->WP_Post = get_post($which);
|
||||
}
|
||||
|
||||
} elseif ($which instanceof WP_Post) {
|
||||
} elseif ($which instanceof \WP_Post) {
|
||||
$this->WP_Post = $which;
|
||||
} else {
|
||||
$this->WP_Post = new StdClass();
|
||||
$this->WP_Post = new \StdClass();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +100,7 @@ class Tainacan_Collection extends Tainacan_Entity {
|
|||
|
||||
// metadata
|
||||
function get_metadata() {
|
||||
$Tainacan_Metadatas = new Tainacan_Metadatas();
|
||||
$Tainacan_Metadatas = new \Tainacan\Repositories\Metadatas();
|
||||
return $Tainacan_Metadatas->get_metadata_by_collection($this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Filter extends Tainacan_Entity {
|
||||
class Filter extends \Tainacan\Entity {
|
||||
|
||||
use Tainacan_Entity_Collection_Relation;
|
||||
use \Tainacan\Traits\Entity_Collection_Relation;
|
||||
|
||||
function __construct( $which = 0 ) {
|
||||
|
||||
|
@ -13,14 +16,14 @@ class Tainacan_Filter extends Tainacan_Entity {
|
|||
|
||||
if ( is_numeric( $which ) && $which > 0) {
|
||||
$post = get_post( $which );
|
||||
if ( $post instanceof WP_Post) {
|
||||
if ( $post instanceof \WP_Post) {
|
||||
$this->WP_Post = get_post( $which );
|
||||
}
|
||||
|
||||
} elseif ( $which instanceof WP_Post ) {
|
||||
} elseif ( $which instanceof \WP_Post ) {
|
||||
$this->WP_Post = $which;
|
||||
} else {
|
||||
$this->WP_Post = new StdClass();
|
||||
$this->WP_Post = new \StdClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +48,7 @@ class Tainacan_Filter extends Tainacan_Entity {
|
|||
|
||||
function get_metadata() {
|
||||
$id = $this->get_mapped_property('metadata');
|
||||
return new Tainacan_Metadata( $id );
|
||||
return new \Tainacan\Entities\Metadata( $id );
|
||||
}
|
||||
|
||||
function get_filter_type_object(){
|
||||
|
@ -77,12 +80,12 @@ class Tainacan_Filter extends Tainacan_Entity {
|
|||
* @param Tainacan_Metadata / int $value
|
||||
*/
|
||||
function set_metadata( $value ){
|
||||
$id = ( $value instanceof Tainacan_Metadata ) ? $value->get_id() : $value;
|
||||
$id = ( $value instanceof \Tainacan\Entities\Metadata ) ? $value->get_id() : $value;
|
||||
|
||||
return $this->set_mapped_property('metadata', $id);
|
||||
}
|
||||
|
||||
function set_filter_type_object( Tainacan_Filter_Type $value ){
|
||||
function set_filter_type_object( \Tainacan\Filter_Types\Filter_Type $value ){
|
||||
// TODO: validate primitive type with filter
|
||||
//if filter matches the metadata type
|
||||
//if( in_array( $type->get_primitive_type(), $value->get_supported_types() ) ){
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Item_Metadata_Entity extends Tainacan_Entity {
|
||||
class Item_Metadata_Entity extends \Tainacan\Entity {
|
||||
|
||||
function __construct(Tainacan_Item $item, Tainacan_Metadata $metadata) {
|
||||
function __construct(Item $item, Metadata $metadata) {
|
||||
|
||||
$this->repository = 'Tainacan_Item_Metadata';
|
||||
|
||||
|
@ -13,7 +16,7 @@ class Tainacan_Item_Metadata_Entity extends Tainacan_Entity {
|
|||
$this->set_metadata($metadata);
|
||||
}
|
||||
|
||||
function set_item(Tainacan_Item $item) {
|
||||
function set_item(Item $item) {
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
|
@ -21,7 +24,7 @@ class Tainacan_Item_Metadata_Entity extends Tainacan_Entity {
|
|||
$this->value = $value;
|
||||
}
|
||||
|
||||
function set_metadata(Tainacan_Metadata $metadata) {
|
||||
function set_metadata(Metadata $metadata) {
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
|
@ -37,7 +40,7 @@ class Tainacan_Item_Metadata_Entity extends Tainacan_Entity {
|
|||
if (isset($this->value))
|
||||
return $this->value;
|
||||
|
||||
$Tainacan_Item_Metadata = new Tainacan_Item_Metadata();
|
||||
$Tainacan_Item_Metadata = new Item_Metadata_Entity();
|
||||
return $Tainacan_Item_Metadata->get_item_metadata_value($this);
|
||||
}
|
||||
|
||||
|
@ -102,7 +105,7 @@ class Tainacan_Item_Metadata_Entity extends Tainacan_Entity {
|
|||
} else {
|
||||
|
||||
if ($this->is_collection_key()) {
|
||||
$Tainacan_Items = new Tainacan_Items();
|
||||
$Tainacan_Items = new \Tainacan\Repositories\Items();
|
||||
|
||||
$test = $Tainacan_Items->query([
|
||||
'collections' => $item->get_collection(),
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Item extends Tainacan_Entity {
|
||||
class Item extends \Tainacan\Entity {
|
||||
|
||||
use Tainacan_Entity_Collection_Relation;
|
||||
use \Tainacan\Traits\Entity_Collection_Relation;
|
||||
|
||||
function __construct($which = 0) {
|
||||
|
||||
|
@ -13,14 +16,14 @@ class Tainacan_Item extends Tainacan_Entity {
|
|||
|
||||
if (is_numeric($which) && $which > 0) {
|
||||
$post = get_post($which);
|
||||
if ($post instanceof WP_Post) {
|
||||
if ($post instanceof \WP_Post) {
|
||||
$this->WP_Post = get_post($which);
|
||||
}
|
||||
|
||||
} elseif ($which instanceof WP_Post) {
|
||||
} elseif ($which instanceof \WP_Post) {
|
||||
$this->WP_Post = $which;
|
||||
} else {
|
||||
$this->WP_Post = new StdClass();
|
||||
$this->WP_Post = new \StdClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,16 +70,16 @@ class Tainacan_Item extends Tainacan_Entity {
|
|||
$metaList = $collection->get_metadata();
|
||||
|
||||
foreach ($metaList as $meta) {
|
||||
$return[$meta->get_id()] = new Tainacan_Item_Metadata_Entity($this, $meta);
|
||||
$return[$meta->get_id()] = new Item_Metadata_Entity($this, $meta);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function add_metadata(Tainacan_Metadata $new_metadata, $value) {
|
||||
function add_metadata(Metadata $new_metadata, $value) {
|
||||
|
||||
//TODO Multiple metadata must receive an array as value
|
||||
$item_metadata = new Tainacan_Item_Metadata_Entity($this, $new_metadata);
|
||||
$item_metadata = new Item_Metadata_Entity($this, $new_metadata);
|
||||
$item_metadata->set_value($value);
|
||||
$current_meta = $this->get_metadata();
|
||||
$current_meta[$new_metadata->get_id()] = $item_metadata;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Tainacan_Log extends Tainacan_Entity {
|
||||
class Log extends \Tainacan\Entity {
|
||||
|
||||
function __construct($which = 0) {
|
||||
|
||||
|
@ -15,14 +14,14 @@ class Tainacan_Log extends Tainacan_Entity {
|
|||
|
||||
if (is_numeric($which) && $which > 0) {
|
||||
$post = get_post($which);
|
||||
if ($post instanceof WP_Post) {
|
||||
if ($post instanceof \WP_Post) {
|
||||
$this->WP_Post = get_post($which);
|
||||
}
|
||||
|
||||
} elseif ($which instanceof WP_Post) {
|
||||
} elseif ($which instanceof \WP_Post) {
|
||||
$this->WP_Post = $which;
|
||||
} else {
|
||||
$this->WP_Post = new StdClass();
|
||||
$this->WP_Post = new \StdClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Metadata extends Tainacan_Entity {
|
||||
class Metadata extends \Tainacan\Entity {
|
||||
|
||||
use Tainacan_Entity_Collection_Relation;
|
||||
use \Tainacan\Traits\Entity_Collection_Relation;
|
||||
|
||||
function __construct( $which = 0 ) {
|
||||
|
||||
|
@ -13,14 +16,14 @@ class Tainacan_Metadata extends Tainacan_Entity {
|
|||
|
||||
if ( is_numeric( $which ) && $which > 0) {
|
||||
$post = get_post( $which );
|
||||
if ( $post instanceof WP_Post) {
|
||||
if ( $post instanceof \WP_Post) {
|
||||
$this->WP_Post = get_post( $which );
|
||||
}
|
||||
|
||||
} elseif ( $which instanceof WP_Post ) {
|
||||
} elseif ( $which instanceof \WP_Post ) {
|
||||
$this->WP_Post = $which;
|
||||
} else {
|
||||
$this->WP_Post = new StdClass();
|
||||
$this->WP_Post = new \StdClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -128,7 +131,7 @@ class Tainacan_Metadata extends Tainacan_Entity {
|
|||
return $this->set_mapped_property('default_property', $value);
|
||||
}
|
||||
|
||||
function set_field_type_object(Tainacan_Field_Type $value){
|
||||
function set_field_type_object(\Tainacan\Field_Types\Field_Type $value){
|
||||
$this->set_field_type( get_class( $value ) );
|
||||
return $this->set_mapped_property('field_type_object', serialize($value) ) ;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Taxonomy extends Tainacan_Entity {
|
||||
class Taxonomy extends \Tainacan\Entity {
|
||||
|
||||
use Tainacan_Entity_Collections_Relation;
|
||||
use \Tainacan\Traits\Entity_Collection_Relation;
|
||||
|
||||
function __construct( $which = 0 ) {
|
||||
|
||||
|
@ -14,14 +17,14 @@ class Tainacan_Taxonomy extends Tainacan_Entity {
|
|||
if ( is_numeric( $which ) && $which > 0) {
|
||||
$post = get_post( $which );
|
||||
|
||||
if ( $post instanceof WP_Post) {
|
||||
if ( $post instanceof \WP_Post) {
|
||||
$this->WP_Post = get_post( $which );
|
||||
}
|
||||
|
||||
} elseif ( $which instanceof WP_Post ) {
|
||||
} elseif ( $which instanceof \WP_Post ) {
|
||||
$this->WP_Post = $which;
|
||||
} else {
|
||||
$this->WP_Post = new StdClass();
|
||||
$this->WP_Post = new \StdClass();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Entities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Term extends Tainacan_Entity {
|
||||
class Term extends \Tainacan\Entity {
|
||||
|
||||
function __construct($which = 0, $taxonomy = '' ) {
|
||||
|
||||
|
@ -13,14 +16,14 @@ class Tainacan_Term extends Tainacan_Entity {
|
|||
if ( is_numeric( $which ) && $which > 0) {
|
||||
$post = get_term_by('id', $which, $taxonomy);
|
||||
|
||||
if ( $post instanceof WP_Term) {
|
||||
if ( $post instanceof \WP_Term) {
|
||||
$this->WP_Term = get_term_by('id', $which, $taxonomy);
|
||||
}
|
||||
|
||||
} elseif ( $which instanceof WP_Term ) {
|
||||
} elseif ( $which instanceof \WP_Term ) {
|
||||
$this->WP_Term = $which;
|
||||
} else {
|
||||
$this->WP_Term = new StdClass();
|
||||
$this->WP_Term = new \StdClass();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Checkbox_Field_Type extends Tainacan_Field_Type {
|
||||
class Checkbox_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'date';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Textarea_Field_Type extends Tainacan_Field_Type {
|
||||
class Textarea_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'date';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
abstract class Tainacan_Field_Type {
|
||||
abstract class Field_Type {
|
||||
|
||||
var $primitive_type;
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Numeric_Field_Type extends Tainacan_Field_Type {
|
||||
class Numeric_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'float';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Radio_Field_Type extends Tainacan_Field_Type {
|
||||
class Radio_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = '';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Relationship_Field_Type extends Tainacan_Field_Type {
|
||||
class Relationship_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = '';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Selectbox_Field_Type extends Tainacan_Field_Type {
|
||||
class Selectbox_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = '';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Text_Field_Type extends Tainacan_Field_Type {
|
||||
class Text_Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'string';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Field_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Textarea_Field_Type extends Tainacan_Field_Type {
|
||||
class Field_Type extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'string';
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Filter_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
abstract class Tainacan_Filter_Type extends Tainacan_Entity {
|
||||
abstract class Filter_Type extends \Tainacan\Entity {
|
||||
|
||||
var $supported_types = [];
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
namespace Tainacan\Filter_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_List_Filter_Type extends Tainacan_Filter_Type {
|
||||
class List_Filter_Type extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->supported_types[] = 'string';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Filter_Types;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class TainacanFieldType
|
||||
*/
|
||||
class Tainacan_Range_Filter_Type extends Tainacan_Filter_Type {
|
||||
class Range_Filter_Type extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->supported_types = ['float','date'];
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
use Respect\Validation\Validator as v;
|
||||
use \Respect\Validation\Validator as v;
|
||||
|
||||
class Tainacan_Collections {
|
||||
class Collections {
|
||||
|
||||
const POST_TYPE = 'tainacan-collections';
|
||||
var $map;
|
||||
|
@ -84,7 +87,7 @@ class Tainacan_Collections {
|
|||
register_post_type(self::POST_TYPE, $args);
|
||||
}
|
||||
|
||||
function insert(Tainacan_Collection $collection) {
|
||||
function insert(\Tainacan\Entities\Collection $collection) {
|
||||
|
||||
// validate
|
||||
if (!$collection->validate())
|
||||
|
@ -135,7 +138,7 @@ class Tainacan_Collections {
|
|||
$collection->register_post_type();
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Collection($collection->WP_Post);
|
||||
return new \Tainacan\Entities\Collection($collection->WP_Post);
|
||||
}
|
||||
|
||||
function get_collections($args = array()) {
|
||||
|
@ -151,7 +154,7 @@ class Tainacan_Collections {
|
|||
$return = [];
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$return[] = new Tainacan_Collection($post);
|
||||
$return[] = new \Tainacan\Entities\Collection($post);
|
||||
}
|
||||
|
||||
// TODO: Pegar coleções registradas via código
|
||||
|
@ -160,7 +163,7 @@ class Tainacan_Collections {
|
|||
}
|
||||
|
||||
function get_collection_by_id($id) {
|
||||
return new Tainacan_Collection($id);
|
||||
return new \Tainacan\Entities\Collection($id);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Filters {
|
||||
class Filters {
|
||||
|
||||
const POST_TYPE = 'tainacan-filters';
|
||||
|
||||
|
@ -90,10 +93,10 @@ class Tainacan_Filters {
|
|||
|
||||
|
||||
/**
|
||||
* @param Tainacan_Metadata $metadata
|
||||
* @param \Tainacan\Entities\Metadata $metadata
|
||||
* @return int
|
||||
*/
|
||||
function insert( Tainacan_Filter $metadata ) {
|
||||
function insert( \Tainacan\Entities\Filter $metadata ) {
|
||||
// First iterate through the native post properties
|
||||
$map = $this->get_map();
|
||||
foreach ($map as $prop => $mapped) {
|
||||
|
@ -122,7 +125,7 @@ class Tainacan_Filters {
|
|||
}
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Filter($metadata->WP_Post);
|
||||
return new \Tainacan\Entities\Filter($metadata->WP_Post);
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,17 +148,17 @@ class Tainacan_Filters {
|
|||
'meta_value' => $collection_id
|
||||
], $args);
|
||||
|
||||
$wp_query = new WP_Query($args);
|
||||
$wp_query = new \WP_Query($args);
|
||||
|
||||
return $wp_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Tainacan_Filter
|
||||
* @return \Tainacan\Entities\Filter
|
||||
*/
|
||||
function get_filter_by_id($id) {
|
||||
return new Tainacan_Filter($id);
|
||||
return new \Tainacan\Entities\Filter($id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Item_Metadata {
|
||||
|
||||
|
||||
class Tainacan_Item_Metadata {
|
||||
|
||||
function get_item_metadata_by_item(Tainacan_Item $item) {
|
||||
function get_item_metadata_by_item(\Tainacan\Entities\Item $item) {
|
||||
global $Tainacan_Items, $Tainacan_Metadatas;
|
||||
|
||||
$collection = $item->get_collection();
|
||||
|
||||
if (!$collection instanceof Tainacan_Collection){
|
||||
if (!$collection instanceof \Tainacan\Entities\Collection){
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -22,7 +23,7 @@ class Tainacan_Item_Metadata {
|
|||
|
||||
if (is_array($meta_list)) {
|
||||
foreach ($meta_list as $meta) {
|
||||
$return = new Tainacan_Item_Metadata_Entity($item, $meta);
|
||||
$return = new \Tainacan\Entities\Item_Metadata_Entity($item, $meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +31,7 @@ class Tainacan_Item_Metadata {
|
|||
|
||||
}
|
||||
|
||||
function insert(Tainacan_Item_Metadata_Entity $item_metadata) {
|
||||
function insert(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
|
||||
|
||||
$unique = ! $item_metadata->is_multiple();
|
||||
|
||||
|
@ -47,11 +48,11 @@ class Tainacan_Item_Metadata {
|
|||
}
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Item_Metadata_Entity($item_metadata->get_item(), $item_metadata->get_metadata());
|
||||
return new \Tainacan\Entities\Item_Metadata_Entity($item_metadata->get_item(), $item_metadata->get_metadata());
|
||||
|
||||
}
|
||||
|
||||
function get_item_metadata_value(Tainacan_Item_Metadata_Entity $item_metadata) {
|
||||
function get_item_metadata_value(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
|
||||
|
||||
$unique = ! $item_metadata->is_multiple();
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Tainacan_Items {
|
||||
class Items {
|
||||
|
||||
function __construct() {
|
||||
add_action('init', array(&$this, 'register_post_types'));
|
||||
|
@ -56,7 +59,7 @@ class Tainacan_Items {
|
|||
}
|
||||
}
|
||||
|
||||
function insert(Tainacan_Item $item) {
|
||||
function insert(\Tainacan\Entities\Item $item) {
|
||||
$map = $this->get_map();
|
||||
|
||||
// get collection to determine post type
|
||||
|
@ -107,7 +110,7 @@ class Tainacan_Items {
|
|||
}
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Item($item->WP_Post);
|
||||
return new \Tainacan\Entities\Item($item->WP_Post);
|
||||
}
|
||||
|
||||
// collections id or array of ids; collection object or array of objects
|
||||
|
@ -123,7 +126,7 @@ class Tainacan_Items {
|
|||
$collections = $Tainacan_Collections->get_collection_by_id($collection);
|
||||
}
|
||||
|
||||
if ($collections instanceof Tainacan_Collection) {
|
||||
if ($collections instanceof \Tainacan\Entities\Collection) {
|
||||
$cpt = $collections->get_db_identifier();
|
||||
} elseif (is_array($collections)) {
|
||||
$cpt = [];
|
||||
|
@ -132,7 +135,7 @@ class Tainacan_Items {
|
|||
if (is_numeric($collection)){
|
||||
$collection = $Tainacan_Collections->get_collection_by_id($collection);
|
||||
}
|
||||
if ($collection instanceof Tainacan_Collection){
|
||||
if ($collection instanceof \Tainacan\Entities\Collection){
|
||||
$cpt[] = $collection->get_db_identifier();
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +159,7 @@ class Tainacan_Items {
|
|||
$return = [];
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$return[] = new Tainacan_Item($post);
|
||||
$return[] = new \Tainacan\Entities\Item($post);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -211,6 +214,6 @@ class Tainacan_Items {
|
|||
}
|
||||
|
||||
function get_item_by_id($id) {
|
||||
return new Tainacan_Item($id);
|
||||
return new \Tainacan\Entities\Item($id);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Tainacan_Logs extends Tainacan_Repository {
|
||||
class Logs extends \Tainacan\Repository {
|
||||
|
||||
const POST_TYPE = 'tainacan-logs';
|
||||
|
||||
|
@ -86,7 +88,7 @@ class Tainacan_Logs extends Tainacan_Repository {
|
|||
register_post_type(self::POST_TYPE, $args);
|
||||
}
|
||||
|
||||
function insert(Tainacan_Log $log) {
|
||||
function insert(\Tainacan\Entities\Log $log) {
|
||||
// First iterate through the native post properties
|
||||
$map = $this->get_map();
|
||||
foreach ($map as $prop => $mapped) {
|
||||
|
@ -118,7 +120,7 @@ class Tainacan_Logs extends Tainacan_Repository {
|
|||
}*/
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Log($log->WP_Post);
|
||||
return new \Tainacan\Entities\Log($log->WP_Post);
|
||||
}
|
||||
|
||||
function get_logs($args = array()) {
|
||||
|
@ -134,7 +136,7 @@ class Tainacan_Logs extends Tainacan_Repository {
|
|||
$return = [];
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$return[] = new Tainacan_Log($post);
|
||||
$return[] = new \Tainacan\Entities\Log($post);
|
||||
}
|
||||
|
||||
// TODO: Pegar coleções registradas via código
|
||||
|
@ -143,7 +145,7 @@ class Tainacan_Logs extends Tainacan_Repository {
|
|||
}
|
||||
|
||||
function get_log_by_id($id) {
|
||||
return new Tainacan_Log($id);
|
||||
return new \Tainacan\Entities\Log($id);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Tainacan_Metadatas
|
||||
* Class Metadatas
|
||||
*/
|
||||
class Tainacan_Metadatas {
|
||||
class Metadatas {
|
||||
|
||||
const POST_TYPE = 'tainacan-metadata';
|
||||
|
||||
|
@ -121,10 +124,10 @@ class Tainacan_Metadatas {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Tainacan_Metadata $metadata
|
||||
* @param \Tainacan\Entities\Metadata $metadata
|
||||
* @return int
|
||||
*/
|
||||
function insert( Tainacan_Metadata $metadata ) {
|
||||
function insert( \Tainacan\Entities\Metadata $metadata ) {
|
||||
// First iterate through the native post properties
|
||||
$map = $this->get_map();
|
||||
foreach ($map as $prop => $mapped) {
|
||||
|
@ -158,7 +161,7 @@ class Tainacan_Metadatas {
|
|||
}
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Metadata($metadata->WP_Post);
|
||||
return new \Tainacan\Entities\Metadata($metadata->WP_Post);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +188,7 @@ class Tainacan_Metadatas {
|
|||
$return = [];
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$return[] = new Tainacan_Metadata($post);
|
||||
$return[] = new \Tainacan\Entities\Metadata($post);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -193,9 +196,9 @@ class Tainacan_Metadatas {
|
|||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Tainacan_Metadata
|
||||
* @return \Tainacan\Entities\Metadata
|
||||
*/
|
||||
function get_metadata_by_id($id) {
|
||||
return new Tainacan_Metadata($id);
|
||||
return new \Tainacan\Entities\Metadata($id);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Class Tainacan_Taxonomies
|
||||
*/
|
||||
class Tainacan_Taxonomies {
|
||||
class Taxonomies {
|
||||
|
||||
const POST_TYPE = 'tainacan-taxonomies';
|
||||
|
||||
|
@ -96,7 +99,7 @@ class Tainacan_Taxonomies {
|
|||
$return = [];
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$return[] = new Tainacan_Taxonomy($post);
|
||||
$return[] = new \Tainacan\Entities\Taxonomy($post);
|
||||
}
|
||||
|
||||
// TODO: Pegar taxonomias registradas via código
|
||||
|
@ -105,10 +108,10 @@ class Tainacan_Taxonomies {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Tainacan_Taxonomy $metadata
|
||||
* @param \Tainacan\Entities\Taxonomy $metadata
|
||||
* @return int
|
||||
*/
|
||||
function insert( Tainacan_Taxonomy $taxonomy ) {
|
||||
function insert( \Tainacan\Entities\Taxonomy $taxonomy ) {
|
||||
// First iterate through the native post properties
|
||||
$map = $this->get_map();
|
||||
foreach ($map as $prop => $mapped) {
|
||||
|
@ -144,7 +147,7 @@ class Tainacan_Taxonomies {
|
|||
$taxonomy->register_taxonomy();
|
||||
|
||||
// return a brand new object
|
||||
return new Tainacan_Taxonomy($taxonomy->WP_Post);
|
||||
return new\Tainacan\Entities\Taxonomy($taxonomy->WP_Post);
|
||||
}
|
||||
|
||||
function registerTainacanTaxonomy( $taxonomy_name ){
|
||||
|
@ -173,6 +176,6 @@ class Tainacan_Taxonomies {
|
|||
}
|
||||
|
||||
function get_taxonomy_by_id($id) {
|
||||
return new Tainacan_Taxonomy($id);
|
||||
return new \Tainacan\Entities\Taxonomy($id);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Repositories;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -6,7 +9,7 @@ exit;
|
|||
/**
|
||||
* Class Tainacan_Terms
|
||||
*/
|
||||
class Tainacan_Terms {
|
||||
class Terms {
|
||||
|
||||
function get_map() {
|
||||
return [
|
||||
|
@ -37,7 +40,7 @@ class Tainacan_Terms {
|
|||
];
|
||||
}
|
||||
|
||||
function insert( Tainacan_Term $term ){
|
||||
function insert( \Tainacan\Entities\Term $term ){
|
||||
// First iterate through the native post properties
|
||||
$map = $this->get_map();
|
||||
foreach ($map as $prop => $mapped) {
|
||||
|
@ -69,7 +72,7 @@ class Tainacan_Terms {
|
|||
function get_term_by($field,$value,$taxonomy){
|
||||
$wp_term = get_term_by($field,$value,$taxonomy);
|
||||
|
||||
$tainacan_term = new Tainacan_Term( $wp_term );
|
||||
$tainacan_term = new \Tainacan\Entities\Term( $wp_term );
|
||||
$tainacan_term->set_user( get_term_meta($tainacan_term->get_id() , 'user', true ) );
|
||||
|
||||
return $tainacan_term;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Traits;
|
||||
|
||||
// used by Item, Event, Field
|
||||
|
||||
trait Tainacan_Entity_Collection_Relation {
|
||||
trait Entity_Collection_Relation {
|
||||
|
||||
function get_collection_id() {
|
||||
return $this->get_mapped_property('collection_id');
|
||||
}
|
||||
|
||||
function get_collection() {
|
||||
if (isset($this->collection) && $this->collection instanceof Tainacan_Collection)
|
||||
if (isset($this->collection) && $this->collection instanceof \Tainacan\Entities\Collection)
|
||||
return $this->collection;
|
||||
|
||||
if (is_numeric($this->get_collection_id())) {
|
||||
|
@ -27,7 +29,7 @@ trait Tainacan_Entity_Collection_Relation {
|
|||
return $this->set_mapped_property('collection_id', $value);
|
||||
}
|
||||
|
||||
function set_collection(Tainacan_Collection $collection) {
|
||||
function set_collection(\Tainacan\Entities\Collection $collection) {
|
||||
$this->collection = $collection;
|
||||
$this->set_collection_id($collection->get_id());
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Traits;
|
||||
|
||||
// used by Taxonomy
|
||||
|
||||
trait Tainacan_Entity_Collections_Relation {
|
||||
trait Entity_Collections_Relation {
|
||||
|
||||
function get_collections_ids() {
|
||||
return $this->get_mapped_property('collections_ids');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
|
@ -8,14 +11,14 @@
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_Collections extends WP_UnitTestCase {
|
||||
class Collections extends \WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* A single example test.
|
||||
*/
|
||||
function test_add() {
|
||||
|
||||
$x = new Tainacan_Collection();
|
||||
$x = new \Tainacan\Entities\Collection();
|
||||
|
||||
$x->set_name('teste');
|
||||
$x->set_description('adasdasdsa');
|
||||
|
@ -39,7 +42,7 @@ class Test_Collections extends WP_UnitTestCase {
|
|||
function test_item() {
|
||||
|
||||
|
||||
$x = new Tainacan_Collection();
|
||||
$x = new \Tainacan\Entities\Collection();
|
||||
|
||||
$x->set_name('teste');
|
||||
$x->set_description('adasdasdsa');
|
||||
|
@ -52,7 +55,7 @@ class Test_Collections extends WP_UnitTestCase {
|
|||
|
||||
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
|
||||
$i->set_title('item teste');
|
||||
$i->set_description('adasdasdsa');
|
||||
|
@ -71,7 +74,7 @@ class Test_Collections extends WP_UnitTestCase {
|
|||
|
||||
function test_validation() {
|
||||
|
||||
$x = new Tainacan_Collection();
|
||||
$x = new \Tainacan\Entities\Collection();
|
||||
|
||||
$x->set_name('teste');
|
||||
$x->set_description('adasdasdsa');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
|
@ -8,14 +11,14 @@
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_Filters extends WP_UnitTestCase {
|
||||
class Filters extends \WP_UnitTestCase {
|
||||
|
||||
|
||||
function teste_add(){
|
||||
global $Tainacan_Collections, $Tainacan_Filters;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$filter = new Tainacan_Filter();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$filter = new \Tainacan\Entities\Filter();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
@ -36,12 +39,12 @@ class Test_Filters extends WP_UnitTestCase {
|
|||
function test_add_with_metadata_and_type(){
|
||||
global $Tainacan_Collections, $Tainacan_Filters,$Tainacan_Metadatas;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$filter = new Tainacan_Filter();
|
||||
$type = new Tainacan_Text_Field_Type();
|
||||
$filter_list_type = new Tainacan_List_Filter_Type();
|
||||
$filter_range_type = new Tainacan_Range_Filter_Type();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
$filter = new \Tainacan\Entities\Filter();
|
||||
$type = new \Tainacan\Field_Types\Text_Field_Type();
|
||||
$filter_list_type = new \Tainacan\Filter_Types\List_Filter_Type();
|
||||
$filter_range_type = new \Tainacan\Filter_Types\Range_Filter_Type();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
|
@ -8,7 +11,7 @@
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_Item_Metadata extends WP_UnitTestCase {
|
||||
class Item_Metadata extends \WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Teste da insercao de um metadado simples sem o tipo
|
||||
|
@ -17,8 +20,8 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
global $Tainacan_Collections, $Tainacan_Metadatas, $Tainacan_Item_Metadata;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
@ -33,7 +36,7 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
$test = $Tainacan_Metadatas->get_metadata_by_id($metadata->get_id());
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
|
||||
$i->set_title('item teste');
|
||||
$i->set_description('adasdasdsa');
|
||||
|
@ -44,7 +47,7 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
$item = $Tainacan_Items->get_item_by_id($item->get_id());
|
||||
|
||||
$item_metadata = new Tainacan_Item_Metadata_Entity($item, $metadata);
|
||||
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $metadata);
|
||||
|
||||
$item_metadata->set_value('teste_value');
|
||||
|
||||
|
@ -62,8 +65,8 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
function teste_required(){
|
||||
global $Tainacan_Collections, $Tainacan_Metadatas, $Tainacan_Item_Metadata;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
@ -79,7 +82,7 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
$test = $Tainacan_Metadatas->get_metadata_by_id($metadata->get_id());
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
|
||||
$i->set_title('item teste');
|
||||
$i->set_description('adasdasdsa');
|
||||
|
@ -90,7 +93,7 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
$item = $Tainacan_Items->get_item_by_id($item->get_id());
|
||||
|
||||
$item_metadata = new Tainacan_Item_Metadata_Entity($item, $metadata);
|
||||
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $metadata);
|
||||
|
||||
// false because its required
|
||||
$this->assertFalse($item_metadata->validate());
|
||||
|
@ -107,8 +110,8 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
function teste_collection_key(){
|
||||
global $Tainacan_Collections, $Tainacan_Metadatas, $Tainacan_Item_Metadata;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
@ -124,7 +127,7 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
$test = $Tainacan_Metadatas->get_metadata_by_id($metadata->get_id());
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
|
||||
$i->set_title('item teste');
|
||||
$i->set_description('adasdasdsa');
|
||||
|
@ -139,12 +142,12 @@ class Test_Item_Metadata extends WP_UnitTestCase {
|
|||
|
||||
$value = 'teste_val';
|
||||
|
||||
$item_metadata = new Tainacan_Item_Metadata_Entity($item, $metadata);
|
||||
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $metadata);
|
||||
$item_metadata->set_value($value);
|
||||
$this->assertTrue($item_metadata->validate());
|
||||
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
|
||||
|
||||
$n_item_metadata = new Tainacan_Item_Metadata_Entity($item, $metadata);
|
||||
$n_item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $metadata);
|
||||
$n_item_metadata->set_value($value);
|
||||
$this->assertFalse($n_item_metadata->validate());
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
|
@ -8,23 +11,23 @@
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_Items extends WP_UnitTestCase {
|
||||
class Items extends \WP_UnitTestCase {
|
||||
|
||||
|
||||
function teste_query(){
|
||||
global $Tainacan_Collections, $Tainacan_Metadatas, $Tainacan_Item_Metadata;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$collection2 = new Tainacan_Collection();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$collection2 = new \Tainacan\Entities\Collection();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
$collection2->set_name('teste2');
|
||||
$collection2 = $Tainacan_Collections->insert($collection2);
|
||||
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$metadata2 = new Tainacan_Metadata();
|
||||
$metadata3 = new Tainacan_Metadata();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
$metadata2 = new \Tainacan\Entities\Metadata();
|
||||
$metadata3 = new \Tainacan\Entities\Metadata();
|
||||
|
||||
$metadata->set_name('metadado');
|
||||
$metadata->set_collection( $collection );
|
||||
|
@ -37,7 +40,7 @@ class Test_Items extends WP_UnitTestCase {
|
|||
$metadata3 = $Tainacan_Metadatas->insert($metadata3);
|
||||
|
||||
global $Tainacan_Items;
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
$i->set_title('orange');
|
||||
$i->set_collection($collection);
|
||||
$i->add_metadata($metadata, 'value_1');
|
||||
|
@ -47,17 +50,17 @@ class Test_Items extends WP_UnitTestCase {
|
|||
$meta_test = $item->get_metadata();
|
||||
|
||||
$this->assertTrue( isset($meta_test[$metadata->get_id()]) );
|
||||
$this->assertTrue( $meta_test[$metadata->get_id()] instanceof Tainacan_Item_Metadata_Entity );
|
||||
$this->assertTrue( $meta_test[$metadata->get_id()] instanceof \Tainacan\Entities\Item_Metadata_Entity );
|
||||
$this->assertEquals( $meta_test[$metadata->get_id()]->get_value(), 'value_1');
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
$i->set_title('apple');
|
||||
$i->set_collection($collection2);
|
||||
$i->add_metadata($metadata2, 'value_2');
|
||||
$i->add_metadata($metadata3, 'value_2');
|
||||
$item = $Tainacan_Items->insert($i);
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
$i->set_title('lemon');
|
||||
$i->set_collection($collection2);
|
||||
$i->add_metadata($metadata2, 'value_2');
|
||||
|
@ -65,7 +68,7 @@ class Test_Items extends WP_UnitTestCase {
|
|||
$i->add_metadata($metadata3, 'value_3');
|
||||
$item = $Tainacan_Items->insert($i);
|
||||
|
||||
$i = new Tainacan_Item();
|
||||
$i = new \Tainacan\Entities\Item();
|
||||
$i->set_title('pinapple');
|
||||
$i->set_collection($collection2);
|
||||
$i->add_metadata($metadata2, 'value_3');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
|
@ -8,7 +11,7 @@
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_Logs extends WP_UnitTestCase {
|
||||
class Logs extends \WP_UnitTestCase {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -17,7 +20,7 @@ class Test_Logs extends WP_UnitTestCase {
|
|||
function test_add() {
|
||||
global $Tainacan_Logs;
|
||||
|
||||
$log = new Tainacan_Log();
|
||||
$log = new \Tainacan\Entities\Log();
|
||||
|
||||
//setando os valores na classe do tainacan
|
||||
$log->set_title('blame someone');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
|
@ -8,7 +11,7 @@
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_Metadata extends WP_UnitTestCase {
|
||||
class Metadata extends \WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Teste da insercao de um metadado simples sem o tipo
|
||||
|
@ -16,8 +19,8 @@ class Test_Metadata extends WP_UnitTestCase {
|
|||
function test_add() {
|
||||
global $Tainacan_Collections, $Tainacan_Metadatas;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
@ -44,9 +47,9 @@ class Test_Metadata extends WP_UnitTestCase {
|
|||
function teste_add_type(){
|
||||
global $Tainacan_Collections, $Tainacan_Metadatas;
|
||||
|
||||
$collection = new Tainacan_Collection();
|
||||
$metadata = new Tainacan_Metadata();
|
||||
$type = new Tainacan_Text_Field_Type();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$metadata = new \Tainacan\Entities\Metadata();
|
||||
$type = new \Tainacan\Field_Types\Text_Field_Type();
|
||||
|
||||
$collection->set_name('teste');
|
||||
$collection = $Tainacan_Collections->insert($collection);
|
||||
|
|
|
@ -17,7 +17,7 @@ class Test_Taxonomies extends WP_UnitTestCase {
|
|||
function test_add() {
|
||||
global $Tainacan_Taxonomies;
|
||||
|
||||
$taxonomy = new Tainacan_Taxonomy();
|
||||
$taxonomy = new \Tainacan\Entities\Taxonomy();
|
||||
|
||||
//setando os valores na classe do tainacan
|
||||
$taxonomy->set_name('genero');
|
||||
|
@ -38,8 +38,8 @@ class Test_Taxonomies extends WP_UnitTestCase {
|
|||
|
||||
function test_add_term_taxonomy(){
|
||||
global $Tainacan_Taxonomies, $Tainacan_Terms;
|
||||
$taxonomy = new Tainacan_Taxonomy();
|
||||
$term = new Tainacan_Term();
|
||||
$taxonomy = new \Tainacan\Entities\Taxonomy();
|
||||
$term = new \Tainacan\Entities\Term();
|
||||
|
||||
//setando os valores na classe de taxonomia
|
||||
$taxonomy->set_name('genero');
|
||||
|
|
Loading…
Reference in New Issue