Tainacan API and two Endpoints: collections and collections/id
This commit is contained in:
parent
6e619d7431
commit
4f195b396b
|
@ -1,2 +1,2 @@
|
|||
# the destination folder, inside the plugins folder of some WordPress installation
|
||||
destination=~/devel/wordpress/wp-content/plugins/test-tainacan
|
||||
destination=~/devel/wordpress/wp-content/plugins/tainacan
|
5
build.sh
5
build.sh
|
@ -2,14 +2,13 @@
|
|||
|
||||
#source build-config.cfg
|
||||
source build-config.cfg
|
||||
#destination=~/devel/wordpress/wp-content/plugins/test-tainacan
|
||||
#destination=~/devel/wordpress/wp-content/plugins/tainacan
|
||||
|
||||
sh compile-sass.sh
|
||||
composer install
|
||||
|
||||
echo "Atualizando arquivos em $destination"
|
||||
rm -r $destination
|
||||
rm -rf $destination
|
||||
mkdir $destination
|
||||
cp -R src/ $destination/
|
||||
cp -R vendor/ $destination/
|
||||
rm -rf $destination/scss
|
||||
|
|
|
@ -5,5 +5,8 @@
|
|||
"require": {
|
||||
"respect/validation": "^1.1"
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
"minimum-stability": "dev",
|
||||
"config": {
|
||||
"vendor-dir": "src/vendor"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "e0eb272f68b3132a64ef299d34cf9700",
|
||||
"packages": [
|
||||
{
|
||||
"name": "respect/validation",
|
||||
"version": "1.1.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Respect/Validation.git",
|
||||
"reference": "22f1f14430155c21c1d6ba271a652f28c5057851"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Respect/Validation/zipball/22f1f14430155c21c1d6ba271a652f28c5057851",
|
||||
"reference": "22f1f14430155c21c1d6ba271a652f28c5057851",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"symfony/polyfill-mbstring": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"egulias/email-validator": "~1.2",
|
||||
"malkusch/bav": "~1.0",
|
||||
"mikey179/vfsstream": "^1.5",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"symfony/validator": "~2.6.9",
|
||||
"zendframework/zend-validator": "~2.3"
|
||||
},
|
||||
"suggest": {
|
||||
"egulias/email-validator": "Strict (RFC compliant) email validation",
|
||||
"ext-bcmath": "Arbitrary Precision Mathematics",
|
||||
"ext-mbstring": "Multibyte String Functions",
|
||||
"fabpot/php-cs-fixer": "Fix PSR2 and other coding style issues",
|
||||
"malkusch/bav": "German bank account validation",
|
||||
"symfony/validator": "Use Symfony validator through Respect\\Validation",
|
||||
"zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Respect\\Validation\\": "library/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD Style"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Respect/Validation Contributors",
|
||||
"homepage": "https://github.com/Respect/Validation/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "The most awesome validation engine ever created for PHP",
|
||||
"homepage": "http://respect.github.io/Validation/",
|
||||
"keywords": [
|
||||
"respect",
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"time": "2017-10-17T10:15:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
|
||||
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.6-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"mbstring",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2017-10-11T12:05:26+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
|
@ -31,6 +31,19 @@ class Collection extends Entity {
|
|||
}
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
return 'Hello, I\'m the Collection Entity';
|
||||
}
|
||||
|
||||
public function __toJSON(){
|
||||
return json_encode(
|
||||
[
|
||||
'name' => $this->get_name(),
|
||||
'description' => $this->get_description(),
|
||||
'items_per_page' => $this->get_itens_per_page(),
|
||||
]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Register the post type for this collection
|
||||
*
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Plugin Name: Tainacan
|
||||
Plugin URI:
|
||||
Description: Lorem Ipsum
|
||||
Author: MediaLab UFG
|
||||
Version: 10.9.8.7.6.5.4
|
||||
* Plugin Name: Tainacan
|
||||
* Plugin URI: https://github.com/tainacan/tainacan
|
||||
* Description: Transforme seu site Wordpress em um repositório digital
|
||||
* Author: Media Lab / UFG
|
||||
* Version: 1.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
@ -15,7 +16,8 @@ const FILTER_TYPES_DIR = __DIR__ . '/classes/filter-types/';
|
|||
const REPOSITORIES_DIR = __DIR__ . '/classes/repositories/';
|
||||
const TRAITS_DIR = __DIR__ . '/classes/traits/';
|
||||
const CLASSES_DIR = __DIR__ . '/classes/';
|
||||
const VENDOR_DIR = __DIR__ . '/../vendor/';
|
||||
const VENDOR_DIR = __DIR__ . '/vendor/';
|
||||
const ENDPOINTS_DIR = __DIR__ . '/api/endpoints/';
|
||||
|
||||
const DIRS = [
|
||||
CLASSES_DIR,
|
||||
|
@ -28,16 +30,16 @@ const DIRS = [
|
|||
|
||||
require_once(VENDOR_DIR . 'autoload.php');
|
||||
|
||||
spl_autoload_register('tainacan_autoload');
|
||||
spl_autoload_register('tainacan_autoload');
|
||||
|
||||
function tainacan_autoload($class_name){
|
||||
$class_path = explode('\\', $class_name);
|
||||
$class_name = end($class_path);
|
||||
|
||||
|
||||
if(count($class_path) == 1 ) {
|
||||
foreach(DIRS as $dir) {
|
||||
$file = $dir . 'class-'. strtolower(str_replace('_', '-' , $class_name)) . '.php';
|
||||
|
||||
|
||||
if(file_exists($file)) {
|
||||
require_once($file);
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ function tainacan_autoload($class_name){
|
|||
elseif ($class_path[0] == 'Tainacan') {
|
||||
$dir = strtolower(CLASSES_DIR.implode(DIRECTORY_SEPARATOR, array_slice($class_path, 1, count($class_path) -2) )).'/';
|
||||
$dir = str_replace('_', '-', $dir);
|
||||
|
||||
|
||||
$file = $dir . 'class-tainacan-'. strtolower(str_replace('_', '-' , $class_name)) . '.php';
|
||||
|
||||
if(file_exists($file)) {
|
||||
|
@ -79,6 +81,10 @@ $Tainacan_Terms = new \Tainacan\Repositories\Terms();
|
|||
global $Tainacan_Logs;
|
||||
$Tainacan_Logs = new \Tainacan\Repositories\Logs();
|
||||
|
||||
|
||||
require_once(ENDPOINTS_DIR . 'class-tainacan-rest-collections-controller.php');
|
||||
$rest_collections_controller = new TAINACAN_REST_Collections_Controller();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
|
|
@ -32,8 +32,7 @@ class Collections extends \WP_UnitTestCase {
|
|||
//
|
||||
|
||||
$test = $Tainacan_Collections->fetch($col->get_id());
|
||||
|
||||
|
||||
|
||||
$this->assertEquals($test->get_name(), 'teste');
|
||||
$this->assertEquals($test->get_description(), 'adasdasdsa');
|
||||
$this->assertEquals($test->get_itens_per_page(), 23);
|
||||
|
|
Loading…
Reference in New Issue