getIntance TO get_instance
This commit is contained in:
parent
8a9aabb823
commit
9e0f467db7
|
@ -24,7 +24,7 @@ This layer is based on a Repository pattern. Each entity Tainacan deals with hav
|
|||
Repositories are the classes that comunicate with the database and know where everything is stored and how to find things. It is a singleton class, so it have only one instance available to be used by any part of the application.
|
||||
|
||||
```PHP
|
||||
$fields_repo = Tainacan\Repositories\Fields::getInstance();
|
||||
$fields_repo = Tainacan\Repositories\Fields::get_instance();
|
||||
```
|
||||
Entities classes are the representation of the individual of each repository.
|
||||
|
||||
|
@ -46,7 +46,7 @@ Tainacan will automatically map the values of the attributes to and from where t
|
|||
When you want to fetch entities from the database, this abstraction layer steps aside and let you use all the power and flexibility of `WP_Query`, which you know and love. For example:
|
||||
|
||||
```PHP
|
||||
Repositories\Fields::getInstance()->fetch('s=test');
|
||||
Repositories\Fields::get_instance()->fetch('s=test');
|
||||
```
|
||||
|
||||
The `fetch` method from the repositories accept exactly the same arguments accepted by `WP_Query` and uses it internally. In fact, you could use `WP_Query` directly if you prefer, but using the repository class gives you some advantages. You dont have to know the name of the post type, you can also fetch by some mapped attribute calling it directly, withour having to use `meta_query` (or even know wether a property is stored as a post attribute or post_meta). See more details in the Fetch section below.
|
||||
|
@ -68,7 +68,7 @@ $collection = new Tainacan\Entities\Collection($collection_id);
|
|||
This will have the same effect as calling the `fetch` method from the repository passing an integer as argument. THe repository will assume it is the collection ID.
|
||||
|
||||
```PHP
|
||||
$collection = Tainacan\Repositories\Collections::getInstance()->fetch($collection_id);
|
||||
$collection = Tainacan\Repositories\Collections::get_instance()->fetch($collection_id);
|
||||
```
|
||||
|
||||
### Fethcing many individuals
|
||||
|
@ -80,8 +80,8 @@ To fetch collections (or any other entity) based on a query search, you may call
|
|||
Examples:
|
||||
|
||||
```PHP
|
||||
$repo = Tainacan\Repositories\Collections::getInstance();
|
||||
$items_repo = Tainacan\Repositories\Collections::getInstance();
|
||||
$repo = Tainacan\Repositories\Collections::get_instance();
|
||||
$items_repo = Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
|
||||
$collections = $repo->fetch(); // get all public collections (or any private collections current user can view. It works exactly the same way WP_Query)
|
||||
|
@ -106,7 +106,7 @@ $items = $items_repo->fetch([
|
|||
Note that you can use the mapped attribute names to build your query, but it is just fine if you want to use the native WordPress names. The same can be achievied with attributes stored as post_meta:
|
||||
|
||||
```PHP
|
||||
$repo = Tainacan\Repositories\Fields::getInstance();
|
||||
$repo = Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$fields = $repo->fetch([
|
||||
'required' => 'yes'
|
||||
|
@ -143,7 +143,7 @@ However, before insertion, you must validate the entity, calling the `validate()
|
|||
So this is a typical routine for creating an entity:
|
||||
|
||||
```PHP
|
||||
$collectionsRepo = \Tainacan\Repositories\Collections::getInstance();
|
||||
$collectionsRepo = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collection = new \Tainacan\Entities\Collection();
|
||||
$collection->set_name('New Collection');
|
||||
|
||||
|
@ -187,7 +187,7 @@ $itemMetadada = new \Tainacan\Entities\ItemMetadataEntity($item, $field);
|
|||
$itemMetadata->set_value('Red');
|
||||
|
||||
if ($itemMetadata->validate()) {
|
||||
$ItemMetadataRepo = \Tainacan\Repositories\ItemMetadata::getInstance();
|
||||
$ItemMetadataRepo = \Tainacan\Repositories\ItemMetadata::get_instance();
|
||||
$ItemMetadata = $ItemMetadataRepo->insert($ItemMetadata);
|
||||
} else {
|
||||
$errors = $ItemMetadata->get_errors();
|
||||
|
@ -313,7 +313,7 @@ $item->can_edit();
|
|||
So now you know how to check the permision when a user wants to update an item. Here is the complete code:
|
||||
|
||||
```PHP
|
||||
$collectionsRepo = \Tainacan\Repositories\Collections::getInstance();
|
||||
$collectionsRepo = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collection = new \Tainacan\Entities\Collection(23);
|
||||
|
||||
if ($collection->can_edit()) {
|
||||
|
|
|
@ -8,7 +8,7 @@ class Admin {
|
|||
private $menu_slug = 'tainacan_admin';
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance() {
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
@ -110,11 +110,11 @@ class Admin {
|
|||
function get_admin_js_localization_params() {
|
||||
global $TAINACAN_BASE_URL;
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
$tainacan_admin_i18n = require( 'tainacan-admin-i18n.php' );
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller {
|
|||
* Initialize objects after post_type register
|
||||
*/
|
||||
public function init_objects() {
|
||||
$this->collections_repository = Repositories\Collections::getInstance();
|
||||
$this->collections_repository = Repositories\Collections::get_instance();
|
||||
$this->collection = new Entities\Collection();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class TAINACAN_REST_Field_Types_Controller extends TAINACAN_REST_Controller {
|
|||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public function get_items( $request ) {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$field_types = $Tainacan_Fields->fetch_field_types('NAME');
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
* @throws Exception
|
||||
*/
|
||||
public function init_objects() {
|
||||
$this->field_repository = Repositories\Fields::getInstance();
|
||||
$this->item_metadata_repository = Repositories\Item_Metadata::getInstance();
|
||||
$this->item_repository = Repositories\Items::getInstance();
|
||||
$this->collection_repository = Repositories\Collections::getInstance();
|
||||
$this->field_repository = Repositories\Fields::get_instance();
|
||||
$this->item_metadata_repository = Repositories\Item_Metadata::get_instance();
|
||||
$this->item_repository = Repositories\Items::get_instance();
|
||||
$this->collection_repository = Repositories\Collections::get_instance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,7 @@ class TAINACAN_REST_Filter_Types_Controller extends TAINACAN_REST_Controller {
|
|||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public function get_items( $request ) {
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$filter_types = $Tainacan_Filters->fetch_filter_types('NAME');
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
|
|||
*/
|
||||
public function init_objects() {
|
||||
$this->collection = new Entities\Collection();
|
||||
$this->collection_repository = Repositories\Collections::getInstance();
|
||||
$this->collection_repository = Repositories\Collections::get_instance();
|
||||
|
||||
$this->field_repository = Repositories\Fields::getInstance();
|
||||
$this->field_repository = Repositories\Fields::get_instance();
|
||||
|
||||
$this->filter_repository = Repositories\Filters::getInstance();
|
||||
$this->filter_repository = Repositories\Filters::get_instance();
|
||||
}
|
||||
|
||||
public function register_routes() {
|
||||
|
|
|
@ -23,10 +23,10 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_REST_Controller {
|
|||
*/
|
||||
public function init_objects() {
|
||||
$this->field = new Entities\Field();
|
||||
$this->field_repository = Repositories\Fields::getInstance();
|
||||
$this->item_metadata_repository = Repositories\Item_Metadata::getInstance();
|
||||
$this->item_repository = Repositories\Items::getInstance();
|
||||
$this->collection_repository = Repositories\Collections::getInstance();
|
||||
$this->field_repository = Repositories\Fields::get_instance();
|
||||
$this->item_metadata_repository = Repositories\Item_Metadata::get_instance();
|
||||
$this->item_repository = Repositories\Items::get_instance();
|
||||
$this->collection_repository = Repositories\Collections::get_instance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,10 +30,10 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
|
|||
* Initialize objects after post_type register
|
||||
*/
|
||||
public function init_objects() {
|
||||
$this->items_repository = Repositories\Items::getInstance();
|
||||
$this->items_repository = Repositories\Items::get_instance();
|
||||
$this->item = new Entities\Item();
|
||||
$this->item_metadata = Repositories\Item_Metadata::getInstance();
|
||||
$this->collections_repository = Repositories\Collections::getInstance();
|
||||
$this->item_metadata = Repositories\Item_Metadata::get_instance();
|
||||
$this->collections_repository = Repositories\Collections::get_instance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ class TAINACAN_REST_Logs_Controller extends TAINACAN_REST_Controller {
|
|||
}
|
||||
|
||||
public function init_objects(){
|
||||
$this->logs_repository = Repositories\Logs::getInstance();
|
||||
$this->logs_repository = Repositories\Logs::get_instance();
|
||||
$this->log = new Entities\Log();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_REST_Controller {
|
|||
*/
|
||||
public function init_objects() {
|
||||
$this->taxonomy = new Entities\Taxonomy();
|
||||
$this->taxonomy_repository = Repositories\Taxonomies::getInstance();
|
||||
$this->taxonomy_repository = Repositories\Taxonomies::get_instance();
|
||||
}
|
||||
|
||||
public function register_routes() {
|
||||
|
|
|
@ -25,9 +25,9 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_REST_Controller {
|
|||
*/
|
||||
public function init_objects() {
|
||||
$this->term = new Entities\Term();
|
||||
$this->terms_repository = Repositories\Terms::getInstance();
|
||||
$this->terms_repository = Repositories\Terms::get_instance();
|
||||
$this->taxonomy = new Entities\Taxonomy();
|
||||
$this->taxonomy_repository = Repositories\Taxonomies::getInstance();
|
||||
$this->taxonomy_repository = Repositories\Taxonomies::get_instance();
|
||||
}
|
||||
|
||||
public function register_routes() {
|
||||
|
|
|
@ -272,7 +272,7 @@ class Capabilities {
|
|||
];
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
@ -392,7 +392,7 @@ class Capabilities {
|
|||
}
|
||||
}
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
foreach ($collections as $collection) {
|
||||
$this->set_items_capabilities($collection, $defaults_caps);
|
||||
|
|
|
@ -373,7 +373,7 @@ class Collection extends Entity {
|
|||
* @throws \Exception
|
||||
*/
|
||||
function get_fields() {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
return $Tainacan_Fields->fetch_by_collection( $this, [], 'OBJECT' );
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class Entity {
|
|||
public function get_repository()
|
||||
{
|
||||
$namespace = '\Tainacan\Repositories\\'.$this->repository;
|
||||
$repository = $namespace::getInstance();
|
||||
$repository = $namespace::get_instance();
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ class Item_Metadata_Entity extends Entity {
|
|||
if (isset($this->value))
|
||||
return $this->value;
|
||||
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
return $Tainacan_Item_Metadata->get_value($this);
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ class Item_Metadata_Entity extends Entity {
|
|||
}
|
||||
|
||||
if ($this->is_collection_key()) {
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$test = $Tainacan_Items->fetch([
|
||||
'meta_query' => [
|
||||
|
|
|
@ -335,7 +335,7 @@ class Item extends Entity {
|
|||
* @return array Array of ItemMetadata objects
|
||||
*/
|
||||
function get_fields() {
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
return $Tainacan_Item_Metadata->fetch( $this, 'OBJECT' );
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ class Log extends Entity {
|
|||
throw new \Exception( 'msn or new_value is need to log' );
|
||||
}
|
||||
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
|
||||
if ( $log->validate() ) {
|
||||
return $Tainacan_Logs->insert( $log );
|
||||
|
|
|
@ -69,7 +69,7 @@ class Category extends Field_Type {
|
|||
if (empty($this->get_option('taxonomy_id')))
|
||||
return ['taxonomy_id' => __('Please select a category', 'tainacan')];
|
||||
|
||||
$Tainacan_Fields = Fields::getInstance();
|
||||
$Tainacan_Fields = Fields::get_instance();
|
||||
|
||||
$category_fields = $Tainacan_Fields->fetch([
|
||||
'collection_id' => $field->get_collection_id(),
|
||||
|
|
|
@ -14,7 +14,7 @@ class Collections extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance() {
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ class Collections extends Repository {
|
|||
* @see \Tainacan\Repositories\Repository::insert()
|
||||
*/
|
||||
public function insert( $collection ) {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$this->pre_update_moderators( $collection );
|
||||
$new_collection = parent::insert( $collection );
|
||||
|
|
|
@ -22,7 +22,7 @@ class Fields extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
@ -419,7 +419,7 @@ class Fields extends Repository {
|
|||
* @see \Tainacan\Repositories\Repository::insert()
|
||||
*/
|
||||
public function insert($field){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$this->pre_update_category_field($field);
|
||||
$new_field = parent::insert($field);
|
||||
|
@ -629,7 +629,7 @@ class Fields extends Repository {
|
|||
// handle core titles
|
||||
if( strpos( $field->get_field_type(), 'Core') !== false ){
|
||||
$collection = new Entities\Collection( $collection_id );
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$items = $Tainacan_Items->fetch( [], $collection, 'OBJECT');
|
||||
$return = [];
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class Filters extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ class Item_Metadata extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ class Item_Metadata extends Repository {
|
|||
$value = $item_metadata->get_value();
|
||||
$item->$set_method( is_array( $value ) ? $value[0] : $value );
|
||||
if ($item->validate_core_fields()) {
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Items->insert($item);
|
||||
} else {
|
||||
throw new \Exception('Item metadata should be validated beforehand');
|
||||
|
@ -178,7 +178,7 @@ class Item_Metadata extends Repository {
|
|||
*/
|
||||
public function fetch($object, $output = null ){
|
||||
if($object instanceof Entities\Item){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection = $object->get_collection();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class Items extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
@ -142,8 +142,8 @@ class Items extends Repository {
|
|||
*/
|
||||
public function register_post_type() {
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
|
||||
$taxonomies = $Tainacan_Taxonomies->fetch( ['status' => ['auto-draft', 'draft', 'publish', 'private']], 'OBJECT' );
|
||||
|
@ -247,7 +247,7 @@ class Items extends Repository {
|
|||
*/
|
||||
public function fetch( $args = [], $collections = [], $output = null ) {
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
if ( is_numeric( $args ) ) {
|
||||
$existing_post = get_post( $args );
|
||||
|
|
|
@ -17,7 +17,7 @@ class Logs extends Repository {
|
|||
public $entities_type = '\Tainacan\Entities\Log';
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance() {
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ abstract class Repository {
|
|||
* @return array[]
|
||||
*/
|
||||
public static function get_collections_db_identifier() {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
|
||||
$cpts = [];
|
||||
foreach ( $collections as $col ) {
|
||||
|
@ -393,15 +393,15 @@ abstract class Repository {
|
|||
} else {
|
||||
throw new \Exception( 'Collection object not found for this post' );
|
||||
}
|
||||
} elseif ($post_type === \Tainacan\Repositories\Item_Metadata::getInstance()->entities_type::get_post_type()){
|
||||
} elseif ($post_type === \Tainacan\Repositories\Item_Metadata::get_instance()->entities_type::get_post_type()){
|
||||
return new Entities\Item_Metadata_Entity(null, null);
|
||||
} else {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
|
||||
|
||||
$tnc_globals = [
|
||||
$Tainacan_Collections,
|
||||
|
@ -435,17 +435,17 @@ abstract class Repository {
|
|||
|
||||
// its is a collection Item?
|
||||
if ( $prefix == Entities\Collection::$db_identifier_prefix ) {
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
return $Tainacan_Items;
|
||||
} else {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
|
||||
$tnc_globals = [
|
||||
$Tainacan_Collections,
|
||||
|
|
|
@ -15,7 +15,7 @@ class Taxonomies extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ class Terms extends Repository {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ class Terms extends Repository {
|
|||
*/
|
||||
public function fetch( $args = [], $taxonomies = []){
|
||||
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
if (is_numeric($taxonomies)){
|
||||
$taxonomies = $Tainacan_Taxonomies->fetch( $taxonomies );
|
||||
|
|
|
@ -74,11 +74,11 @@ function tainacan_autoload($class_name){
|
|||
}
|
||||
}
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
//register field types
|
||||
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Text');
|
||||
|
@ -90,7 +90,7 @@ $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Relationship');
|
|||
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Category');
|
||||
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Compound');
|
||||
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
//register filter type
|
||||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Custom_Interval');
|
||||
|
@ -102,12 +102,12 @@ $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategoryTaginput'
|
|||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategoryCheckbox');
|
||||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategorySelectbox');
|
||||
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
|
||||
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
|
||||
?>
|
|
@ -31,7 +31,7 @@ trait Entity_Collection_Relation {
|
|||
return $this->collection;
|
||||
|
||||
if (is_numeric($this->get_collection_id())) {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$this->collection = $Tainacan_Collections->fetch($this->get_collection_id());
|
||||
return $this->collection;
|
||||
|
|
|
@ -16,7 +16,7 @@ trait Entity_Collections_Relation {
|
|||
return $this->collections;
|
||||
|
||||
if (is_array($this->get_collections_ids()) && !empty($this->get_collections_ids())) {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$this->collections = [];
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class DevInterface {
|
|||
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
public static function get_instance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
|
@ -29,11 +29,11 @@ class DevInterface {
|
|||
|
||||
add_filter('post_type_link', array(&$this, 'permalink_filter'), 10, 3);
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
$repositories = [$Tainacan_Collections, $Tainacan_Filters, $Tainacan_Logs, $Tainacan_Fields, $Tainacan_Taxonomies];
|
||||
|
||||
|
@ -54,7 +54,7 @@ class DevInterface {
|
|||
'components' => $components
|
||||
];
|
||||
|
||||
$tainacan_settings = \Tainacan\Admin::getInstance()->get_admin_js_localization_params();
|
||||
$tainacan_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();
|
||||
|
||||
$settings = array_merge($settings, $tainacan_settings);
|
||||
|
||||
|
@ -114,7 +114,7 @@ class DevInterface {
|
|||
|
||||
}
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
|
||||
foreach ($collections as $col) {
|
||||
|
@ -133,23 +133,23 @@ class DevInterface {
|
|||
}
|
||||
|
||||
function properties_metabox_Collections() {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$this->properties_metabox($Tainacan_Collections);
|
||||
}
|
||||
function properties_metabox_Filters() {
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
$this->properties_metabox($Tainacan_Filters);
|
||||
}
|
||||
function properties_metabox_Logs() {
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
$this->properties_metabox($Tainacan_Logs);
|
||||
}
|
||||
function properties_metabox_Fields() {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$this->properties_metabox($Tainacan_Fields);
|
||||
}
|
||||
function properties_metabox_Taxonomies() {
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
$this->properties_metabox($Tainacan_Taxonomies);
|
||||
}
|
||||
|
||||
|
@ -227,8 +227,8 @@ class DevInterface {
|
|||
|
||||
function metadata_metabox() {
|
||||
global $typenow, $post;
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
|
||||
|
@ -299,8 +299,8 @@ class DevInterface {
|
|||
|
||||
function metadata_components_metabox() {
|
||||
global $typenow, $post;
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
|
||||
|
@ -372,7 +372,7 @@ class DevInterface {
|
|||
|
||||
function field_type_dropdown($id,$selected) {
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$class = ( class_exists( $selected ) ) ? new $selected() : '';
|
||||
|
||||
|
@ -399,7 +399,7 @@ class DevInterface {
|
|||
|
||||
function filter_type_dropdown($id,$selected) {
|
||||
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$class = ( class_exists( $selected ) ) ? new $selected() : '';
|
||||
|
||||
|
@ -430,7 +430,7 @@ class DevInterface {
|
|||
}
|
||||
|
||||
function collections_checkbox_list($selected) {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
$selected = json_decode($selected);
|
||||
?>
|
||||
|
@ -505,10 +505,10 @@ class DevInterface {
|
|||
// TODO: there should ve a method in the repository to find this out
|
||||
// or I could try to initialize an entity and find out what type it is
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
$cpts = [];
|
||||
|
|
|
@ -12,7 +12,7 @@ use Tainacan\Entities;
|
|||
* @param string $name_field (optional) default 'tnc_prop_collections_id'
|
||||
*/
|
||||
public static function collections_dropdown($selected, $name_field = 'tnc_prop_collection_id'){
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
?>
|
||||
<select name="<?php echo $name_field ?>">
|
||||
|
@ -30,7 +30,7 @@ use Tainacan\Entities;
|
|||
* @param string $name_field (optional) default 'tnc_prop_collections_ids[]'
|
||||
*/
|
||||
public static function collections_checkbox_list($selected,$name_field = 'tnc_prop_collections_ids[]') {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
$selected = json_decode($selected);
|
||||
?>
|
||||
|
@ -51,7 +51,7 @@ use Tainacan\Entities;
|
|||
* @param array $args (optional) filter the field list
|
||||
*/
|
||||
public static function metadata_dropdown( $collection , $selected, $name_field = 'tnc_prop_field_id', $args = []){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$collection = ( is_numeric( $collection ) ) ? new Entities\Collection( $collection ) : $collection;
|
||||
$field = $Tainacan_Fields->fetch_by_collection( $collection, $args, 'OBJECT');
|
||||
?>
|
||||
|
@ -74,7 +74,7 @@ use Tainacan\Entities;
|
|||
* @param array $args (optional) filter the field list
|
||||
*/
|
||||
public static function metadata_checkbox_list( $collection , $selected,$name_field = 'tnc_prop_tnc_field_ids[]', $args = []) {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$collection = ( is_numeric( $collection ) ) ? new Entities\Collection( $collection ) : $collection;
|
||||
$field = $Tainacan_Fields->fetch_by_collection( $collection, $args, 'OBJECT');
|
||||
$selected = ( is_array( $selected) ) ? $selected : json_decode($selected);
|
||||
|
|
|
@ -343,9 +343,9 @@ abstract class Importer {
|
|||
* @return Tainacan\Entities\Item Item inserted
|
||||
*/
|
||||
public function insert( $index, $processed_item ){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$isUpdate = ( is_array( $this->processed_items ) && isset( $this->processed_items[ $index ] ) )
|
||||
? $this->processed_items[ $index ] : 0;
|
||||
|
@ -424,8 +424,8 @@ abstract class Importer {
|
|||
$new_collection = new Entities\Collection();
|
||||
$new_collection->set_name('New Imported Collection');
|
||||
$new_collection->set_status('publish');
|
||||
$new_collection->validade();
|
||||
$new_collection = \Tainacan\Repositories\Collections::get_instance()->insert($new_collection);
|
||||
$new_collection->validate();
|
||||
$new_collection = Tainacan\Repositories\Collections::get_instance()->insert($new_collection);
|
||||
|
||||
$this->set_collection($new_collection);
|
||||
|
||||
|
|
|
@ -11,11 +11,13 @@ namespace Tainacan\Importer;
|
|||
|
||||
class Old_Tainacan extends Importer
|
||||
{
|
||||
public function __construct() {
|
||||
public function __construct($import_structure_and_mapping = false) {
|
||||
parent::__construct();
|
||||
|
||||
$this->remove_import_method('file');
|
||||
$this->add_import_method('url');
|
||||
|
||||
$this->import_structure_and_mapping = $import_structure_and_mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +28,6 @@ class Old_Tainacan extends Importer
|
|||
*/
|
||||
public function get_fields()
|
||||
{
|
||||
// TODO: Implement get_fields() method.
|
||||
$file = new \SplFileObject( $this->tmp_file, 'r' );
|
||||
$json = json_decode($file->fread($file->getSize()), true);
|
||||
|
||||
|
@ -65,10 +66,36 @@ class Old_Tainacan extends Importer
|
|||
return $processedItem;
|
||||
}
|
||||
|
||||
function create_fields_and_mapping() {
|
||||
|
||||
$file = new \SplFileObject( $this->tmp_file, 'r' );
|
||||
$json = json_decode($file->fread($file->getSize()), true);
|
||||
|
||||
print ".";
|
||||
|
||||
/*$fields_repository = \Tainacan\Repositories\Fields::get_instance();
|
||||
$newField = new \Tainacan\Entities\Field();
|
||||
$newField->set_name = 'New Field';
|
||||
$newField->set_field_type = 'Tainacan\Field_Types\Text';
|
||||
$newField->set_collection($this->collection);
|
||||
|
||||
$newField->validate(); // there is no user input here, so we can be sure it will validate.
|
||||
|
||||
$newField = $fields_repository->insert($newField);
|
||||
|
||||
$source_fields = $this->get_fields();
|
||||
|
||||
$this->set_mapping([
|
||||
$newField->get_id() => $source_fields[0]
|
||||
]);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method implemented by the child importer class to return the number of items to be imported
|
||||
* @return int
|
||||
*/
|
||||
* Method implemented by the child importer class to return the number of items to be imported
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_items_from_source()
|
||||
{
|
||||
$file = new \SplFileObject( $this->tmp_file, 'r' );
|
||||
|
|
|
@ -20,7 +20,7 @@ require_once(API_DIR . 'tainacan-rest-creator.php');
|
|||
|
||||
require_once('dev-interface/class-tainacan-dev-interface.php');
|
||||
if ( tnc_enable_dev_wp_interface() ) {
|
||||
$Tainacan_Dev_interface = \Tainacan\DevInterface\DevInterface::getInstance();
|
||||
$Tainacan_Dev_interface = \Tainacan\DevInterface\DevInterface::get_instance();
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,12 +28,12 @@ function tnc_enable_dev_wp_interface() {
|
|||
return defined('TNC_ENABLE_DEV_WP_INTERFACE') && true === TNC_ENABLE_DEV_WP_INTERFACE ? true : false;
|
||||
}
|
||||
|
||||
$Tainacan_Capabilities = \Tainacan\Capabilities::getInstance();
|
||||
$Tainacan_Capabilities = \Tainacan\Capabilities::get_instance();
|
||||
register_activation_hook( __FILE__, array( $Tainacan_Capabilities, 'init' ) );
|
||||
|
||||
// TODO move it somewhere else?
|
||||
require_once('admin/class-tainacan-admin.php');
|
||||
$Tainacan_Admin = \Tainacan\Admin::getInstance();
|
||||
$Tainacan_Admin = \Tainacan\Admin::get_instance();
|
||||
|
||||
require_once('theme-helper/class-tainacan-theme-helper.php');
|
||||
require_once('theme-helper/template-tags.php');
|
||||
|
|
|
@ -32,7 +32,7 @@ class Entity_Factory {
|
|||
public function create_entity($type, $args = [], $is_validated_and_in_db = false, $publish = false){
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
try {
|
||||
if(empty($type)){
|
||||
|
@ -55,7 +55,7 @@ class Entity_Factory {
|
|||
}
|
||||
|
||||
$this->entity = new $this->entity_type();
|
||||
$this->repository = $this->repository_type::getInstance();
|
||||
$this->repository = $this->repository_type::get_instance();
|
||||
|
||||
if($publish) {
|
||||
$this->entity->set_status('publish');
|
||||
|
|
|
@ -6,7 +6,7 @@ class Item_Metadata_Factory {
|
|||
private $item_metadata;
|
||||
|
||||
public function create_item_metadata(\Tainacan\Entities\Item $item, \Tainacan\Entities\Field $field, $value = ''){
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $field);
|
||||
|
||||
if (!empty($value))
|
||||
|
|
|
@ -15,7 +15,7 @@ class TAINACAN_REST_Field_Types_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
$data = $ftype_response->get_data();
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$field_types = $Tainacan_Fields->fetch_field_types('NAME');
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class TAINACAN_REST_Filter_Types_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
$data = $ftype_response->get_data();
|
||||
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$filter_types = $Tainacan_Filters->fetch_filter_types('NAME');
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$this->assertEquals(200, $response->get_status());
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 'pending', $data['status'] );
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
$query = $Tainacan_Logs->fetch(['post_status' => 'pending']);
|
||||
|
||||
$log = false;
|
||||
|
@ -153,7 +153,7 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$this->assertEquals(200, $response->get_status());
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 'pending', $data['status'] );
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
$query = $Tainacan_Logs->fetch(['post_status' => 'pending']);
|
||||
|
||||
$log = false;
|
||||
|
|
|
@ -143,7 +143,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
}
|
||||
|
||||
public function test_get_item_and_collection_metadata(){
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -405,7 +405,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
}
|
||||
|
||||
public function test_fetch_all_field_values(){
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -18,9 +18,9 @@ class CategoryFieldTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
function test_category_field_types() {
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -135,8 +135,8 @@ class CategoryFieldTypes extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_relate_taxonomy() {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -207,9 +207,9 @@ class CategoryFieldTypes extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_values_and_html() {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_ItemMetadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
$Tainacan_ItemMetadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -66,7 +66,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
|
||||
$collection_test->add_moderator_id($current_user_id);
|
||||
$collection_test->validate();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$collection_test = $Tainacan_Collections->insert($collection_test);
|
||||
|
||||
|
@ -146,7 +146,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$this->assertEquals('Tainacan\Entities\Collection', get_class($x));
|
||||
|
||||
|
@ -210,7 +210,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
|
||||
$this->assertEquals($x->get_slug(), $y->get_slug());
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$x->set_status('publish');
|
||||
$x->validate();
|
||||
$x = $Tainacan_Collections->insert($x);
|
||||
|
@ -233,7 +233,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collection = $Tainacan_Collections->fetch($x->get_id());
|
||||
|
||||
$i = $this->tainacan_entity_factory->create_entity(
|
||||
|
@ -247,7 +247,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$item = $Tainacan_Items->fetch( $i->get_id() );
|
||||
|
||||
$this->assertEquals($item->get_title(), 'item test');
|
||||
|
@ -281,7 +281,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_hooks() {
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$this->assertTrue(has_action('init', array($Tainacan_Collections, 'register_post_type')) !== false, 'Collections Init is not registred!');
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ class CompoundFieldTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
function test_compound_field_types() {
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -117,9 +117,9 @@ class CompoundFieldTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
function test_multiple_compound_field_types() {
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -18,8 +18,8 @@ class CoreFieldTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
function test_core_field_types() {
|
||||
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -17,7 +17,7 @@ class DefaultCapabilities extends TAINACAN_UnitTestCase {
|
|||
|
||||
function test_capabilities_present() {
|
||||
|
||||
$Tainacan_Capabilities = \Tainacan\Capabilities::getInstance();
|
||||
$Tainacan_Capabilities = \Tainacan\Capabilities::get_instance();
|
||||
$c = new \Tainacan\Entities\Collection();
|
||||
$caps = $c->get_capabilities();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
* Test insert a regular field with type
|
||||
*/
|
||||
function test_add() {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -52,7 +52,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
* Test insert a regular field with type
|
||||
*/
|
||||
function test_add_type(){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -85,7 +85,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
* test if parent field are visible for children collection
|
||||
*/
|
||||
function test_hierarchy_metadata(){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$this->tainacan_entity_factory->create_entity(
|
||||
'field',
|
||||
|
@ -170,7 +170,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
* test remove core fields
|
||||
*/
|
||||
function test_core_fields(){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection_grandfather = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -193,7 +193,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
* test if the defaults types are registered
|
||||
*/
|
||||
function test_metadata_field_type(){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$this->assertEquals( 8, sizeof( $Tainacan_Fields->fetch_field_types() ) );
|
||||
}
|
||||
|
||||
|
@ -202,8 +202,8 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
*
|
||||
*/
|
||||
function test_ordenation_fields(){
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -322,7 +322,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
|
||||
$this->assertEquals($x->get_slug(), $y->get_slug());
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$x->set_status('publish');
|
||||
$x->validate();
|
||||
$x = $Tainacan_Fields->insert($x);
|
||||
|
@ -335,7 +335,7 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_validation_of_field_types() {
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -15,7 +15,7 @@ class Filters extends TAINACAN_UnitTestCase {
|
|||
|
||||
|
||||
function teste_add(){
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -43,7 +43,7 @@ class Filters extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_add_with_metadata_and_type(){
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -96,7 +96,7 @@ class Filters extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_get_filters_type(){
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$all_filter_types = $Tainacan_Filters->fetch_filter_types();
|
||||
$this->assertEquals( 8, count( $all_filter_types ) );
|
||||
|
@ -109,7 +109,7 @@ class Filters extends TAINACAN_UnitTestCase {
|
|||
* @group filter
|
||||
*/
|
||||
function test_validate_supported_filters(){
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -27,13 +27,31 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$id = $old_tainacan_importer->get_id();
|
||||
$_SESSION['tainacan_importer'][$id]->set_collection( $collection );
|
||||
$this->assertEquals( $collection->get_id(), $_SESSION['tainacan_importer'][$id]->collection->get_id() );
|
||||
|
||||
/*$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wp-json/tainacan/v1/collections/860/items' );
|
||||
$_SESSION['tainacan_importer'][$id]->process_item(2);*/
|
||||
}
|
||||
|
||||
public function test_automapping_old_tainacan()
|
||||
{
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$old_tainacan = new Importer\Old_Tainacan(true);
|
||||
$id = $old_tainacan->get_id();
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->set_items_per_step(2);
|
||||
|
||||
if(!copy('./tests/attachment/json_old_tainacan_base.txt', './tests/attachment/json_old_tainacan.txt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->set_file( './tests/attachment/json_old_tainacan.txt' );
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->run();
|
||||
}
|
||||
|
||||
public function test_file_old_tainacan () {
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$old_tainacan = new Importer\Old_Tainacan();
|
||||
$id = $old_tainacan->get_id();
|
||||
|
@ -100,7 +118,6 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$items = $Tainacan_Items->fetch( [], $collection, 'OBJECT' );
|
||||
|
||||
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_total_items(), count( $items ) );
|
||||
|
||||
}
|
||||
/**
|
||||
* @group importer
|
||||
|
@ -130,8 +147,8 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
* @group importer
|
||||
*/
|
||||
public function test_file_csv () {
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
|
||||
$csv_importer = new Importer\CSV();
|
||||
$id = $csv_importer->get_id();
|
||||
|
|
|
@ -18,8 +18,8 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
*/
|
||||
function test_add() {
|
||||
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -53,7 +53,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$item = $Tainacan_Items->fetch($i->get_id());
|
||||
|
||||
|
@ -71,8 +71,8 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
* Teste da insercao de um metadado simples com o tipo
|
||||
*/
|
||||
function teste_required(){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -107,7 +107,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$item = $Tainacan_Items->fetch($i->get_id());
|
||||
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $test);
|
||||
|
@ -125,8 +125,8 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function teste_collection_key(){
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
@ -162,7 +162,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$item = $Tainacan_Items->fetch($i->get_id());
|
||||
|
||||
|
@ -183,7 +183,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function teste_fetch(){
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
|
|
|
@ -125,7 +125,7 @@ class Items extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$i = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
|
|
|
@ -17,6 +17,11 @@ use Tainacan\Entities\Log;
|
|||
class Logs extends TAINACAN_UnitTestCase {
|
||||
|
||||
|
||||
/**
|
||||
* Teste da insercao de um log simples apenas se criar o dado bruto
|
||||
*/
|
||||
function test_add() {
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
/**
|
||||
* Teste da insercao de um log simples apenas se criar o dado bruto
|
||||
*/
|
||||
|
@ -24,21 +29,64 @@ class Logs extends TAINACAN_UnitTestCase {
|
|||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
|
||||
$log = $this->tainacan_entity_factory->create_entity(
|
||||
'log',
|
||||
array(
|
||||
'title' => 'blame someone',
|
||||
'description' => 'someone did that'
|
||||
),
|
||||
true
|
||||
);
|
||||
$log = $this->tainacan_entity_factory->create_entity(
|
||||
'log',
|
||||
array(
|
||||
'title' => 'blame someone',
|
||||
'description' => 'someone did that'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$blog_id = get_current_blog_id();
|
||||
$user_id = get_current_user_id();
|
||||
$blog_id = get_current_blog_id();
|
||||
|
||||
//retorna a taxonomia
|
||||
$test = $Tainacan_Logs->fetch( $log->get_id() );
|
||||
//retorna a taxonomia
|
||||
$test = $Tainacan_Logs->fetch($log->get_id());
|
||||
|
||||
$this->assertEquals( 'blame someone', $test->get_title() );
|
||||
$this->assertEquals( 'someone did that', $test->get_description() );
|
||||
$this->assertEquals( $user_id, $test->get_user_id() );
|
||||
$this->assertEquals( $blog_id, $test->get_blog_id() );
|
||||
|
||||
$value = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'testeLogs',
|
||||
'description' => 'adasdasdsa123',
|
||||
'default_order' => 'DESC'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$value->set_name('new_testeLogs');
|
||||
$value->validate();
|
||||
$new_value = $Tainacan_Collections->insert($value);
|
||||
|
||||
$create_log = Log::create('teste create', 'testing a log creation function', $new_value, $value);
|
||||
|
||||
$this->assertEquals( 'teste create', $create_log->get_title() );
|
||||
$this->assertEquals( 'testing a log creation function', $create_log->get_description() );
|
||||
$this->assertEquals( $new_value, $create_log->get_value() );
|
||||
$this->assertEquals( $value, $create_log->get_old_value() );
|
||||
|
||||
$testDB = $Tainacan_Logs->fetch($create_log->get_id());
|
||||
|
||||
$this->assertEquals( 'teste create', $testDB->get_title() );
|
||||
$this->assertEquals( 'testing a log creation function', $testDB->get_description() );
|
||||
$this->assertEquals( $new_value, $testDB->get_value() );
|
||||
$this->assertEquals( $value, $testDB->get_old_value() );
|
||||
|
||||
$last_log = $Tainacan_Logs->fetch_last();
|
||||
$this->assertTrue(is_object($last_log));
|
||||
$collection = $last_log->get_value();
|
||||
|
||||
$this->assertEquals($collection->get_name(), 'new_testeLogs');
|
||||
$this->assertEquals($collection->get_description(), 'adasdasdsa123');
|
||||
$this->assertEquals($collection->get_default_order(), 'DESC');
|
||||
}
|
||||
$this->assertEquals( 'blame someone', $test->get_title() );
|
||||
$this->assertEquals( 'someone did that', $test->get_description() );
|
||||
$this->assertEquals( $user_id, $test->get_user_id() );
|
||||
|
@ -83,29 +131,31 @@ class Logs extends TAINACAN_UnitTestCase {
|
|||
$this->assertEquals( 'DESC', $collection->get_default_order() );
|
||||
}
|
||||
|
||||
public function test_log_diff(){
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
public function test_log_diff() {
|
||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
|
||||
|
||||
$filter = $this->tainacan_entity_factory->create_entity(
|
||||
'filter',
|
||||
array(
|
||||
'name' => 'No name',
|
||||
),
|
||||
true
|
||||
);
|
||||
$filter = $this->tainacan_entity_factory->create_entity(
|
||||
'filter',
|
||||
array(
|
||||
'name' => 'No name'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
// Modify filter name
|
||||
$filter->set_name( 'With name' );
|
||||
// Modify filter name
|
||||
$filter->set_name('With name');
|
||||
|
||||
$Tainacan_Filters->update( $filter );
|
||||
$Tainacan_Filters->update($filter);
|
||||
|
||||
$log = $Tainacan_Logs->fetch_last();
|
||||
$log = $Tainacan_Logs->fetch_last();
|
||||
|
||||
$diff = $log->diff();
|
||||
$diff = $log->diff();
|
||||
|
||||
$this->assertEquals( 'With name', "{$diff['name']['new'][0]} {$diff['name']['new'][1]}" );
|
||||
$this->assertEquals( 'No name', $diff['name']['old'] );
|
||||
$this->assertEquals( 'With', $diff['name']['diff_with_index'][0] );
|
||||
}
|
||||
$this->assertEquals('With name', $diff['name']['new']);
|
||||
$this->assertEquals('No name', $diff['name']['old']);
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@ class Objects extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$i = $this->tainacan_entity_factory->create_entity(
|
||||
'item',
|
||||
|
@ -125,7 +125,7 @@ class Objects extends TAINACAN_UnitTestCase {
|
|||
$collection->set_name('');
|
||||
$this->assertEquals('', $collection->get_name());
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$this->assertTrue($collection->validate());
|
||||
$newCol = $Tainacan_Collections->insert($collection);
|
||||
$this->assertEquals('', $newCol->get_name());
|
||||
|
|
|
@ -52,7 +52,7 @@ class PrivateObjects extends TAINACAN_UnitTestCase {
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
||||
$items = $Tainacan_Items->fetch([], $collection);
|
||||
|
||||
|
@ -135,8 +135,8 @@ class PrivateObjects extends TAINACAN_UnitTestCase {
|
|||
$new_contributor_user = $this->factory()->user->create(array( 'role' => 'contributor' ));
|
||||
wp_set_current_user($new_contributor_user);
|
||||
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
|
||||
$items = $Tainacan_Items->fetch([], $collection);
|
||||
$this->assertEquals(2, $items->found_posts, 'items of a public collections should be visible');
|
||||
|
|
|
@ -18,7 +18,7 @@ class Taxonomies extends TAINACAN_UnitTestCase {
|
|||
* Teste da insercao de uma taxonomia simples
|
||||
*/
|
||||
function test_add() {
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
$taxonomy = $this->tainacan_entity_factory->create_entity(
|
||||
'taxonomy',
|
||||
|
@ -40,8 +40,8 @@ class Taxonomies extends TAINACAN_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_add_term_taxonomy(){
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
|
||||
|
||||
$taxonomy = $this->tainacan_entity_factory->create_entity(
|
||||
'taxonomy',
|
||||
|
|
Loading…
Reference in New Issue