Upgrade to JSON-API RC3 + latest version of tobscure/json-api

Note: npm source for ember-json-api changed to a fork, but I still had
to apply a custom change to get polymorphic relationships to work (see
https://github.com/kurko/ember-json-api/pull/71#issuecomment-85257281)
This commit is contained in:
Toby Zerner 2015-03-24 15:04:24 +10:30
parent 536281e273
commit a62e04f956
36 changed files with 342 additions and 503 deletions

258
composer.lock generated
View File

@ -135,12 +135,12 @@
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
"reference": "7ffdad0a2b2c600445deb57f5f7e93092e44ca2a"
"reference": "17cfa85970c5729cb504a7dfa0d142a5d1bb3547"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/container/zipball/7ffdad0a2b2c600445deb57f5f7e93092e44ca2a",
"reference": "7ffdad0a2b2c600445deb57f5f7e93092e44ca2a",
"url": "https://api.github.com/repos/illuminate/container/zipball/17cfa85970c5729cb504a7dfa0d142a5d1bb3547",
"reference": "17cfa85970c5729cb504a7dfa0d142a5d1bb3547",
"shasum": ""
},
"require": {
@ -169,7 +169,8 @@
}
],
"description": "The Illuminate Container package.",
"time": "2015-02-11 16:00:31"
"homepage": "http://laravel.com",
"time": "2015-03-07 15:07:05"
},
{
"name": "illuminate/contracts",
@ -177,12 +178,12 @@
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
"reference": "66dbfb78c67622367b50a0f2ce3e0be52f19f6e1"
"reference": "bd6f39e211d9fecd0d7b9a4e6826c10dd3a6c769"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/66dbfb78c67622367b50a0f2ce3e0be52f19f6e1",
"reference": "66dbfb78c67622367b50a0f2ce3e0be52f19f6e1",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/bd6f39e211d9fecd0d7b9a4e6826c10dd3a6c769",
"reference": "bd6f39e211d9fecd0d7b9a4e6826c10dd3a6c769",
"shasum": ""
},
"require": {
@ -210,7 +211,8 @@
}
],
"description": "The Illuminate Contracts package.",
"time": "2015-02-04 15:23:46"
"homepage": "http://laravel.com",
"time": "2015-03-07 15:07:05"
},
{
"name": "illuminate/database",
@ -218,12 +220,12 @@
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
"reference": "c79543fe832b41ddb6b131c5c85c379facebf657"
"reference": "2915bd599829eeb5ecb92cb4a437ee3859bec568"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/c79543fe832b41ddb6b131c5c85c379facebf657",
"reference": "c79543fe832b41ddb6b131c5c85c379facebf657",
"url": "https://api.github.com/repos/illuminate/database/zipball/2915bd599829eeb5ecb92cb4a437ee3859bec568",
"reference": "2915bd599829eeb5ecb92cb4a437ee3859bec568",
"shasum": ""
},
"require": {
@ -261,13 +263,14 @@
}
],
"description": "The Illuminate Database package.",
"homepage": "http://laravel.com",
"keywords": [
"database",
"laravel",
"orm",
"sql"
],
"time": "2015-02-23 22:48:09"
"time": "2015-03-22 19:07:50"
},
{
"name": "illuminate/support",
@ -275,12 +278,12 @@
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
"reference": "3ef267a25145cc6ff0b3993c95a20cf1d934cf6b"
"reference": "f15c8ed68d344d4fd514cd4b30169cb86d14b0eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/3ef267a25145cc6ff0b3993c95a20cf1d934cf6b",
"reference": "3ef267a25145cc6ff0b3993c95a20cf1d934cf6b",
"url": "https://api.github.com/repos/illuminate/support/zipball/f15c8ed68d344d4fd514cd4b30169cb86d14b0eb",
"reference": "f15c8ed68d344d4fd514cd4b30169cb86d14b0eb",
"shasum": ""
},
"require": {
@ -318,7 +321,8 @@
}
],
"description": "The Illuminate Support package.",
"time": "2015-02-24 00:00:31"
"homepage": "http://laravel.com",
"time": "2015-03-18 00:02:27"
},
{
"name": "misd/linkify",
@ -373,16 +377,16 @@
},
{
"name": "nesbot/carbon",
"version": "1.14.0",
"version": "1.17.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "bb87460c995d97fe55b39e65f6ffb7f64b0a941e"
"reference": "a1dd1ad9abfc8b3c4d8768068e6c71d293424e86"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bb87460c995d97fe55b39e65f6ffb7f64b0a941e",
"reference": "bb87460c995d97fe55b39e65f6ffb7f64b0a941e",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/a1dd1ad9abfc8b3c4d8768068e6c71d293424e86",
"reference": "a1dd1ad9abfc8b3c4d8768068e6c71d293424e86",
"shasum": ""
},
"require": {
@ -409,13 +413,13 @@
}
],
"description": "A simple API extension for DateTime.",
"homepage": "https://github.com/briannesbitt/Carbon",
"homepage": "http://carbon.nesbot.com",
"keywords": [
"date",
"datetime",
"time"
],
"time": "2015-02-06 05:07:29"
"time": "2015-03-08 14:05:44"
},
{
"name": "tobscure/json-api",
@ -423,12 +427,12 @@
"source": {
"type": "git",
"url": "https://github.com/tobscure/json-api.git",
"reference": "b48789f0e2fba8c813cd59f2bcfed3daf698ad97"
"reference": "053b4f1fc1da9654bb6ba134da22f50a70554fea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tobscure/json-api/zipball/b48789f0e2fba8c813cd59f2bcfed3daf698ad97",
"reference": "b48789f0e2fba8c813cd59f2bcfed3daf698ad97",
"url": "https://api.github.com/repos/tobscure/json-api/zipball/053b4f1fc1da9654bb6ba134da22f50a70554fea",
"reference": "053b4f1fc1da9654bb6ba134da22f50a70554fea",
"shasum": ""
},
"require": {
@ -451,7 +455,7 @@
}
],
"description": "JSON-API responses in PHP.",
"time": "2015-02-24 10:51:39"
"time": "2015-03-24 03:52:18"
},
{
"name": "tobscure/permissible",
@ -459,12 +463,12 @@
"source": {
"type": "git",
"url": "https://github.com/tobscure/permissible.git",
"reference": "ecd716f8e9420d4c5e486c44fda7514d6c0ffbc6"
"reference": "86536bbdea2073d69dfc45e29d10bbab245977df"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tobscure/permissible/zipball/ecd716f8e9420d4c5e486c44fda7514d6c0ffbc6",
"reference": "ecd716f8e9420d4c5e486c44fda7514d6c0ffbc6",
"url": "https://api.github.com/repos/tobscure/permissible/zipball/86536bbdea2073d69dfc45e29d10bbab245977df",
"reference": "86536bbdea2073d69dfc45e29d10bbab245977df",
"shasum": ""
},
"require": {
@ -488,7 +492,7 @@
}
],
"description": "Powerful, flexible, relational permissions using Eloquent.",
"time": "2015-02-24 10:52:32"
"time": "2015-03-17 06:29:41"
}
],
"packages-dev": [
@ -498,12 +502,12 @@
"source": {
"type": "git",
"url": "https://github.com/Codeception/Codeception.git",
"reference": "142599e281b63dbe79a243b237187d078f8d86ce"
"reference": "ade835f79160658ae16eb5ce40f8761627559159"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/142599e281b63dbe79a243b237187d078f8d86ce",
"reference": "142599e281b63dbe79a243b237187d078f8d86ce",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/ade835f79160658ae16eb5ce40f8761627559159",
"reference": "ade835f79160658ae16eb5ce40f8761627559159",
"shasum": ""
},
"require": {
@ -570,7 +574,7 @@
"functional testing",
"unit testing"
],
"time": "2015-02-23 23:30:41"
"time": "2015-03-23 23:00:13"
},
{
"name": "codeception/mockery-module",
@ -815,12 +819,12 @@
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "a1da305d1c5c0175abf7bc912cb065e906de9500"
"reference": "6af9751f947d7c6b4ec857ff2b5a5538c24c2596"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a1da305d1c5c0175abf7bc912cb065e906de9500",
"reference": "a1da305d1c5c0175abf7bc912cb065e906de9500",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/6af9751f947d7c6b4ec857ff2b5a5538c24c2596",
"reference": "6af9751f947d7c6b4ec857ff2b5a5538c24c2596",
"shasum": ""
},
"require": {
@ -858,7 +862,7 @@
}
],
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
"time": "2015-02-08 23:29:08"
"time": "2015-03-23 03:26:29"
},
{
"name": "guzzlehttp/streams",
@ -911,17 +915,62 @@
"time": "2015-01-22 00:01:34"
},
{
"name": "laracasts/testdummy",
"version": "2.0.12",
"name": "hamcrest/hamcrest-php",
"version": "v1.2.1",
"source": {
"type": "git",
"url": "https://github.com/laracasts/TestDummy.git",
"reference": "a3cb5605fbdac17f0a8973ece0e41b1221ccc990"
"url": "https://github.com/hamcrest/hamcrest-php.git",
"reference": "ac50c470531243944f977b8de75be0b684a9cb51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laracasts/TestDummy/zipball/a3cb5605fbdac17f0a8973ece0e41b1221ccc990",
"reference": "a3cb5605fbdac17f0a8973ece0e41b1221ccc990",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/ac50c470531243944f977b8de75be0b684a9cb51",
"reference": "ac50c470531243944f977b8de75be0b684a9cb51",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"replace": {
"cordoval/hamcrest-php": "*",
"davedevelopment/hamcrest-php": "*",
"kodova/hamcrest-php": "*"
},
"require-dev": {
"phpunit/php-file-iterator": "1.3.3",
"satooshi/php-coveralls": "dev-master"
},
"type": "library",
"autoload": {
"classmap": [
"hamcrest"
],
"files": [
"hamcrest/Hamcrest.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"description": "This is the PHP port of Hamcrest Matchers",
"keywords": [
"test"
],
"time": "2015-01-20 19:34:09"
},
{
"name": "laracasts/testdummy",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/laracasts/TestDummy.git",
"reference": "8c5423605b2294bdcb819c5dc298d15c1158c478"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laracasts/TestDummy/zipball/8c5423605b2294bdcb819c5dc298d15c1158c478",
"reference": "8c5423605b2294bdcb819c5dc298d15c1158c478",
"shasum": ""
},
"require": {
@ -930,12 +979,14 @@
"php": ">=5.4.0"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
"illuminate/database": "~4.0|~5.0",
"phpspec/phpspec": "~2.0",
"phpunit/phpunit": "~4.7@dev"
},
"type": "library",
"autoload": {
"psr-0": {
"Laracasts\\TestDummy": "src/"
"psr-4": {
"Laracasts\\TestDummy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -955,7 +1006,7 @@
"stubs",
"testing"
],
"time": "2015-01-07 19:32:02"
"time": "2015-03-15 06:09:30"
},
{
"name": "mockery/mockery",
@ -963,20 +1014,20 @@
"source": {
"type": "git",
"url": "https://github.com/padraic/mockery.git",
"reference": "2448c5b27f40d11db1f7bcee5a1188fef8ae490a"
"reference": "5311940484f2c117d32f835637f5c71a49618d8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/padraic/mockery/zipball/2448c5b27f40d11db1f7bcee5a1188fef8ae490a",
"reference": "2448c5b27f40d11db1f7bcee5a1188fef8ae490a",
"url": "https://api.github.com/repos/padraic/mockery/zipball/5311940484f2c117d32f835637f5c71a49618d8c",
"reference": "5311940484f2c117d32f835637f5c71a49618d8c",
"shasum": ""
},
"require": {
"hamcrest/hamcrest-php": "~1.1",
"lib-pcre": ">=7.0",
"php": ">=5.3.2"
},
"require-dev": {
"hamcrest/hamcrest-php": "~1.1",
"phpunit/phpunit": "~4.0"
},
"type": "library",
@ -1020,7 +1071,7 @@
"test double",
"testing"
],
"time": "2015-02-20 22:10:40"
"time": "2015-03-21 21:37:36"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -1028,12 +1079,12 @@
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "ff902a0beb121a13a4d3c604bd6778a25aeae07a"
"reference": "d1da796ba5565789a623052eb9f2cf59d57fec60"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/ff902a0beb121a13a4d3c604bd6778a25aeae07a",
"reference": "ff902a0beb121a13a4d3c604bd6778a25aeae07a",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d1da796ba5565789a623052eb9f2cf59d57fec60",
"reference": "d1da796ba5565789a623052eb9f2cf59d57fec60",
"shasum": ""
},
"require": {
@ -1044,7 +1095,8 @@
},
"suggest": {
"dflydev/markdown": "~1.0",
"erusev/parsedown": "~1.0"
"erusev/parsedown": "~1.0",
"league/commonmark": "*"
},
"type": "library",
"extra": {
@ -1069,7 +1121,7 @@
"email": "mike.vanriel@naenius.com"
}
],
"time": "2015-02-12 12:17:11"
"time": "2015-02-27 09:28:18"
},
{
"name": "phpspec/prophecy",
@ -1077,12 +1129,12 @@
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "9ed07757cd5c46fe33d28826327d274bd142a143"
"reference": "07606749da971eda75434814a313ed0ce6790f6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/9ed07757cd5c46fe33d28826327d274bd142a143",
"reference": "9ed07757cd5c46fe33d28826327d274bd142a143",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/07606749da971eda75434814a313ed0ce6790f6a",
"reference": "07606749da971eda75434814a313ed0ce6790f6a",
"shasum": ""
},
"require": {
@ -1129,7 +1181,7 @@
"spy",
"stub"
],
"time": "2015-02-16 14:11:36"
"time": "2015-03-20 17:41:29"
},
{
"name": "phpunit/php-code-coverage",
@ -1137,12 +1189,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "34cc484af1ca149188d0d9e91412191e398e0b67"
"reference": "4676604b851bfc6fc02bf3394bf350c727bcebf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/34cc484af1ca149188d0d9e91412191e398e0b67",
"reference": "34cc484af1ca149188d0d9e91412191e398e0b67",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4676604b851bfc6fc02bf3394bf350c727bcebf4",
"reference": "4676604b851bfc6fc02bf3394bf350c727bcebf4",
"shasum": ""
},
"require": {
@ -1191,7 +1243,7 @@
"testing",
"xunit"
],
"time": "2015-01-24 10:06:35"
"time": "2015-03-19 05:49:08"
},
{
"name": "phpunit/php-file-iterator",
@ -1381,12 +1433,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "eb6ad0d4f250c34f394b77b41e5f5e5ba5dd7773"
"reference": "10f6685ca2cf5d8662b43a225ab853699821690b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/eb6ad0d4f250c34f394b77b41e5f5e5ba5dd7773",
"reference": "eb6ad0d4f250c34f394b77b41e5f5e5ba5dd7773",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/10f6685ca2cf5d8662b43a225ab853699821690b",
"reference": "10f6685ca2cf5d8662b43a225ab853699821690b",
"shasum": ""
},
"require": {
@ -1397,7 +1449,7 @@
"ext-spl": "*",
"php": ">=5.3.3",
"phpspec/prophecy": "~1.3.1",
"phpunit/php-code-coverage": "~2.0",
"phpunit/php-code-coverage": "~2.0,>=2.0.11",
"phpunit/php-file-iterator": "~1.3.2",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "~1.0.2",
@ -1445,7 +1497,7 @@
"testing",
"xunit"
],
"time": "2015-02-09 07:13:08"
"time": "2015-03-02 06:58:30"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -1453,12 +1505,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "b752b41e3fead4feee99f3a2f2972cef517abb8b"
"reference": "55484334fb4c306ed24bfc3bdb0874685c29036f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b752b41e3fead4feee99f3a2f2972cef517abb8b",
"reference": "b752b41e3fead4feee99f3a2f2972cef517abb8b",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/55484334fb4c306ed24bfc3bdb0874685c29036f",
"reference": "55484334fb4c306ed24bfc3bdb0874685c29036f",
"shasum": ""
},
"require": {
@ -1500,7 +1552,7 @@
"mock",
"xunit"
],
"time": "2015-01-18 10:44:19"
"time": "2015-03-18 09:04:51"
},
{
"name": "react/promise",
@ -1924,12 +1976,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
"reference": "481280a7258400925fd7011404c955362db9dac2"
"reference": "c1569f6b960ea1f27e343ec9775e5f9e7b9ae46a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/481280a7258400925fd7011404c955362db9dac2",
"reference": "481280a7258400925fd7011404c955362db9dac2",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/c1569f6b960ea1f27e343ec9775e5f9e7b9ae46a",
"reference": "c1569f6b960ea1f27e343ec9775e5f9e7b9ae46a",
"shasum": ""
},
"require": {
@ -1971,7 +2023,7 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "http://symfony.com",
"time": "2015-02-18 10:38:04"
"time": "2015-03-13 13:22:05"
},
{
"name": "symfony/console",
@ -1980,12 +2032,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "be6d274e452bc6e3016d7d2d725b1e59a58982bb"
"reference": "de303b307151adadef2bbeff2858ac53d813e186"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/be6d274e452bc6e3016d7d2d725b1e59a58982bb",
"reference": "be6d274e452bc6e3016d7d2d725b1e59a58982bb",
"url": "https://api.github.com/repos/symfony/Console/zipball/de303b307151adadef2bbeff2858ac53d813e186",
"reference": "de303b307151adadef2bbeff2858ac53d813e186",
"shasum": ""
},
"require": {
@ -2029,7 +2081,7 @@
],
"description": "Symfony Console Component",
"homepage": "http://symfony.com",
"time": "2015-02-21 13:05:27"
"time": "2015-03-22 16:57:18"
},
{
"name": "symfony/css-selector",
@ -2038,12 +2090,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/CssSelector.git",
"reference": "4e65f063b5a7c33baf4967e486435a9eedddedc8"
"reference": "4af0110c47b5905944c3688a73e9452077e68a26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/4e65f063b5a7c33baf4967e486435a9eedddedc8",
"reference": "4e65f063b5a7c33baf4967e486435a9eedddedc8",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/4af0110c47b5905944c3688a73e9452077e68a26",
"reference": "4af0110c47b5905944c3688a73e9452077e68a26",
"shasum": ""
},
"require": {
@ -2083,7 +2135,7 @@
],
"description": "Symfony CssSelector Component",
"homepage": "http://symfony.com",
"time": "2015-02-18 10:38:04"
"time": "2015-03-22 16:57:18"
},
{
"name": "symfony/dom-crawler",
@ -2092,12 +2144,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
"reference": "09f93424f3098ff1c95095de6d8c61032bcd8d89"
"reference": "c6f3631d4525813ac13db45dbda0493450071020"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/09f93424f3098ff1c95095de6d8c61032bcd8d89",
"reference": "09f93424f3098ff1c95095de6d8c61032bcd8d89",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/c6f3631d4525813ac13db45dbda0493450071020",
"reference": "c6f3631d4525813ac13db45dbda0493450071020",
"shasum": ""
},
"require": {
@ -2137,7 +2189,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "http://symfony.com",
"time": "2015-02-18 10:38:04"
"time": "2015-03-23 08:18:05"
},
{
"name": "symfony/event-dispatcher",
@ -2146,12 +2198,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
"reference": "ce9246f87133be616f5db06b5e162f5210f95280"
"reference": "186349c2966529804e38685f671e64746dde220b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/ce9246f87133be616f5db06b5e162f5210f95280",
"reference": "ce9246f87133be616f5db06b5e162f5210f95280",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/186349c2966529804e38685f671e64746dde220b",
"reference": "186349c2966529804e38685f671e64746dde220b",
"shasum": ""
},
"require": {
@ -2196,7 +2248,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "http://symfony.com",
"time": "2015-02-18 10:38:04"
"time": "2015-03-13 17:50:01"
},
{
"name": "symfony/finder",
@ -2205,12 +2257,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "5db34b8c6ab8c04452a5660ad9535766940b5348"
"reference": "4ceb3c184e5008f95f56a85916cb3d2226f7da38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/5db34b8c6ab8c04452a5660ad9535766940b5348",
"reference": "5db34b8c6ab8c04452a5660ad9535766940b5348",
"url": "https://api.github.com/repos/symfony/Finder/zipball/4ceb3c184e5008f95f56a85916cb3d2226f7da38",
"reference": "4ceb3c184e5008f95f56a85916cb3d2226f7da38",
"shasum": ""
},
"require": {
@ -2246,7 +2298,7 @@
],
"description": "Symfony Finder Component",
"homepage": "http://symfony.com",
"time": "2015-02-21 13:05:27"
"time": "2015-03-22 16:57:18"
},
{
"name": "symfony/yaml",
@ -2255,12 +2307,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "d04b39229628a0cc36ae5616db9c7f6f7119ac8f"
"reference": "bc2504716cb3f7704dfff5d5dcb88df43282f414"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/d04b39229628a0cc36ae5616db9c7f6f7119ac8f",
"reference": "d04b39229628a0cc36ae5616db9c7f6f7119ac8f",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/bc2504716cb3f7704dfff5d5dcb88df43282f414",
"reference": "bc2504716cb3f7704dfff5d5dcb88df43282f414",
"shasum": ""
},
"require": {
@ -2296,7 +2348,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
"time": "2015-02-18 10:38:04"
"time": "2015-03-22 16:57:18"
}
],
"aliases": [],

View File

@ -18,12 +18,8 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
// `content` property to the content of the item in the post-stream object.
// This happens to be our post model!
post: Ember.computed.alias('content'),
decodedContent: Ember.computed('post.content', function() {
return JSON.parse(this.get('post.content'));
}),
oldTitle: Ember.computed.alias('decodedContent.0'),
newTitle: Ember.computed.alias('decodedContent.1'),
oldTitle: Ember.computed.alias('post.content.0'),
newTitle: Ember.computed.alias('post.content.1'),
populateControls: function(items) {
this.addActionItem(items, 'delete', 'Delete', 'times', 'post.canDelete');

View File

@ -6,7 +6,7 @@ export default Ember.Component.extend(FadeIn, {
layoutName: 'components/user/activity-item',
tagName: 'li',
componentName: Ember.computed('activity.type', function() {
return 'user/activity-'+this.get('activity.type');
componentName: Ember.computed('activity.contentType', function() {
return 'user/activity-'+this.get('activity.contentType');
})
});

View File

@ -6,7 +6,7 @@ export default {
initialize: function(container) {
var store = container.lookup('store:main');
if (!Ember.isEmpty(FLARUM_DATA)) {
store.pushPayload(FLARUM_DATA);
store.pushPayload({included: FLARUM_DATA});
}
if (!Ember.isEmpty(FLARUM_SESSION)) {
FLARUM_SESSION.user = store.getById('user', FLARUM_SESSION.userId);

View File

@ -1,8 +1,8 @@
import DS from 'ember-data';
export default DS.Model.extend({
type: DS.attr('string'),
content: DS.attr('string'),
contentType: DS.attr('string'),
content: DS.attr(),
time: DS.attr('date'),
user: DS.belongsTo('user'),

View File

@ -47,10 +47,14 @@ export default DS.Model.extend(HasItemLists, {
// post-stream object, we're only interested in obtaining a list of IDs, so
// we make it a string and then split it by comma. Instead, we'll put a
// relationship on `loadedPosts`.
posts: DS.attr('string'),
postIds: Ember.computed('posts', function() {
var posts = this.get('posts') || '';
return posts.split(',');
// posts: DS.attr('string'),
posts: DS.hasMany('post', {async: true}),
postIds: Ember.computed(function() {
var ids = [];
this.get('data.posts').forEach(function(post) {
ids.push(post.id);
});
return ids;
}),
loadedPosts: DS.hasMany('post'),
relevantPosts: DS.hasMany('post'),

View File

@ -182,7 +182,7 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
if (post) {
item.setProperties({
content: post,
component: 'discussion/post-'+post.get('type')
component: 'discussion/post-'+post.get('contentType')
});
}
return item;

View File

@ -7,8 +7,8 @@ export default DS.Model.extend({
time: DS.attr('date'),
user: DS.belongsTo('user'),
type: DS.attr('string'),
content: DS.attr('string'),
contentType: DS.attr('string'),
content: DS.attr(),
contentHtml: DS.attr('string'),
editTime: DS.attr('date'),

View File

@ -34,7 +34,7 @@
"ember-data": "1.0.0-beta.15",
"ember-dynamic-component": "0.0.4",
"ember-export-application-global": "^1.0.2",
"ember-json-api": "^0.3.0",
"ember-json-api": "eneuhauser/ember-json-api",
"express": "^4.8.5",
"glob": "^4.0.5"
}

View File

@ -40,7 +40,7 @@ class IndexAction extends BaseAction
// Finally, we can set up the activity serializer and use it to create
// a collection of activity results.
$serializer = new ActivitySerializer(['sender', 'post', 'post.discussion', 'post.user', 'post.discussion.startUser', 'post.discussion.lastUser'], ['user']);
$document = $this->document()->setPrimaryElement($serializer->collection($activity));
$document = $this->document()->setData($serializer->collection($activity));
return $this->respondWithDocument($document);
}

View File

@ -23,7 +23,12 @@ abstract class BaseAction extends Action
public function handle(Request $request, $routeParams = [])
{
$params = array_merge($request->all(), $routeParams);
if (str_contains($request->header('CONTENT_TYPE'), 'application/vnd.api+json')) {
$input = $request->json();
} else {
$input = $request;
}
$params = array_merge($input->all(), $routeParams);
return $this->call($params);
}

View File

@ -18,8 +18,8 @@ class CreateAction extends BaseAction
// By default, the only required attributes of a discussion are the
// title and the content. We'll extract these from the rbaseequest data
// and pass them through to the StartDiscussionCommand.
$title = $params->get('discussions.title');
$content = $params->get('discussions.content');
$title = $params->get('data.title');
$content = $params->get('data.content');
$user = $this->actor->getUser();
$command = new StartDiscussionCommand($title, $content, $user, app('flarum.forum'));
@ -34,7 +34,7 @@ class CreateAction extends BaseAction
}
$serializer = new DiscussionSerializer(['posts']);
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
$document = $this->document()->setData($serializer->resource($discussion));
return $this->respondWithDocument($document);
}

View File

@ -36,16 +36,14 @@ class IndexAction extends BaseAction
{
$query = $params->get('q');
$start = $params->start();
$include = $params->included(['startPost', 'lastPost', 'relevantPosts']);
$include = $params->included(['startUser', 'lastUser', 'startPost', 'lastPost', 'relevantPosts']);
$count = $params->count(20, 50);
$sort = $params->sort(['', 'lastPost', 'replies', 'created']);
$relations = array_merge(['startUser', 'lastUser'], $include);
// Set up the discussion searcher with our search criteria, and get the
// requested range of results with the necessary relations loaded.
$criteria = new DiscussionSearchCriteria($this->actor->getUser(), $query, $sort['field'], $sort['order']);
$load = array_merge($relations, ['state']);
$load = array_merge($include, ['state']);
$results = $this->searcher->search($criteria, $count, $start, $load);
@ -61,9 +59,8 @@ class IndexAction extends BaseAction
// specified.
if ($results->areMoreResults()) {
$start += $count;
$include = implode(',', $include);
$sort = $sort['string'];
$input = array_filter(compact('query', 'sort', 'start', 'count', 'include'));
$input = array_filter(compact('query', 'sort', 'start', 'count')) + ['include' => implode(',', $include)];
$moreUrl = $this->buildUrl('discussions.index', [], $input);
} else {
$moreUrl = '';
@ -72,8 +69,8 @@ class IndexAction extends BaseAction
// Finally, we can set up the discussion serializer and use it to create
// a collection of discussion results.
$serializer = new DiscussionSerializer($relations);
$document->setPrimaryElement($serializer->collection($results->getDiscussions()));
$serializer = new DiscussionSerializer($include);
$document->setData($serializer->collection($results->getDiscussions()));
return $this->respondWithDocument($document);
}

View File

@ -49,6 +49,8 @@ class ShowAction extends BaseAction
$discussion = $this->discussions->findOrFail($params->get('id'), $this->actor->getUser());
$discussion->posts_ids = $discussion->posts()->get(['id'])->fetch('id')->all();
if (in_array('posts', $include)) {
$relations = ['user', 'user.groups', 'editUser', 'hideUser'];
$discussion->posts = $this->getPosts($params, ['discussion_id' => $discussion->id])->load($relations);
@ -63,7 +65,7 @@ class ShowAction extends BaseAction
// relations, we will specify that we want the 'posts' relation to be
// linked so that a list of post IDs will show up in the response.
$serializer = new DiscussionSerializer($include, ['posts']);
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
$document = $this->document()->setData($serializer->resource($discussion));
return $this->respondWithDocument($document);
}

View File

@ -24,10 +24,10 @@ class UpdateAction extends BaseAction
// discussion's direct properties; by default, this is just the title.
// As usual, however, we will fire an event to allow plugins to update
// additional properties.
if ($data = array_except($params->get('discussions'), ['readNumber'])) {
if ($data = array_except($params->get('data'), ['readNumber'])) {
try {
$command = new EditDiscussionCommand($discussionId, $user);
$this->hydrate($command, $params->get('discussions'));
$this->hydrate($command, $params->get('data'));
$discussion = $this->dispatch($command, $params);
} catch (PermissionDeniedException $e) {
// Temporary fix. See @todo below
@ -43,7 +43,7 @@ class UpdateAction extends BaseAction
// PermissionDeniedException is thrown by the
// EditDiscussionCommand above. So this needs to be extracted into
// its own endpoint.
if ($readNumber = $params->get('discussions.readNumber')) {
if ($readNumber = $params->get('data.readNumber')) {
$command = new ReadDiscussionCommand($discussionId, $user, $readNumber);
$this->dispatch($command, $params);
}
@ -52,7 +52,7 @@ class UpdateAction extends BaseAction
// handlers would have thrown an exception if not.) We set this
// discussion as our document's primary element.
$serializer = new DiscussionSerializer(['addedPosts', 'addedPosts.user']);
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
$document = $this->document()->setData($serializer->resource($discussion));
return $this->respondWithDocument($document);
}

View File

@ -11,7 +11,7 @@ class Index extends Base
$groups = Group::get();
$serializer = new GroupSerializer;
$this->document->setPrimaryElement($serializer->collection($groups));
$this->document->setData($serializer->collection($groups));
return $this->respondWithDocument();
}

View File

@ -22,8 +22,8 @@ class CreateAction extends BaseAction
// the post content, and the author's user account. Let's set up a
// command with this information. We also fire an event to allow plugins
// to add data to the command.
$discussionId = $params->get('posts.links.discussion');
$content = $params->get('posts.content');
$discussionId = $params->get('data.links.discussion.linkage.id');
$content = $params->get('data.content');
$command = new PostReplyCommand($discussionId, $content, $user);
$post = $this->dispatch($command, $params);
@ -40,7 +40,7 @@ class CreateAction extends BaseAction
// would have thrown an exception if not.) We set this post as our
// document's primary element.
$serializer = new PostSerializer;
$document = $this->document()->setPrimaryElement($serializer->resource($post));
$document = $this->document()->setData($serializer->resource($post));
return $this->respondWithDocument($document, 201);
}

View File

@ -60,7 +60,7 @@ class IndexAction extends BaseAction
// a post resource or collection, depending on how many posts were
// requested.
$serializer = new PostSerializer($include);
$document = $this->document()->setPrimaryElement($serializer->collection($posts->load($include)));
$document = $this->document()->setData($serializer->collection($posts->load($include)));
return $this->respondWithDocument($document);
}

View File

@ -35,7 +35,7 @@ class ShowAction extends BaseAction
// a post resource or collection, depending on how many posts were
// requested.
$serializer = new PostSerializer($relations);
$document = $this->document()->setPrimaryElement($serializer->resource($posts->first()));
$document = $this->document()->setData($serializer->resource($posts->first()));
return $this->respondWithDocument($document);
}

View File

@ -20,14 +20,14 @@ class UpdateAction extends BaseAction
// updates (i.e. if we were to run one command and then another, if the
// second one failed, the first one would still have succeeded.)
$command = new EditPostCommand($postId, $this->actor->getUser());
$this->hydrate($command, $params->get('posts'));
$this->hydrate($command, $params->get('data'));
$post = $this->dispatch($command, $params);
// Presumably, the post was updated successfully. (The command handler
// would have thrown an exception if not.) We set this post as our
// document's primary element.
$serializer = new PostSerializer;
$document = $this->document()->setPrimaryElement($serializer->resource($post));
$document = $this->document()->setData($serializer->resource($post));
return $this->respondWithDocument($document);
}

View File

@ -18,9 +18,9 @@ class CreateAction extends BaseAction
// required attributes of a user is the username, email, and password.
// Let's set up a command with this information. We also fire an event
// to allow plugins to add data to the command.
$username = $params->get('users.username');
$email = $params->get('users.email');
$password = $params->get('users.password');
$username = $params->get('data.username');
$email = $params->get('data.email');
$password = $params->get('data.password');
$command = new RegisterUserCommand($username, $email, $password, $this->actor->getUser(), app('flarum.forum'));
$user = $this->dispatch($command, $params);
@ -29,7 +29,7 @@ class CreateAction extends BaseAction
// would have thrown an exception if not.) We set this post as our
// document's primary element.
$serializer = new UserSerializer;
$document = $this->document()->setPrimaryElement($serializer->resource($user));
$document = $this->document()->setData($serializer->resource($user));
return $this->respondWithDocument($document, 201);
}

View File

@ -72,7 +72,7 @@ class IndexAction extends BaseAction
// Finally, we can set up the discussion serializer and use it to create
// a collection of discussion results.
$serializer = new UserSerializer($relations);
$document->setPrimaryElement($serializer->collection($results->getUsers()));
$document->setData($serializer->collection($results->getUsers()));
return $this->respondWithDocument($document);
}

View File

@ -37,7 +37,7 @@ class ShowAction extends BaseAction
// document's primary resource. We will specify that we want the
// 'groups' relation to be included by default.
$serializer = new UserSerializer(['groups']);
$document = $this->document()->setPrimaryElement($serializer->resource($user));
$document = $this->document()->setData($serializer->resource($user));
return $this->respondWithDocument($document);
}

View File

@ -21,14 +21,14 @@ class UpdateAction extends BaseAction
// updates (i.e. if we were to run one command and then another, if the
// second one failed, the first one would still have succeeded.)
$command = new EditUserCommand($userId, $this->actor->getUser());
$this->hydrate($command, $params->get('users'));
$this->hydrate($command, $params->get('data'));
$user = $this->dispatch($command, $params);
// Presumably, the user was updated successfully. (The command handler
// would have thrown an exception if not.) We set this user as our
// document's primary element.
$serializer = new UserSerializer;
$document = $this->document()->setPrimaryElement($serializer->resource($user));
$document = $this->document()->setData($serializer->resource($user));
return $this->respondWithDocument($document);
}

View File

@ -4,20 +4,11 @@ class SerializeRelationship
{
public $serializer;
public $model;
public $type;
public $name;
public $relations;
public function __construct($serializer, $model, $type, $name, $relations)
public function __construct($serializer, $name)
{
$this->serializer = $serializer;
$this->model = $model;
$this->type = $type;
$this->name = $name;
$this->relations = $relations;
}
}

View File

@ -1,11 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\Activity;
class ActivitySerializer extends BaseSerializer
{
/**
* The resource type.
*
* @var string
*/
protected $type = 'activity';
@ -16,50 +15,30 @@ class ActivitySerializer extends BaseSerializer
* @param Activity $activity The Activity model to serialize.
* @return array
*/
protected function attributes(Activity $activity)
protected function attributes($activity)
{
$attributes = [
'id' => ((int) $activity->id) ?: str_random(5),
'type' => $activity->type,
'contentType' => $activity->type,
'content' => json_encode($activity->data),
'time' => $activity->time->toRFC3339String()
];
return $this->attributesEvent($activity, $attributes);
return $this->extendAttributes($activity, $attributes);
}
/**
* Get a resource containing an activity's sender.
*
* @param Activity $activity
* @return Tobscure\JsonApi\Resource
*/
public function linkUser(Activity $activity)
public function user()
{
return (new UserBasicSerializer)->resource($activity->user_id);
return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer');
}
/**
* Get a resource containing an activity's sender.
*
* @param Activity $activity
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeSender(Activity $activity, $relations)
public function sender()
{
return (new UserBasicSerializer($relations))->resource($activity->sender);
return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer');
}
/**
* Get a resource containing an activity's sender.
*
* @param Activity $activity
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includePost(Activity $activity, $relations)
public function post()
{
return (new PostSerializer($relations))->resource($activity->post);
return $this->hasOne('Flarum\Api\Serializers\PostSerializer');
}
}

View File

@ -4,6 +4,7 @@ use Tobscure\JsonApi\SerializerAbstract;
use Flarum\Api\Events\SerializeAttributes;
use Flarum\Api\Events\SerializeRelationship;
use Flarum\Core\Support\Actor;
use Closure;
/**
* A base serializer to call Flarum events at common serialization points.
@ -35,13 +36,55 @@ abstract class BaseSerializer extends SerializerAbstract
* @param array $attributes Attributes that have already been serialized.
* @return array
*/
protected function attributesEvent($model, $attributes = [])
protected function extendAttributes($model, &$attributes = [])
{
event(new SerializeAttributes($this, $model, $attributes));
return $attributes;
}
protected function relationship($serializer, Closure $callback = null, $many = false)
{
// Get the relationship name from the stack trace.
if (is_null($callback)) {
list(, , $caller) = debug_backtrace(false, 3);
$relation = $caller['function'];
}
return function ($model, $include, $links) use ($serializer, $callback, $many, $relation) {
if ($callback) {
$data = $callback($model, $include);
} else {
if ($include) {
$data = $model->$relation;
} elseif ($many) {
$relationIds = $relation.'_ids';
$data = $model->$relationIds ?: $model->relation()->get(['id'])->fetch('id')->all();
} else {
$relationId = $relation.'_id';
$data = $model->$relationId;
}
}
if (is_array($serializer)) {
$class = get_class(is_object($data) ? $data : $model->$relation()->getRelated());
$serializer = $serializer[$class];
}
$serializer = new $serializer($links);
return $many ? $serializer->collection($data) : $serializer->resource($data);
};
}
public function hasOne($serializer, Closure $callback = null)
{
return $this->relationship($serializer, $callback);
}
public function hasMany($serializer, Closure $callback = null)
{
return $this->relationship($serializer, $callback, true);
}
/**
* Fire an event to allow for custom links and includes.
*
@ -51,12 +94,6 @@ abstract class BaseSerializer extends SerializerAbstract
*/
public function __call($name, $arguments)
{
if ($link = starts_with($name, 'link') || starts_with($name, 'include')) {
$model = isset($arguments[0]) ? $arguments[0] : null;
$relations = isset($arguments[1]) ? $arguments[1] : null;
$type = $link ? 'link' : 'include';
$name = substr($name, strlen($type));
return event(new SerializeRelationship($this, $model, $type, $name, $relations), null, true);
}
return event(new SerializeRelationship($this, $name), null, true);
}
}

View File

@ -1,11 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\Discussion;
class DiscussionBasicSerializer extends BaseSerializer
{
/**
* The resource type.
*
* @var string
*/
protected $type = 'discussions';
@ -16,29 +15,47 @@ class DiscussionBasicSerializer extends BaseSerializer
* @param Discussion $discussion The Discussion model to serialize.
* @return array
*/
protected function attributes(Discussion $discussion)
protected function attributes($discussion)
{
$attributes = [
'id' => (int) $discussion->id,
'title' => $discussion->title,
'title' => $discussion->title
];
return $this->attributesEvent($discussion, $attributes);
return $this->extendAttributes($discussion, $attributes);
}
/**
* Get the URL templates where this resource and its related resources can
* be accessed.
*
* @return array
*/
protected function href()
public function startUser()
{
$href = [
'discussions' => $this->action('DiscussionsController@show', ['id' => '{discussions.id}']),
'posts' => $this->action('PostsController@indexForDiscussion', ['id' => '{discussions.id}'])
];
return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer');
}
return $this->hrefEvent($href);
public function startPost()
{
return $this->hasOne('Flarum\Api\Serializers\PostBasicSerializer');
}
public function lastUser()
{
return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer');
}
public function lastPost()
{
return $this->hasOne('Flarum\Api\Serializers\PostBasicSerializer');
}
public function posts()
{
return $this->hasMany('Flarum\Api\Serializers\PostSerializer');
}
public function relevantPosts()
{
return $this->hasMany('Flarum\Api\Serializers\PostBasicSerializer');
}
public function addedPosts()
{
return $this->hasMany('Flarum\Api\Serializers\PostBasicSerializer');
}
}

View File

@ -1,12 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\Discussion;
use Flarum\Core\Models\DiscussionState;
class DiscussionSerializer extends DiscussionBasicSerializer
{
/**
* Default relations to include.
*
* @var array
*/
protected $include = ['startUser', 'lastUser'];
@ -17,7 +15,7 @@ class DiscussionSerializer extends DiscussionBasicSerializer
* @param Discussion $discussion The Discussion model to serialize.
* @return array
*/
protected function attributes(Discussion $discussion)
protected function attributes($discussion)
{
$attributes = parent::attributes($discussion);
@ -37,109 +35,6 @@ class DiscussionSerializer extends DiscussionBasicSerializer
'readNumber' => $state ? (int) $state->read_number : 0
];
$this->attributesEvent($discussion, $attributes);
return $attributes;
}
/**
* Get a collection containing a discussion's viewable post IDs.
*
* @param Discussion $discussion
* @return Tobscure\JsonApi\Collection
*/
public function linkPosts(Discussion $discussion)
{
$user = static::$actor->getUser();
return (new PostBasicSerializer)->collection($discussion->posts()->whereCan($user, 'view')->orderBy('time', 'asc')->ids());
}
/**
* Get a collection containing a discussion's viewable posts. Assumes that
* the discussion model's posts attributes has been filled.
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Collection
*/
public function includePosts(Discussion $discussion, $relations)
{
return (new PostSerializer($relations))->collection($discussion->posts);
}
/**
* Get a collection containing a discussion's relevant posts. Assumes that
* the discussion model's relevantPosts attributes has been filled (this
* happens in the DiscussionFinder.)
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Collection
*/
public function includeRelevantPosts(Discussion $discussion, $relations)
{
return (new PostBasicSerializer($relations))->collection($discussion->relevantPosts);
}
/**
* Get a resource containing a discussion's start user.
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeStartUser(Discussion $discussion, $relations)
{
return (new UserBasicSerializer($relations))->resource($discussion->startUser);
}
/**
* Get a resource containing a discussion's starting post.
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeStartPost(Discussion $discussion, $relations)
{
return (new PostBasicSerializer($relations))->resource($discussion->startPost);
}
/**
* Get a resource containing a discussion's last user.
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeLastUser(Discussion $discussion, $relations)
{
return (new UserBasicSerializer($relations))->resource($discussion->lastUser);
}
/**
* Get a resource containing a discussion's last post.
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeLastPost(Discussion $discussion, $relations)
{
return (new PostBasicSerializer($relations))->resource($discussion->lastPost);
}
/**
* Get a resource containing a discussion's list of posts that have been
* added during this request.
*
* @param Discussion $discussion
* @param array $relations
* @return Tobscure\JsonApi\Collection
*/
public function includeAddedPosts(Discussion $discussion, $relations)
{
return (new PostBasicSerializer($relations))->collection($discussion->getAddedPosts());
return $this->extendAttributes($discussion, $attributes);
}
}

View File

@ -1,17 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\Group;
class GroupSerializer extends BaseSerializer
{
/**
* The name to use for Flarum events.
* @var string
*/
protected static $eventName = 'Group';
/**
* The resource type.
*
* @var string
*/
protected $type = 'groups';
@ -22,27 +15,13 @@ class GroupSerializer extends BaseSerializer
* @param Group $group The Group model to serialize.
* @return array
*/
protected function attributes(Group $group)
protected function attributes($group)
{
$attributes = [
'id' => (int) $group->id,
'name' => $group->name
];
return $this->attributesEvent($group, $attributes);
}
/**
* Get the URL templates where this resource and its related resources can
* be accessed.
*
* @return array
*/
public function href()
{
return [
'groups' => $this->action('GroupsController@show', ['id' => '{groups.id}']),
'users' => $this->action('UsersController@indexForGroup', ['id' => '{groups.id}'])
];
return $this->extendAttributes($group, $attributes);
}
}

View File

@ -1,29 +1,24 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\Post;
class PostBasicSerializer extends BaseSerializer
{
/**
* The name to use for Flarum events.
* @var string
*/
protected static $eventName = 'PostBasic';
/**
* The resource type.
*
* @var string
*/
protected $type = 'posts';
/**
* Default relations to link.
*
* @var array
*/
protected $link = ['discussion'];
/**
* Default relations to include.
*
* @var array
*/
protected $include = ['user'];
@ -34,13 +29,13 @@ class PostBasicSerializer extends BaseSerializer
* @param Post $post The Post model to serialize.
* @return array
*/
protected function attributes(Post $post)
protected function attributes($post)
{
$attributes = [
'id' => (int) $post->id,
'number' => (int) $post->number,
'time' => $post->time->toRFC3339String(),
'type' => $post->type
'contentType' => $post->type
];
if ($post->type === 'comment') {
@ -49,42 +44,16 @@ class PostBasicSerializer extends BaseSerializer
$attributes['content'] = json_encode($post->content);
}
return $this->attributesEvent($post, $attributes);
return $this->extendAttributes($post, $attributes);
}
/**
* Get the URL templates where this resource and its related resources can
* be accessed.
*
* @return array
*/
public function href()
public function user()
{
return [
'posts' => $this->action('PostsController@show', ['id' => '{posts.id}'])
];
return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer');
}
/**
* Get a resource containing a post's user.
*
* @param Post $post
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeUser(Post $post, $relations)
public function discussion()
{
return (new UserBasicSerializer($relations))->resource($post->user);
}
/**
* Get a resource containing a post's discussion ID.
*
* @param Post $post
* @return Tobscure\JsonApi\Resource
*/
public function linkDiscussion(Post $post)
{
return (new DiscussionBasicSerializer)->resource($post->discussion_id);
return $this->hasOne('Flarum\Api\Serializers\DiscussionBasicSerializer');
}
}

View File

@ -1,18 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\Post;
use Flarum\Core\Models\User;
class PostSerializer extends PostBasicSerializer
{
/**
* Default relations to link.
* @var array
*/
protected $link = ['discussion'];
/**
* Default relations to include.
*
* @var array
*/
protected $include = ['user', 'editUser', 'hideUser'];
@ -23,7 +15,7 @@ class PostSerializer extends PostBasicSerializer
* @param Post $post The Post model to serialize.
* @return array
*/
protected function attributes(Post $post)
protected function attributes($post)
{
$attributes = parent::attributes($post);
$user = static::$actor->getUser();
@ -38,7 +30,7 @@ class PostSerializer extends PostBasicSerializer
$attributes['content'] = $post->content;
}
} else {
$attributes['content'] = json_encode($post->content);
$attributes['content'] = $post->content;
}
if ($post->edit_time) {
@ -55,54 +47,26 @@ class PostSerializer extends PostBasicSerializer
'canDelete' => $post->can($user, 'delete')
];
return $this->attributesEvent($post, $attributes);
return $this->extendAttributes($post, $attributes);
}
/**
* Get a resource containing a post's user.
*
* @param Post $post
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeUser(Post $post, $relations = [])
public function user()
{
return (new UserSerializer($relations))->resource($post->user);
return $this->hasOne('Flarum\Api\Serializers\UserSerializer');
}
/**
* Get a resource containing a post's discussion.
*
* @param Post $post
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeDiscussion(Post $post, $relations = [])
public function discussion()
{
return (new DiscussionSerializer($relations))->resource($post->discussion);
return $this->hasOne('Flarum\Api\Serializers\DiscussionSerializer');
}
/**
* Get a resource containing a post's edit user.
*
* @param Post $post
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeEditUser(Post $post, $relations = [])
public function editUser()
{
return (new UserBasicSerializer($relations))->resource($post->editUser);
return $this->hasOne('Flarum\Api\Serializers\UserSerializer');
}
/**
* Get a resource containing a post's hide user.
*
* @param Post $post
* @param array $relations
* @return Tobscure\JsonApi\Resource
*/
public function includeHideUser(Post $post, $relations = [])
public function hideUser()
{
return (new UserBasicSerializer($relations))->resource($post->hideUser);
return $this->hasOne('Flarum\Api\Serializers\UserSerializer');
}
}

View File

@ -1,17 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\User;
class UserBasicSerializer extends BaseSerializer
{
/**
* The name to use for Flarum events.
* @var string
*/
protected static $eventName = 'UserBasic';
/**
* The resource type.
*
* @var string
*/
protected $type = 'users';
@ -22,29 +15,13 @@ class UserBasicSerializer extends BaseSerializer
* @param User $user The User model to serialize.
* @return array
*/
protected function attributes(User $user)
protected function attributes($user)
{
$attributes = [
'id' => (int) $user->id,
'username' => $user->username,
'avatarUrl' => $user->avatar_url
];
return $this->attributesEvent($user, $attributes);
}
/**
* Get the URL templates where this resource and its related resources can
* be accessed.
*
* @return array
*/
protected function href()
{
$href = [
'users' => $this->action('UsersController@show', ['id' => '{users.id}'])
];
return $this->hrefEvent($href);
return $this->extendAttributes($user, $attributes);
}
}

View File

@ -1,17 +1,10 @@
<?php namespace Flarum\Api\Serializers;
use Flarum\Core\Models\User;
class UserSerializer extends UserBasicSerializer
{
/**
* The name to use for Flarum events.
* @var string
*/
protected static $eventName = 'User';
/**
* Default relations to include.
*
* @var array
*/
protected $include = ['groups'];
@ -22,7 +15,7 @@ class UserSerializer extends UserBasicSerializer
* @param User $user The User model to serialize.
* @return array
*/
protected function attributes(User $user)
protected function attributes($user)
{
$attributes = parent::attributes($user);
@ -51,21 +44,15 @@ class UserSerializer extends UserBasicSerializer
if ($user->id === $actorUser->id) {
$attributes += [
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
'unreadNotificationsCount' => $user->getUnreadNotificationsCount()
];
}
return $this->attributesEvent($user, $attributes);
return $this->extendAttributes($user, $attributes);
}
/**
* Get a collection containing a user's groups.
*
* @param User $user
* @param array $relations
* @return Tobscure\JsonApi\Collection
*/
protected function includeGroups(User $user, $relations)
protected function groups()
{
return (new GroupSerializer($relations))->collection($user->groups);
return $this->hasMany('Flarum\Api\Serializers\GroupSerializer');
}
}

View File

@ -47,7 +47,7 @@ class Discussion extends Model
*
* @var \Flarum\Core\Models\Post[]
*/
protected $addedPosts = [];
public $addedPosts = [];
/**
* The user for which the state relationship should be loaded.
@ -154,17 +154,6 @@ class Discussion extends Model
return $this;
}
/**
* Get a list of the posts that have been added to this discussion during
* this request.
*
* @return \Flarum\Core\Models\Post[]
*/
public function getAddedPosts()
{
return $this->addedPosts;
}
/**
* Specify that a post was added to this discussion during this request
* for later retrieval.

View File

@ -34,8 +34,7 @@ class IndexAction extends Action
$response = $this->callAction('Flarum\Api\Actions\Users\ShowAction', ['id' => $user->id]);
$data['users'] = [$response->getData()->users];
$data['groups'] = $response->getData()->linked->groups;
$data = array_merge([$response->getData()->data], $response->getData()->included);
}