Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
weryques 2018-04-11 16:06:21 -03:00
commit a921b7467c
76 changed files with 341 additions and 274 deletions

View File

@ -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()) {

View File

@ -45,6 +45,7 @@
margin: 0 auto;
position: relative;
overflow-y: auto;
height: 100%;
@media screen and (max-width: 769px) {
& {
@ -62,6 +63,7 @@
margin: $header-height auto 0 auto;
position: relative;
overflow-y: auto;
height: calc(100% - 58px);
@media screen and (max-width: 769px) {
& {

View File

@ -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' );

View File

@ -114,6 +114,7 @@
</p>
<p>{{ $i18n.get('info_no_collection_created') }}</p>
<router-link
id="button-create-collection"
tag="button"
class="button is-primary"
:to="{ path: $routerHelper.getNewCollectionPath() }">

View File

@ -56,7 +56,7 @@
tabindex="0"
:aria-label="$i18n.get('label_who_when') + ': ' + props.row.creation"
:label="$i18n.get('label_who_when')"
property="by"
property="by"R
show-overflow-tooltip
field="props.row.by">
<router-link

View File

@ -116,11 +116,10 @@
</draggable>
</div>
<div class="column available-fields-area">
<div
class="field"
v-if="availableFieldList.length > 0">
<div class="field" >
<h3 class="label"> {{ $i18n.get('label_available_field_types') }}</h3>
<draggable
<draggable
v-if="availableFieldList.length > 0"
:list="availableFieldList"
:options="{
sort: false,
@ -136,21 +135,25 @@
<span class="field-name">{{ field.name }}</span>
</div>
</draggable>
</div>
<div
v-else
class="field is-grouped-centered">
<h3 class="label"> {{ $i18n.get('label_available_field_types') }}</h3>
<div>
{{ $i18n.get('info_there_is_no_field' ) }}
</div>
<div class="control">
<router-link
:to="isRepositoryLevel ? $routerHelper.getNewFieldPath() : $routerHelper.getNewCollectionFieldPath(collectionId)"
tag="button"
class="button is-secondary is-centered">
{{ $i18n.getFrom('fields', 'new_item') }}</router-link>
</div>
<section
v-else
class="field is-grouped-centered section">
<div class="content has-text-gray has-text-centered">
<p>
<b-icon
icon="format-list-checks"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_there_is_no_field' ) }}</p>
<router-link
id="button-create-field"
:to="isRepositoryLevel ? $routerHelper.getNewFieldPath() : $routerHelper.getNewCollectionFieldPath(collectionId)"
tag="button"
class="button is-secondary is-centered">
{{ $i18n.getFrom('fields', 'new_item') }}</router-link>
</div>
</section>
</div>
</div>
</div>

View File

@ -23,23 +23,6 @@
</div>
<ul class="menu-list">
<li class="search-area">
<b-field>
<b-input
:placeholder="$i18n.get('search')"
type="search"
size="is-small"
icon="magnify"/>
</b-field>
<router-link
tag="a"
to="">
<b-icon
size="is-small"
icon="magnify"/> <span class="menu-text">{{ $i18n.get('advanced_search') }}</span>
</router-link>
</li>
<li class="separator"/>
<li><router-link
tag="a"
to="/collections"

View File

@ -1,10 +1,31 @@
<template>
<div>
<tainacan-filters-list
:query="getPostQuery()"
v-for="(filter, index) in filters"
:key="index"
:filter="filter"/>
<div v-if="filters.length > 0">
<tainacan-filter-item
:query="getPostQuery()"
v-for="(filter, index) in filters"
:key="index"
:filter="filter"/>
</div>
<section
v-else
class="is-grouped-centered section">
<div class="content has-text-gray has-text-centered">
<p>
<b-icon
icon="filter-outline"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_there_is_no_filter' ) }}</p>
<router-link
id="button-create-filter"
:to="isRepositoryLevel ? $routerHelper.getNewFilterPath() : $routerHelper.getNewCollectionFilterPath(collectionId)"
tag="button"
class="button is-secondary is-centered">
{{ $i18n.getFrom('filters', 'new_item') }}</router-link>
</div>
</section>
</div>
</template>
<script>

View File

@ -28,7 +28,12 @@
:placeholder="$i18n.get('label_sorting')">
<option
v-for="(field, index) in tableFields"
v-if="field.id != undefined && field.field_type_object.related_mapped_prop != 'description'"
v-if="
field.id != undefined &&
field.field_type_object.related_mapped_prop != 'description' &&
field.field_type_object.primitive_type != 'term' &&
field.field_type_object.primitive_type != 'item' &&
field.field_type_object.primitive_type != 'compound'"
:value="field"
:key="index">
{{ field.name }}

View File

@ -26,7 +26,7 @@ import FilterCategoryTaginput from '../../classes/filter-types/category/Taginput
import FilterCategorySelectbox from '../../classes/filter-types/category/Selectbox.vue';
import TaincanFormItem from '../../classes/field-types/tainacan-form-item.vue';
import TaincanFiltersList from '../../classes/filter-types/tainacan-filters-list.vue';
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
// Remaining imports
import AdminPage from '../admin.vue'
@ -63,7 +63,7 @@ Vue.component('tainacan-form-relationship', FormRelationship);
Vue.component('tainacan-form-category', FormCategory);
Vue.component('tainacan-form-selectbox', FormSelectbox);
Vue.component('tainacan-form-item', TaincanFormItem);
Vue.component('tainacan-filters-list', TaincanFiltersList);
Vue.component('tainacan-filter-item', TaincanFiltersList);
/* Filters */
Vue.component('tainacan-filter-custom-interval', FilterCustomInterval);

View File

@ -218,6 +218,9 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
getNewFieldPath() {
return '/fields';
},
getNewCollectionFilterPath(collectionId) {
return '/collections/' + collectionId + '/filters/';
},
getNewFilterPath() {
return '/filters/new';
},

View File

@ -5,11 +5,12 @@
class="sub-header"
v-if="totalCategories > 0">
<div class="header-item">
<router-link
<router-link
id="button-create-category"
tag="button"
class="button is-secondary"
:to="{ path: $routerHelper.getNewCategoryPath() }">
{{ $i18n.get('new') + ' ' + $i18n.get('category') }}
{{ $i18n.getFrom('taxonomies', 'new_item') }}
</router-link>
</div>
</div>

View File

@ -5,7 +5,7 @@
v-if="totalCollections > 0">
<div class="header-item">
<router-link
id="button-collection-creation"
id="button-create-collection"
tag="button"
class="button is-secondary"
:to="{ path: $routerHelper.getNewCollectionPath() }">

View File

@ -7,6 +7,7 @@
v-if="items.length > 0">
<div class="header-item">
<router-link
id="button-create-item"
tag="button"
class="button is-secondary"
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
@ -44,7 +45,7 @@
</p>
<p>{{ $i18n.get('info_no_item_created') }}</p>
<router-link
id="button-create"
id="button-create-item"
tag="button"
class="button is-primary"
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">

View File

@ -27,7 +27,6 @@ html {
width: 100%;
z-index: 999999;
overflow-y: auto;
height: 100%;
margin: 0px !important;
font-family: $family-sans-serif;
}
@ -62,7 +61,7 @@ html {
}
.page-container-small{
padding: $page-small-top-padding $page-small-side-padding;
height: 100%;
height: calc(100% - 78px);
overflow-y: auto;
@media screen and (max-width: 769px) {

View File

@ -186,6 +186,8 @@ return [
'info_no_events' => __( 'No events', 'tainacan' ),
'info_logs_before' => __( 'Before updating', 'tainacan' ),
'info_logs_after' => __( 'What was updated', 'tainacan' ),
'info_there_is_no_field' => __('There is no field here yet.', 'tainacan' ),
'info_there_is_no_filter' => __('There is no filter here yet.', 'tainacan' ),
// Tainacan Field Types
'tainacan-text' => __( 'Text', 'tainacan' ),

View File

@ -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();
}

View File

@ -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');

View File

@ -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();
}
/**

View File

@ -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');

View File

@ -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() {

View File

@ -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();
}
/**

View File

@ -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();
}
/**

View File

@ -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();
}

View File

@ -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() {

View File

@ -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() {

View File

@ -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);

View File

@ -87,6 +87,8 @@ class Collection extends Entity {
$cpt_labels = $repository->get_cpt_labels();
$cpt_labels['menu_name'] = $this->get_name();
$cpt_labels['name'] = $this->get_name();
$cpt_labels['singular_name'] = $this->get_name();
$cpt_slug = $this->get_db_identifier();
$capabilities = $this->get_items_capabilities();
@ -373,7 +375,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' );
}

View File

@ -128,7 +128,7 @@ class Entity {
public function get_repository()
{
$namespace = '\Tainacan\Repositories\\'.$this->repository;
$repository = $namespace::getInstance();
$repository = $namespace::get_instance();
return $repository;
}

View File

@ -396,7 +396,7 @@ class Field extends Entity {
}
}
if ( $this->get_field_type() == 'Tainacan\Field_Types\Compound' && $this->is_multiple() ) {
$Tainacan_fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_fields = \Tainacan\Repositories\Fields::get_instance();
$children = $Tainacan_fields->fetch(
[
'parent' => $this->get_id(),

View File

@ -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' => [

View File

@ -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' );
@ -448,8 +448,8 @@ class Item extends Entity {
*/
public function get_metadata_as_html($field = null, $hide_empty = true) {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$return = '';

View File

@ -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 );

View File

@ -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(),

View File

@ -19,7 +19,7 @@
import { mapActions, mapGetters } from 'vuex';
export default {
name: 'TainacanFiltersList',
name: 'TainacanFilterItem',
props: {
filter: Object,
query: Object

View File

@ -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 );

View File

@ -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)) {
self::$instance = new self();
}
@ -417,7 +417,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);
@ -628,7 +628,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 = [];

View File

@ -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))
{

View File

@ -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();

View File

@ -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 );

View File

@ -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();
}

View File

@ -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,

View File

@ -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))
{

View File

@ -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 );

View File

@ -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();
?>

View File

@ -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;

View File

@ -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 = [];

View File

@ -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 = [];

View File

@ -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);

View File

@ -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,15 +424,15 @@ 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);
if (!method_exists($this, 'create_fields_and_mapping')) {
throw new Exception('Importers with import_structure_and_mapping true must implement create_fields_and_mapping method');
}
$this->create_fields_and_mapping();
}

View File

@ -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' );

View File

@ -35,7 +35,7 @@ export const setItemsPerPage = ({ commit }, page ) => {
// Sorting queries
export const setOrderBy = ({ commit }, orderBy ) => {
// Primitive Types: string, date, item, term, compound
// Primitive Types: string, date, item, term, compound, float
if (orderBy.field_type_object.primitive_type == 'float' || orderBy.field_type_object.primitive_type == 'int') {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value_num' } );

View File

@ -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,16 +28,16 @@ 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');
$Tainacan_Admin = \Tainacan\Theme_Helper::getInstance();
$Tainacan_Admin = \Tainacan\Theme_Helper::get_instance();
function tainacan_load_plugin_textdomain() {
load_plugin_textdomain( 'tainacan', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );

View File

@ -8,7 +8,7 @@ class Theme_Helper {
private static $instance = null;
public static function getInstance() {
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}

View File

@ -19,7 +19,7 @@ use Tainacan\Entities;
*/
function get_tainacan_the_metadata($field = null, $hide_empty = true) {
$post = get_post();
$theme_helper = \Tainacan\Theme_Helper::getInstance();
$theme_helper = \Tainacan\Theme_Helper::get_instance();
if (!$theme_helper->is_post_an_item($post));
return;

View File

@ -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');

View File

@ -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))

View File

@ -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');

View File

@ -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');

View File

@ -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;

View File

@ -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',

View File

@ -194,8 +194,8 @@ class TAINACAN_REST_Terms extends TAINACAN_UnitApiTestCase {
true
);
$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();
$new_attributes = [
'hideempty' => false,

View File

@ -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',

View File

@ -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!');
}

View File

@ -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',
@ -250,7 +250,7 @@ class CompoundFieldTypes extends TAINACAN_UnitTestCase {
function test_validations_category_in_multiple() {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -288,7 +288,7 @@ class CompoundFieldTypes extends TAINACAN_UnitTestCase {
function test_validations_category_in_multiple_2() {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -328,7 +328,7 @@ class CompoundFieldTypes extends TAINACAN_UnitTestCase {
function test_validations_multiple_fields() {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',

View File

@ -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',

View File

@ -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();

View File

@ -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',

View File

@ -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',

View File

@ -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();
@ -223,7 +240,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
public function test_fetch_file(){
$csv_importer = new Importer\CSV();
$id = $csv_importer->get_id();
$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wordpress-test/wp-json' );
$this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );
//$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wordpress-test/wp-json' );
//$this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );
}
}

View File

@ -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',

View File

@ -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',

View File

@ -21,8 +21,8 @@ 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::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$log = $this->tainacan_entity_factory->create_entity(
'log',
@ -84,8 +84,8 @@ class Logs extends TAINACAN_UnitTestCase {
}
public function test_log_diff() {
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$filter = $this->tainacan_entity_factory->create_entity(
'filter',

View File

@ -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());

View File

@ -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');

View File

@ -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',
@ -83,8 +83,8 @@ class Taxonomies extends TAINACAN_UnitTestCase {
true
);
$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();
$terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy->get_id());