diff --git a/composer.lock b/composer.lock index affa75f2d..00378df5f 100644 --- a/composer.lock +++ b/composer.lock @@ -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": [], diff --git a/ember/app/components/discussion/post-renamed.js b/ember/app/components/discussion/post-renamed.js index ea8c68a68..dc71621d7 100644 --- a/ember/app/components/discussion/post-renamed.js +++ b/ember/app/components/discussion/post-renamed.js @@ -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'); diff --git a/ember/app/components/user/activity-item.js b/ember/app/components/user/activity-item.js index 01428fd58..3433c2769 100644 --- a/ember/app/components/user/activity-item.js +++ b/ember/app/components/user/activity-item.js @@ -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'); }) }); diff --git a/ember/app/initializers/preload-data.js b/ember/app/initializers/preload-data.js index 793b16609..75cd4f920 100644 --- a/ember/app/initializers/preload-data.js +++ b/ember/app/initializers/preload-data.js @@ -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); diff --git a/ember/app/models/activity.js b/ember/app/models/activity.js index bc6c9fc1b..671c85f24 100644 --- a/ember/app/models/activity.js +++ b/ember/app/models/activity.js @@ -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'), diff --git a/ember/app/models/discussion.js b/ember/app/models/discussion.js index c1c3b2f2f..c0c338192 100644 --- a/ember/app/models/discussion.js +++ b/ember/app/models/discussion.js @@ -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'), diff --git a/ember/app/models/post-stream.js b/ember/app/models/post-stream.js index fd088e0d8..32677fca0 100644 --- a/ember/app/models/post-stream.js +++ b/ember/app/models/post-stream.js @@ -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; diff --git a/ember/app/models/post.js b/ember/app/models/post.js index 09e85d536..8eb3e5a96 100644 --- a/ember/app/models/post.js +++ b/ember/app/models/post.js @@ -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'), diff --git a/ember/package.json b/ember/package.json index 4d0e9b688..ab4223a99 100644 --- a/ember/package.json +++ b/ember/package.json @@ -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" } diff --git a/src/Api/Actions/Activity/IndexAction.php b/src/Api/Actions/Activity/IndexAction.php index 7f658a7d0..5515cc491 100644 --- a/src/Api/Actions/Activity/IndexAction.php +++ b/src/Api/Actions/Activity/IndexAction.php @@ -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); } diff --git a/src/Api/Actions/BaseAction.php b/src/Api/Actions/BaseAction.php index 016925498..d9aa5077c 100644 --- a/src/Api/Actions/BaseAction.php +++ b/src/Api/Actions/BaseAction.php @@ -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); } diff --git a/src/Api/Actions/Discussions/CreateAction.php b/src/Api/Actions/Discussions/CreateAction.php index fe91ec51a..a063b1b36 100644 --- a/src/Api/Actions/Discussions/CreateAction.php +++ b/src/Api/Actions/Discussions/CreateAction.php @@ -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); } diff --git a/src/Api/Actions/Discussions/IndexAction.php b/src/Api/Actions/Discussions/IndexAction.php index 2e12cac40..3015bcbef 100644 --- a/src/Api/Actions/Discussions/IndexAction.php +++ b/src/Api/Actions/Discussions/IndexAction.php @@ -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); } diff --git a/src/Api/Actions/Discussions/ShowAction.php b/src/Api/Actions/Discussions/ShowAction.php index e89aca139..fcd9dfc30 100644 --- a/src/Api/Actions/Discussions/ShowAction.php +++ b/src/Api/Actions/Discussions/ShowAction.php @@ -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); } diff --git a/src/Api/Actions/Discussions/UpdateAction.php b/src/Api/Actions/Discussions/UpdateAction.php index c2088cbc6..22ea30a49 100644 --- a/src/Api/Actions/Discussions/UpdateAction.php +++ b/src/Api/Actions/Discussions/UpdateAction.php @@ -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); } diff --git a/src/Api/Actions/Groups/IndexAction.php b/src/Api/Actions/Groups/IndexAction.php index 916686c4d..e306356a5 100644 --- a/src/Api/Actions/Groups/IndexAction.php +++ b/src/Api/Actions/Groups/IndexAction.php @@ -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(); } diff --git a/src/Api/Actions/Posts/CreateAction.php b/src/Api/Actions/Posts/CreateAction.php index 96db97aff..a437b8cb8 100644 --- a/src/Api/Actions/Posts/CreateAction.php +++ b/src/Api/Actions/Posts/CreateAction.php @@ -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); } diff --git a/src/Api/Actions/Posts/IndexAction.php b/src/Api/Actions/Posts/IndexAction.php index 45e465e23..2405fe270 100644 --- a/src/Api/Actions/Posts/IndexAction.php +++ b/src/Api/Actions/Posts/IndexAction.php @@ -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); } diff --git a/src/Api/Actions/Posts/ShowAction.php b/src/Api/Actions/Posts/ShowAction.php index b3110e6d1..1a0cd5bab 100644 --- a/src/Api/Actions/Posts/ShowAction.php +++ b/src/Api/Actions/Posts/ShowAction.php @@ -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); } diff --git a/src/Api/Actions/Posts/UpdateAction.php b/src/Api/Actions/Posts/UpdateAction.php index bced8498a..4aeb20baa 100644 --- a/src/Api/Actions/Posts/UpdateAction.php +++ b/src/Api/Actions/Posts/UpdateAction.php @@ -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); } diff --git a/src/Api/Actions/Users/CreateAction.php b/src/Api/Actions/Users/CreateAction.php index 166136674..5ad6b536c 100644 --- a/src/Api/Actions/Users/CreateAction.php +++ b/src/Api/Actions/Users/CreateAction.php @@ -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); } diff --git a/src/Api/Actions/Users/IndexAction.php b/src/Api/Actions/Users/IndexAction.php index 0a2c1635c..73f11818a 100644 --- a/src/Api/Actions/Users/IndexAction.php +++ b/src/Api/Actions/Users/IndexAction.php @@ -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); } diff --git a/src/Api/Actions/Users/ShowAction.php b/src/Api/Actions/Users/ShowAction.php index f6cc8aae0..694e68449 100644 --- a/src/Api/Actions/Users/ShowAction.php +++ b/src/Api/Actions/Users/ShowAction.php @@ -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); } diff --git a/src/Api/Actions/Users/UpdateAction.php b/src/Api/Actions/Users/UpdateAction.php index 25e3cbf82..fe48f0f9a 100644 --- a/src/Api/Actions/Users/UpdateAction.php +++ b/src/Api/Actions/Users/UpdateAction.php @@ -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); } diff --git a/src/Api/Events/SerializeRelationship.php b/src/Api/Events/SerializeRelationship.php index 48826796c..cfc07e259 100644 --- a/src/Api/Events/SerializeRelationship.php +++ b/src/Api/Events/SerializeRelationship.php @@ -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; } } diff --git a/src/Api/Serializers/ActivitySerializer.php b/src/Api/Serializers/ActivitySerializer.php index 271e2153b..2348598e4 100644 --- a/src/Api/Serializers/ActivitySerializer.php +++ b/src/Api/Serializers/ActivitySerializer.php @@ -1,11 +1,10 @@ ((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'); } } diff --git a/src/Api/Serializers/BaseSerializer.php b/src/Api/Serializers/BaseSerializer.php index 5f0224f3a..ef2eae5af 100644 --- a/src/Api/Serializers/BaseSerializer.php +++ b/src/Api/Serializers/BaseSerializer.php @@ -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); } } diff --git a/src/Api/Serializers/DiscussionBasicSerializer.php b/src/Api/Serializers/DiscussionBasicSerializer.php index de9547bb1..8ed30c205 100644 --- a/src/Api/Serializers/DiscussionBasicSerializer.php +++ b/src/Api/Serializers/DiscussionBasicSerializer.php @@ -1,11 +1,10 @@ (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'); } } diff --git a/src/Api/Serializers/DiscussionSerializer.php b/src/Api/Serializers/DiscussionSerializer.php index cfbb0e114..ca6697241 100644 --- a/src/Api/Serializers/DiscussionSerializer.php +++ b/src/Api/Serializers/DiscussionSerializer.php @@ -1,12 +1,10 @@ $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); } } diff --git a/src/Api/Serializers/GroupSerializer.php b/src/Api/Serializers/GroupSerializer.php index 3d77576a2..352315a38 100644 --- a/src/Api/Serializers/GroupSerializer.php +++ b/src/Api/Serializers/GroupSerializer.php @@ -1,17 +1,10 @@ (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); } } diff --git a/src/Api/Serializers/PostBasicSerializer.php b/src/Api/Serializers/PostBasicSerializer.php index 4e9712a3b..4c96e7c29 100644 --- a/src/Api/Serializers/PostBasicSerializer.php +++ b/src/Api/Serializers/PostBasicSerializer.php @@ -1,29 +1,24 @@ (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'); } } diff --git a/src/Api/Serializers/PostSerializer.php b/src/Api/Serializers/PostSerializer.php index ab84ecdb7..7d1e52eb3 100644 --- a/src/Api/Serializers/PostSerializer.php +++ b/src/Api/Serializers/PostSerializer.php @@ -1,18 +1,10 @@ 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'); } } diff --git a/src/Api/Serializers/UserBasicSerializer.php b/src/Api/Serializers/UserBasicSerializer.php index d047114f7..6f463da68 100644 --- a/src/Api/Serializers/UserBasicSerializer.php +++ b/src/Api/Serializers/UserBasicSerializer.php @@ -1,17 +1,10 @@ (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); } } diff --git a/src/Api/Serializers/UserSerializer.php b/src/Api/Serializers/UserSerializer.php index 82f862d2e..62b470357 100644 --- a/src/Api/Serializers/UserSerializer.php +++ b/src/Api/Serializers/UserSerializer.php @@ -1,17 +1,10 @@ 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'); } } diff --git a/src/Core/Models/Discussion.php b/src/Core/Models/Discussion.php index d78cdc2fd..a6a7aaa34 100755 --- a/src/Core/Models/Discussion.php +++ b/src/Core/Models/Discussion.php @@ -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. diff --git a/src/Web/Actions/IndexAction.php b/src/Web/Actions/IndexAction.php index 680ba1696..7ca444b43 100644 --- a/src/Web/Actions/IndexAction.php +++ b/src/Web/Actions/IndexAction.php @@ -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); }