mirror of
https://github.com/flarum/core.git
synced 2025-07-20 00:01:17 +02:00
Major refactor and improvements
- Reorganised all namespaces and class names for consistency and structure. Following PSR bylaws (Abstract prefix, Interface/Trait suffix). - Move models into root of Core, because writing `use Flarum\Core\Discussion` is nice. Namespace the rest by type. (Namespacing by entity was too arbitrary.) - Moved some non-domain stuff out of Core: Database, Formatter, Settings. - Renamed config table and all references to "settings" for consistency. - Remove Core class and add url()/isInstalled()/inDebugMode() as instance methods of Foundation\Application. - Cleanup, docblocking, etc. - Improvements to HTTP architecture - API and forum/admin Actions are now actually all the same thing (simple PSR-7 Request handlers), renamed to Controllers. - Upgrade to tobscure/json-api 0.2 branch. - Where possible, moved generic functionality to tobscure/json-api (e.g. pagination links). I'm quite happy with the backend balance now re: #262 - Improvements to other architecture - Use Illuminate's Auth\Access\Gate interface/implementation instead of our old Locked trait. We still use events to actually determine the permissions though. Our Policy classes are actually glorified event subscribers. - Extract model validation into Core\Validator classes. - Make post visibility permission stuff much more efficient and DRY. - Renamed Flarum\Event classes for consistency. ref #246 - `Configure` prefix for events dedicated to configuring an object. - `Get` prefix for events whose listeners should return something. - `Prepare` prefix when a variable is passed by reference so it can be modified. - `Scope` prefix when a query builder is passed. - Miscellaneous improvements/bug-fixes. I'm easily distracted! - Increase default height of post composer. - Improve post stream redraw flickering in Safari by keying loading post placeholders with their IDs. ref #451 - Use a PHP JavaScript minification library for minifying TextFormatter's JavaScript, instead of ClosureCompilerService (can't rely on external service!) - Use UrlGenerator properly in various places. closes #123 - Make Api\Client return Response object. closes #128 - Allow extensions to specify custom icon images. - Allow external API/admin URLs to be optionally specified in config.php. If the value or "url" is an array, we look for the corresponding path inside. Otherwise, we append the path to the base URL, using the corresponding value in "paths" if present. closes #244
This commit is contained in:
Before Width: | Height: | Size: 348 KiB After Width: | Height: | Size: 348 KiB |
@@ -23,20 +23,21 @@
|
|||||||
"illuminate/validation": "5.1.*",
|
"illuminate/validation": "5.1.*",
|
||||||
"illuminate/view": "5.1.*",
|
"illuminate/view": "5.1.*",
|
||||||
"league/flysystem": "^1.0.11",
|
"league/flysystem": "^1.0.11",
|
||||||
"tobscure/json-api": "^0.1.1",
|
"tobscure/json-api": "0.2.x-dev",
|
||||||
"oyejorge/less.php": "~1.5",
|
"oyejorge/less.php": "~1.5",
|
||||||
"intervention/image": "^2.3.0",
|
"intervention/image": "^2.3.0",
|
||||||
"s9e/text-formatter": "^0.4.0",
|
"s9e/text-formatter": "^0.4.0",
|
||||||
"psr/http-message": "^1.0",
|
"psr/http-message": "^1.0",
|
||||||
"zendframework/zend-diactoros": "^1.1",
|
"zendframework/zend-diactoros": "^1.1",
|
||||||
|
"zendframework/zend-stratigility": "^1.1",
|
||||||
"nikic/fast-route": "^0.6",
|
"nikic/fast-route": "^0.6",
|
||||||
"dflydev/fig-cookies": "^1.0",
|
"dflydev/fig-cookies": "^1.0",
|
||||||
"symfony/console": "^2.7",
|
"symfony/console": "^2.7",
|
||||||
"symfony/yaml": "^2.7",
|
"symfony/yaml": "^2.7",
|
||||||
"doctrine/dbal": "^2.5",
|
"doctrine/dbal": "^2.5",
|
||||||
"zendframework/zend-stratigility": "^1.1",
|
|
||||||
"monolog/monolog": "^1.16.0",
|
"monolog/monolog": "^1.16.0",
|
||||||
"franzl/whoops-middleware": "dev-master"
|
"franzl/whoops-middleware": "dev-master",
|
||||||
|
"matthiasmullie/minify": "^1.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mockery/mockery": "^0.9.4",
|
"mockery/mockery": "^0.9.4",
|
||||||
|
629
framework/core/composer.lock
generated
629
framework/core/composer.lock
generated
@@ -4,8 +4,8 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "555cfa89899e3b8e3df986c1edab97ad",
|
"hash": "0b4a3140d826b9566b0fde2c36fdf81f",
|
||||||
"content-hash": "24bf970274bf8e8ea5de56c5036d1c20",
|
"content-hash": "c770bf3b6d5906b52fa2066708d07959",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "danielstjules/stringy",
|
"name": "danielstjules/stringy",
|
||||||
@@ -394,16 +394,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/dbal",
|
"name": "doctrine/dbal",
|
||||||
"version": "v2.5.1",
|
"version": "v2.5.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/doctrine/dbal.git",
|
"url": "https://github.com/doctrine/dbal.git",
|
||||||
"reference": "628c2256b646ae2417d44e063bce8aec5199d48d"
|
"reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/doctrine/dbal/zipball/628c2256b646ae2417d44e063bce8aec5199d48d",
|
"url": "https://api.github.com/repos/doctrine/dbal/zipball/01dbcbc5cd0a913d751418e635434a18a2f2a75c",
|
||||||
"reference": "628c2256b646ae2417d44e063bce8aec5199d48d",
|
"reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -461,7 +461,7 @@
|
|||||||
"persistence",
|
"persistence",
|
||||||
"queryobject"
|
"queryobject"
|
||||||
],
|
],
|
||||||
"time": "2015-01-12 21:52:47"
|
"time": "2015-09-16 16:29:33"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/inflector",
|
"name": "doctrine/inflector",
|
||||||
@@ -584,6 +584,92 @@
|
|||||||
],
|
],
|
||||||
"time": "2014-09-09 13:34:57"
|
"time": "2014-09-09 13:34:57"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "filp/whoops",
|
||||||
|
"version": "1.1.7",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/filp/whoops.git",
|
||||||
|
"reference": "72538eeb70bbfb11964412a3d098d109efd012f7"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/filp/whoops/zipball/72538eeb70bbfb11964412a3d098d109efd012f7",
|
||||||
|
"reference": "72538eeb70bbfb11964412a3d098d109efd012f7",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "0.9.*"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.2-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Whoops": "src/"
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"src/deprecated"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Filipe Dobreira",
|
||||||
|
"homepage": "https://github.com/filp",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "php error handling for cool kids",
|
||||||
|
"homepage": "https://github.com/filp/whoops",
|
||||||
|
"keywords": [
|
||||||
|
"error",
|
||||||
|
"exception",
|
||||||
|
"handling",
|
||||||
|
"library",
|
||||||
|
"silex-provider",
|
||||||
|
"whoops",
|
||||||
|
"zf2"
|
||||||
|
],
|
||||||
|
"time": "2015-06-29 05:42:04"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "franzl/whoops-middleware",
|
||||||
|
"version": "dev-master",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/franzliedke/whoops-middleware.git",
|
||||||
|
"reference": "4f87c4d36653d95b27fbe85d21954e0d2de58136"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/franzliedke/whoops-middleware/zipball/4f87c4d36653d95b27fbe85d21954e0d2de58136",
|
||||||
|
"reference": "4f87c4d36653d95b27fbe85d21954e0d2de58136",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"filp/whoops": "^1.1",
|
||||||
|
"zendframework/zend-diactoros": "^1.1@dev",
|
||||||
|
"zendframework/zend-stratigility": "^1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Franzl\\Middleware\\Whoops\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"time": "2015-06-17 00:08:50"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
@@ -1374,21 +1460,24 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "league/flysystem",
|
"name": "league/flysystem",
|
||||||
"version": "1.0.12",
|
"version": "1.0.15",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/thephpleague/flysystem.git",
|
"url": "https://github.com/thephpleague/flysystem.git",
|
||||||
"reference": "7323424a9d39c24e597ed3f2144419dfbb52e086"
|
"reference": "31525caf9e8772683672fefd8a1ca0c0736020f4"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/7323424a9d39c24e597ed3f2144419dfbb52e086",
|
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/31525caf9e8772683672fefd8a1ca0c0736020f4",
|
||||||
"reference": "7323424a9d39c24e597ed3f2144419dfbb52e086",
|
"reference": "31525caf9e8772683672fefd8a1ca0c0736020f4",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.4.0"
|
||||||
},
|
},
|
||||||
|
"conflict": {
|
||||||
|
"league/flysystem-sftp": "<1.0.6"
|
||||||
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-fileinfo": "*",
|
"ext-fileinfo": "*",
|
||||||
"mockery/mockery": "~0.9",
|
"mockery/mockery": "~0.9",
|
||||||
@@ -1451,7 +1540,190 @@
|
|||||||
"sftp",
|
"sftp",
|
||||||
"storage"
|
"storage"
|
||||||
],
|
],
|
||||||
"time": "2015-09-05 12:06:41"
|
"time": "2015-09-30 22:26:59"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "matthiasmullie/minify",
|
||||||
|
"version": "1.3.28",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/matthiasmullie/minify.git",
|
||||||
|
"reference": "2cee2544198d97bca4ba094bc2df27d6458da1af"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/2cee2544198d97bca4ba094bc2df27d6458da1af",
|
||||||
|
"reference": "2cee2544198d97bca4ba094bc2df27d6458da1af",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"matthiasmullie/path-converter": "~1.0",
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "4.3.*",
|
||||||
|
"satooshi/php-coveralls": "dev-master",
|
||||||
|
"scrapbook/psr-cache": "~0.2"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/minifycss",
|
||||||
|
"bin/minifyjs"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"MatthiasMullie\\Minify\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Matthias Mullie",
|
||||||
|
"email": "minify@mullie.eu",
|
||||||
|
"homepage": "http://www.mullie.eu",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "CSS & JS minifier",
|
||||||
|
"homepage": "http://www.minifier.org",
|
||||||
|
"keywords": [
|
||||||
|
"JS",
|
||||||
|
"css",
|
||||||
|
"javascript",
|
||||||
|
"minifier",
|
||||||
|
"minify"
|
||||||
|
],
|
||||||
|
"time": "2015-08-20 14:49:37"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "matthiasmullie/path-converter",
|
||||||
|
"version": "1.0.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/matthiasmullie/path-converter.git",
|
||||||
|
"reference": "b1e31c51e8c207ad6114f5b4ac4e652bc936c380"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/b1e31c51e8c207ad6114f5b4ac4e652bc936c380",
|
||||||
|
"reference": "b1e31c51e8c207ad6114f5b4ac4e652bc936c380",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "4.3.*",
|
||||||
|
"satooshi/php-coveralls": "dev-master"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"MatthiasMullie\\PathConverter\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Matthias Mullie",
|
||||||
|
"email": "pathconverter@mullie.eu",
|
||||||
|
"homepage": "http://www.mullie.eu",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Relative path converter",
|
||||||
|
"homepage": "http://github.com/matthiasmullie/path-converter",
|
||||||
|
"keywords": [
|
||||||
|
"converter",
|
||||||
|
"path",
|
||||||
|
"paths",
|
||||||
|
"relative"
|
||||||
|
],
|
||||||
|
"time": "2015-06-01 15:20:30"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "monolog/monolog",
|
||||||
|
"version": "1.17.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Seldaek/monolog.git",
|
||||||
|
"reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/0524c87587ab85bc4c2d6f5b41253ccb930a5422",
|
||||||
|
"reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0",
|
||||||
|
"psr/log": "~1.0"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/log-implementation": "1.0.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"aws/aws-sdk-php": "^2.4.9",
|
||||||
|
"doctrine/couchdb": "~1.0@dev",
|
||||||
|
"graylog2/gelf-php": "~1.0",
|
||||||
|
"php-console/php-console": "^3.1.3",
|
||||||
|
"phpunit/phpunit": "~4.5",
|
||||||
|
"phpunit/phpunit-mock-objects": "2.3.0",
|
||||||
|
"raven/raven": "~0.11",
|
||||||
|
"ruflin/elastica": ">=0.90 <3.0",
|
||||||
|
"swiftmailer/swiftmailer": "~5.3",
|
||||||
|
"videlalvaro/php-amqplib": "~2.4"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
||||||
|
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
||||||
|
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
||||||
|
"ext-mongo": "Allow sending log messages to a MongoDB server",
|
||||||
|
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
||||||
|
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
||||||
|
"raven/raven": "Allow sending log messages to a Sentry server",
|
||||||
|
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
||||||
|
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
|
||||||
|
"videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.16.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Monolog\\": "src/Monolog"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jordi Boggiano",
|
||||||
|
"email": "j.boggiano@seld.be",
|
||||||
|
"homepage": "http://seld.be"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
|
||||||
|
"homepage": "http://github.com/Seldaek/monolog",
|
||||||
|
"keywords": [
|
||||||
|
"log",
|
||||||
|
"logging",
|
||||||
|
"psr-3"
|
||||||
|
],
|
||||||
|
"time": "2015-08-31 09:17:37"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nesbot/carbon",
|
"name": "nesbot/carbon",
|
||||||
@@ -1545,16 +1817,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "oyejorge/less.php",
|
"name": "oyejorge/less.php",
|
||||||
"version": "v1.7.0.5",
|
"version": "v1.7.0.9",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/oyejorge/less.php.git",
|
"url": "https://github.com/oyejorge/less.php.git",
|
||||||
"reference": "4385036b1dbfaf37f5380bd26a1e6006fc43149f"
|
"reference": "fb64e2f6ef647a229c50e9fa0f2076240a3484c6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/oyejorge/less.php/zipball/4385036b1dbfaf37f5380bd26a1e6006fc43149f",
|
"url": "https://api.github.com/repos/oyejorge/less.php/zipball/fb64e2f6ef647a229c50e9fa0f2076240a3484c6",
|
||||||
"reference": "4385036b1dbfaf37f5380bd26a1e6006fc43149f",
|
"reference": "fb64e2f6ef647a229c50e9fa0f2076240a3484c6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1600,7 +1872,7 @@
|
|||||||
"php",
|
"php",
|
||||||
"stylesheet"
|
"stylesheet"
|
||||||
],
|
],
|
||||||
"time": "2015-07-13 20:34:18"
|
"time": "2015-09-28 01:11:47"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/http-message",
|
"name": "psr/http-message",
|
||||||
@@ -1691,16 +1963,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "s9e/text-formatter",
|
"name": "s9e/text-formatter",
|
||||||
"version": "0.4.0",
|
"version": "0.4.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/s9e/TextFormatter.git",
|
"url": "https://github.com/s9e/TextFormatter.git",
|
||||||
"reference": "0ad4f5d80542819d0bae9047d39566ab0df55c53"
|
"reference": "1f742f17ad0294d52754b9acc6a053e239d26226"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/s9e/TextFormatter/zipball/0ad4f5d80542819d0bae9047d39566ab0df55c53",
|
"url": "https://api.github.com/repos/s9e/TextFormatter/zipball/1f742f17ad0294d52754b9acc6a053e239d26226",
|
||||||
"reference": "0ad4f5d80542819d0bae9047d39566ab0df55c53",
|
"reference": "1f742f17ad0294d52754b9acc6a053e239d26226",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1746,7 +2018,7 @@
|
|||||||
"parser",
|
"parser",
|
||||||
"shortcodes"
|
"shortcodes"
|
||||||
],
|
],
|
||||||
"time": "2015-09-22 23:26:41"
|
"time": "2015-10-04 10:36:14"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "swiftmailer/swiftmailer",
|
"name": "swiftmailer/swiftmailer",
|
||||||
@@ -1803,16 +2075,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/console",
|
"name": "symfony/console",
|
||||||
"version": "v2.7.4",
|
"version": "v2.7.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/console.git",
|
"url": "https://github.com/symfony/console.git",
|
||||||
"reference": "9ff9032151186bd66ecee727d728f1319f52d1d8"
|
"reference": "06cb17c013a82f94a3d840682b49425cd00a2161"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/console/zipball/9ff9032151186bd66ecee727d728f1319f52d1d8",
|
"url": "https://api.github.com/repos/symfony/console/zipball/06cb17c013a82f94a3d840682b49425cd00a2161",
|
||||||
"reference": "9ff9032151186bd66ecee727d728f1319f52d1d8",
|
"reference": "06cb17c013a82f94a3d840682b49425cd00a2161",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1856,20 +2128,20 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Console Component",
|
"description": "Symfony Console Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2015-09-03 11:40:38"
|
"time": "2015-09-25 08:32:23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/finder",
|
"name": "symfony/finder",
|
||||||
"version": "v2.7.4",
|
"version": "v2.7.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Finder.git",
|
"url": "https://github.com/symfony/finder.git",
|
||||||
"reference": "fff4b0c362640a0ab7355e2647b3d461608e9065"
|
"reference": "8262ab605973afbb3ef74b945daabf086f58366f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Finder/zipball/fff4b0c362640a0ab7355e2647b3d461608e9065",
|
"url": "https://api.github.com/repos/symfony/finder/zipball/8262ab605973afbb3ef74b945daabf086f58366f",
|
||||||
"reference": "fff4b0c362640a0ab7355e2647b3d461608e9065",
|
"reference": "8262ab605973afbb3ef74b945daabf086f58366f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1905,20 +2177,20 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Finder Component",
|
"description": "Symfony Finder Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2015-08-26 17:56:37"
|
"time": "2015-09-19 19:59:23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/http-foundation",
|
"name": "symfony/http-foundation",
|
||||||
"version": "v2.7.4",
|
"version": "v2.7.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/http-foundation.git",
|
"url": "https://github.com/symfony/http-foundation.git",
|
||||||
"reference": "7253c2041652353e71560bbd300d6256d170ddaf"
|
"reference": "e1509119f164a0d0a940d7d924d693a7a28a5470"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/7253c2041652353e71560bbd300d6256d170ddaf",
|
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e1509119f164a0d0a940d7d924d693a7a28a5470",
|
||||||
"reference": "7253c2041652353e71560bbd300d6256d170ddaf",
|
"reference": "e1509119f164a0d0a940d7d924d693a7a28a5470",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1958,19 +2230,19 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony HttpFoundation Component",
|
"description": "Symfony HttpFoundation Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2015-08-27 06:45:45"
|
"time": "2015-09-22 13:49:29"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/translation",
|
"name": "symfony/translation",
|
||||||
"version": "v2.7.4",
|
"version": "v2.7.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Translation.git",
|
"url": "https://github.com/symfony/translation.git",
|
||||||
"reference": "485877661835e188cd78345c6d4eef1290d17571"
|
"reference": "485877661835e188cd78345c6d4eef1290d17571"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/485877661835e188cd78345c6d4eef1290d17571",
|
"url": "https://api.github.com/repos/symfony/translation/zipball/485877661835e188cd78345c6d4eef1290d17571",
|
||||||
"reference": "485877661835e188cd78345c6d4eef1290d17571",
|
"reference": "485877661835e188cd78345c6d4eef1290d17571",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
@@ -2023,16 +2295,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/yaml",
|
"name": "symfony/yaml",
|
||||||
"version": "v2.7.4",
|
"version": "v2.7.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Yaml.git",
|
"url": "https://github.com/symfony/yaml.git",
|
||||||
"reference": "2dc7b06c065df96cc686c66da2705e5e18aef661"
|
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661",
|
"url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
|
||||||
"reference": "2dc7b06c065df96cc686c66da2705e5e18aef661",
|
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -2068,20 +2340,20 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Yaml Component",
|
"description": "Symfony Yaml Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2015-08-24 07:13:45"
|
"time": "2015-09-14 14:14:09"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tobscure/json-api",
|
"name": "tobscure/json-api",
|
||||||
"version": "v0.1.1",
|
"version": "0.2.x-dev",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tobscure/json-api.git",
|
"url": "https://github.com/tobscure/json-api.git",
|
||||||
"reference": "bd316b03c63d6e2bbd56c0714eccc644f31881d4"
|
"reference": "e26093389685de3c0c67f4d50145ddd12f967e1b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/tobscure/json-api/zipball/bd316b03c63d6e2bbd56c0714eccc644f31881d4",
|
"url": "https://api.github.com/repos/tobscure/json-api/zipball/e26093389685de3c0c67f4d50145ddd12f967e1b",
|
||||||
"reference": "bd316b03c63d6e2bbd56c0714eccc644f31881d4",
|
"reference": "e26093389685de3c0c67f4d50145ddd12f967e1b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -2118,7 +2390,7 @@
|
|||||||
"jsonapi",
|
"jsonapi",
|
||||||
"standard"
|
"standard"
|
||||||
],
|
],
|
||||||
"time": "2015-08-07 07:12:01"
|
"time": "2015-10-08 02:08:53"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zendframework/zend-diactoros",
|
"name": "zendframework/zend-diactoros",
|
||||||
@@ -2481,117 +2753,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2015-02-03 12:10:50"
|
"time": "2015-02-03 12:10:50"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "phpspec/php-diff",
|
|
||||||
"version": "v1.0.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/phpspec/php-diff.git",
|
|
||||||
"reference": "30e103d19519fe678ae64a60d77884ef3d71b28a"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a",
|
|
||||||
"reference": "30e103d19519fe678ae64a60d77884ef3d71b28a",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Diff": "lib/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Chris Boulton",
|
|
||||||
"homepage": "http://github.com/chrisboulton",
|
|
||||||
"role": "Original developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).",
|
|
||||||
"time": "2013-11-01 13:02:21"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpspec/phpspec",
|
|
||||||
"version": "2.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/phpspec/phpspec.git",
|
|
||||||
"reference": "36635a903bdeb54899d7407bc95610501fd98559"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/36635a903bdeb54899d7407bc95610501fd98559",
|
|
||||||
"reference": "36635a903bdeb54899d7407bc95610501fd98559",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"doctrine/instantiator": "^1.0.1",
|
|
||||||
"php": ">=5.3.3",
|
|
||||||
"phpspec/php-diff": "~1.0.0",
|
|
||||||
"phpspec/prophecy": "~1.4",
|
|
||||||
"sebastian/exporter": "~1.0",
|
|
||||||
"symfony/console": "~2.3",
|
|
||||||
"symfony/event-dispatcher": "~2.1",
|
|
||||||
"symfony/finder": "~2.1",
|
|
||||||
"symfony/process": "^2.6",
|
|
||||||
"symfony/yaml": "~2.1"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"behat/behat": "^3.0.11",
|
|
||||||
"bossa/phpspec2-expect": "~1.0",
|
|
||||||
"phpunit/phpunit": "~4.4",
|
|
||||||
"symfony/filesystem": "~2.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters"
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"bin/phpspec"
|
|
||||||
],
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.2.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"PhpSpec": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Konstantin Kudryashov",
|
|
||||||
"email": "ever.zet@gmail.com",
|
|
||||||
"homepage": "http://everzet.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Marcello Duarte",
|
|
||||||
"homepage": "http://marcelloduarte.net/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Specification-oriented BDD framework for PHP 5.3+",
|
|
||||||
"homepage": "http://phpspec.net/",
|
|
||||||
"keywords": [
|
|
||||||
"BDD",
|
|
||||||
"SpecBDD",
|
|
||||||
"TDD",
|
|
||||||
"spec",
|
|
||||||
"specification",
|
|
||||||
"testing",
|
|
||||||
"tests"
|
|
||||||
],
|
|
||||||
"time": "2015-09-07 07:07:37"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "phpspec/prophecy",
|
"name": "phpspec/prophecy",
|
||||||
"version": "v1.5.0",
|
"version": "v1.5.0",
|
||||||
@@ -2654,16 +2815,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "2.2.3",
|
"version": "2.2.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
|
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
|
||||||
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
|
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -2712,7 +2873,7 @@
|
|||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-09-14 06:51:16"
|
"time": "2015-10-06 15:47:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
@@ -2894,16 +3055,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "4.8.9",
|
"version": "4.8.11",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b"
|
"reference": "bdd199472410fd7e32751f9c814c7e06f2c21bd5"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/73fad41adb5b7bc3a494bb930d90648df1d5e74b",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bdd199472410fd7e32751f9c814c7e06f2c21bd5",
|
||||||
"reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b",
|
"reference": "bdd199472410fd7e32751f9c814c7e06f2c21bd5",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -2962,20 +3123,20 @@
|
|||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-09-20 12:56:44"
|
"time": "2015-10-07 10:39:46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit-mock-objects",
|
"name": "phpunit/phpunit-mock-objects",
|
||||||
"version": "2.3.7",
|
"version": "2.3.8",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||||
"reference": "5e2645ad49d196e020b85598d7c97e482725786a"
|
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
|
||||||
"reference": "5e2645ad49d196e020b85598d7c97e482725786a",
|
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -3018,7 +3179,7 @@
|
|||||||
"mock",
|
"mock",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-08-19 09:14:08"
|
"time": "2015-10-02 06:51:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/comparator",
|
"name": "sebastian/comparator",
|
||||||
@@ -3464,118 +3625,14 @@
|
|||||||
"standards"
|
"standards"
|
||||||
],
|
],
|
||||||
"time": "2015-09-09 00:18:50"
|
"time": "2015-09-09 00:18:50"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/event-dispatcher",
|
|
||||||
"version": "v2.7.4",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
|
||||||
"reference": "b58c916f1db03a611b72dd702564f30ad8fe83fa"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b58c916f1db03a611b72dd702564f30ad8fe83fa",
|
|
||||||
"reference": "b58c916f1db03a611b72dd702564f30ad8fe83fa",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.9"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"psr/log": "~1.0",
|
|
||||||
"symfony/config": "~2.0,>=2.0.5",
|
|
||||||
"symfony/dependency-injection": "~2.6",
|
|
||||||
"symfony/expression-language": "~2.6",
|
|
||||||
"symfony/phpunit-bridge": "~2.7",
|
|
||||||
"symfony/stopwatch": "~2.3"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"symfony/dependency-injection": "",
|
|
||||||
"symfony/http-kernel": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.7-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\EventDispatcher\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony EventDispatcher Component",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"time": "2015-08-24 07:13:45"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/process",
|
|
||||||
"version": "v2.7.4",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/Process.git",
|
|
||||||
"reference": "f7b3f73f70a7f8f49a1c838dc3debbf054732d8e"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/Process/zipball/f7b3f73f70a7f8f49a1c838dc3debbf054732d8e",
|
|
||||||
"reference": "f7b3f73f70a7f8f49a1c838dc3debbf054732d8e",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.9"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"symfony/phpunit-bridge": "~2.7"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.7-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\Process\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony Process Component",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"time": "2015-08-27 06:45:45"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": {
|
||||||
|
"tobscure/json-api": 20,
|
||||||
|
"franzl/whoops-middleware": 20
|
||||||
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
|
@@ -10,4 +10,4 @@
|
|||||||
<p>Something went wrong on our server.</p>
|
<p>Something went wrong on our server.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
8
framework/core/js/admin/dist/app.js
vendored
8
framework/core/js/admin/dist/app.js
vendored
File diff suppressed because one or more lines are too long
@@ -2,16 +2,16 @@ import Component from 'flarum/Component';
|
|||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import Switch from 'flarum/components/Switch';
|
import Switch from 'flarum/components/Switch';
|
||||||
import EditCustomCssModal from 'flarum/components/EditCustomCssModal';
|
import EditCustomCssModal from 'flarum/components/EditCustomCssModal';
|
||||||
import saveConfig from 'flarum/utils/saveConfig';
|
import saveSettings from 'flarum/utils/saveSettings';
|
||||||
|
|
||||||
export default class AppearancePage extends Component {
|
export default class AppearancePage extends Component {
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
super(...args);
|
super(...args);
|
||||||
|
|
||||||
this.primaryColor = m.prop(app.config.theme_primary_color);
|
this.primaryColor = m.prop(app.settings.theme_primary_color);
|
||||||
this.secondaryColor = m.prop(app.config.theme_secondary_color);
|
this.secondaryColor = m.prop(app.settings.theme_secondary_color);
|
||||||
this.darkMode = m.prop(app.config.theme_dark_mode === '1');
|
this.darkMode = m.prop(app.settings.theme_dark_mode === '1');
|
||||||
this.coloredHeader = m.prop(app.config.theme_colored_header === '1');
|
this.coloredHeader = m.prop(app.settings.theme_colored_header === '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
@@ -79,7 +79,7 @@ export default class AppearancePage extends Component {
|
|||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
saveConfig({
|
saveSettings({
|
||||||
theme_primary_color: this.primaryColor(),
|
theme_primary_color: this.primaryColor(),
|
||||||
theme_secondary_color: this.secondaryColor(),
|
theme_secondary_color: this.secondaryColor(),
|
||||||
theme_dark_mode: this.darkMode(),
|
theme_dark_mode: this.darkMode(),
|
||||||
|
@@ -3,7 +3,7 @@ import FieldSet from 'flarum/components/FieldSet';
|
|||||||
import Select from 'flarum/components/Select';
|
import Select from 'flarum/components/Select';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import Alert from 'flarum/components/Alert';
|
import Alert from 'flarum/components/Alert';
|
||||||
import saveConfig from 'flarum/utils/saveConfig';
|
import saveSettings from 'flarum/utils/saveSettings';
|
||||||
import ItemList from 'flarum/utils/ItemList';
|
import ItemList from 'flarum/utils/ItemList';
|
||||||
|
|
||||||
export default class BasicsPage extends Component {
|
export default class BasicsPage extends Component {
|
||||||
@@ -20,8 +20,8 @@ export default class BasicsPage extends Component {
|
|||||||
];
|
];
|
||||||
this.values = {};
|
this.values = {};
|
||||||
|
|
||||||
const config = app.config;
|
const settings = app.settings;
|
||||||
this.fields.forEach(key => this.values[key] = m.prop(config[key]));
|
this.fields.forEach(key => this.values[key] = m.prop(settings[key]));
|
||||||
|
|
||||||
this.localeOptions = {};
|
this.localeOptions = {};
|
||||||
const locales = app.locales;
|
const locales = app.locales;
|
||||||
@@ -108,7 +108,7 @@ export default class BasicsPage extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
changed() {
|
changed() {
|
||||||
return this.fields.some(key => this.values[key]() !== app.config[key]);
|
return this.fields.some(key => this.values[key]() !== app.settings[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,11 +137,11 @@ export default class BasicsPage extends Component {
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
app.alerts.dismiss(this.successAlert);
|
app.alerts.dismiss(this.successAlert);
|
||||||
|
|
||||||
const config = {};
|
const settings = {};
|
||||||
|
|
||||||
this.fields.forEach(key => config[key] = this.values[key]());
|
this.fields.forEach(key => settings[key] = this.values[key]());
|
||||||
|
|
||||||
saveConfig(config)
|
saveSettings(settings)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
app.alerts.show(this.successAlert = new Alert({type: 'success', children: 'Your changes were saved.'}));
|
app.alerts.show(this.successAlert = new Alert({type: 'success', children: 'Your changes were saved.'}));
|
||||||
})
|
})
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import Modal from 'flarum/components/Modal';
|
import Modal from 'flarum/components/Modal';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import saveConfig from 'flarum/utils/saveConfig';
|
import saveSettings from 'flarum/utils/saveSettings';
|
||||||
|
|
||||||
export default class EditCustomCssModal extends Modal {
|
export default class EditCustomCssModal extends Modal {
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
super(...args);
|
super(...args);
|
||||||
|
|
||||||
this.customLess = m.prop(app.config.custom_less || '');
|
this.customLess = m.prop(app.settings.custom_less || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
className() {
|
className() {
|
||||||
@@ -45,7 +45,7 @@ export default class EditCustomCssModal extends Modal {
|
|||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
saveConfig({
|
saveSettings({
|
||||||
custom_less: this.customLess()
|
custom_less: this.customLess()
|
||||||
}).then(() => window.location.reload());
|
}).then(() => window.location.reload());
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ export default class ExtensionsPage extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isEnabled(name) {
|
isEnabled(name) {
|
||||||
const enabled = JSON.parse(app.config.extensions_enabled);
|
const enabled = JSON.parse(app.settings.extensions_enabled);
|
||||||
|
|
||||||
return enabled.indexOf(name) !== -1;
|
return enabled.indexOf(name) !== -1;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import Component from 'flarum/Component';
|
import Component from 'flarum/Component';
|
||||||
import PermissionDropdown from 'flarum/components/PermissionDropdown';
|
import PermissionDropdown from 'flarum/components/PermissionDropdown';
|
||||||
import ConfigDropdown from 'flarum/components/ConfigDropdown';
|
import SettingDropdown from 'flarum/components/SettingDropdown';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import ItemList from 'flarum/utils/ItemList';
|
import ItemList from 'flarum/utils/ItemList';
|
||||||
import icon from 'flarum/helpers/icon';
|
import icon from 'flarum/helpers/icon';
|
||||||
@@ -96,7 +96,7 @@ export default class PermissionGrid extends Component {
|
|||||||
items.add('signUp', {
|
items.add('signUp', {
|
||||||
icon: 'user-plus',
|
icon: 'user-plus',
|
||||||
label: 'Sign up',
|
label: 'Sign up',
|
||||||
setting: () => ConfigDropdown.component({
|
setting: () => SettingDropdown.component({
|
||||||
key: 'allow_sign_up',
|
key: 'allow_sign_up',
|
||||||
options: [
|
options: [
|
||||||
{value: '1', label: 'Open'},
|
{value: '1', label: 'Open'},
|
||||||
@@ -121,9 +121,9 @@ export default class PermissionGrid extends Component {
|
|||||||
icon: 'i-cursor',
|
icon: 'i-cursor',
|
||||||
label: 'Allow renaming',
|
label: 'Allow renaming',
|
||||||
setting: () => {
|
setting: () => {
|
||||||
const minutes = parseInt(app.config.allow_renaming, 10);
|
const minutes = parseInt(app.settings.allow_renaming, 10);
|
||||||
|
|
||||||
return ConfigDropdown.component({
|
return SettingDropdown.component({
|
||||||
defaultLabel: minutes ? `For ${minutes} minutes` : 'Indefinitely',
|
defaultLabel: minutes ? `For ${minutes} minutes` : 'Indefinitely',
|
||||||
key: 'allow_renaming',
|
key: 'allow_renaming',
|
||||||
options: [
|
options: [
|
||||||
@@ -151,9 +151,9 @@ export default class PermissionGrid extends Component {
|
|||||||
icon: 'pencil',
|
icon: 'pencil',
|
||||||
label: 'Allow post editing',
|
label: 'Allow post editing',
|
||||||
setting: () => {
|
setting: () => {
|
||||||
const minutes = parseInt(app.config.allow_post_editing, 10);
|
const minutes = parseInt(app.settings.allow_post_editing, 10);
|
||||||
|
|
||||||
return ConfigDropdown.component({
|
return SettingDropdown.component({
|
||||||
defaultLabel: minutes ? `For ${minutes} minutes` : 'Indefinitely',
|
defaultLabel: minutes ? `For ${minutes} minutes` : 'Indefinitely',
|
||||||
key: 'allow_post_editing',
|
key: 'allow_post_editing',
|
||||||
options: [
|
options: [
|
||||||
|
@@ -1,23 +1,23 @@
|
|||||||
import SelectDropdown from 'flarum/components/SelectDropdown';
|
import SelectDropdown from 'flarum/components/SelectDropdown';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import saveConfig from 'flarum/utils/saveConfig';
|
import saveSettings from 'flarum/utils/saveSettings';
|
||||||
|
|
||||||
export default class ConfigDropdown extends SelectDropdown {
|
export default class SettingDropdown extends SelectDropdown {
|
||||||
static initProps(props) {
|
static initProps(props) {
|
||||||
super.initProps(props);
|
super.initProps(props);
|
||||||
|
|
||||||
props.className = 'ConfigDropdown';
|
props.className = 'SettingDropdown';
|
||||||
props.buttonClassName = 'Button Button--text';
|
props.buttonClassName = 'Button Button--text';
|
||||||
props.caretIcon = 'caret-down';
|
props.caretIcon = 'caret-down';
|
||||||
props.defaultLabel = 'Custom';
|
props.defaultLabel = 'Custom';
|
||||||
|
|
||||||
props.children = props.options.map(({value, label}) => {
|
props.children = props.options.map(({value, label}) => {
|
||||||
const active = app.config[props.key] === value;
|
const active = app.settings[props.key] === value;
|
||||||
|
|
||||||
return Button.component({
|
return Button.component({
|
||||||
children: label,
|
children: label,
|
||||||
icon: active ? 'check' : true,
|
icon: active ? 'check' : true,
|
||||||
onclick: saveConfig.bind(this, {[props.key]: value}),
|
onclick: saveSettings.bind(this, {[props.key]: value}),
|
||||||
active
|
active
|
||||||
});
|
});
|
||||||
});
|
});
|
@@ -1,6 +1,6 @@
|
|||||||
import Modal from 'flarum/components/Modal';
|
import Modal from 'flarum/components/Modal';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
import saveConfig from 'flarum/utils/saveConfig';
|
import saveSettings from 'flarum/utils/saveSettings';
|
||||||
|
|
||||||
export default class SettingsModal extends Modal {
|
export default class SettingsModal extends Modal {
|
||||||
init() {
|
init() {
|
||||||
@@ -39,7 +39,7 @@ export default class SettingsModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setting(key, fallback = '') {
|
setting(key, fallback = '') {
|
||||||
this.settings[key] = this.settings[key] || m.prop(app.config[key] || fallback);
|
this.settings[key] = this.settings[key] || m.prop(app.settings[key] || fallback);
|
||||||
|
|
||||||
return this.settings[key];
|
return this.settings[key];
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ export default class SettingsModal extends Modal {
|
|||||||
Object.keys(this.settings).forEach(key => {
|
Object.keys(this.settings).forEach(key => {
|
||||||
const value = this.settings[key]();
|
const value = this.settings[key]();
|
||||||
|
|
||||||
if (value !== app.config[key]) {
|
if (value !== app.settings[key]) {
|
||||||
dirty[key] = value;
|
dirty[key] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -67,7 +67,7 @@ export default class SettingsModal extends Modal {
|
|||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
saveConfig(this.dirty()).then(
|
saveSettings(this.dirty()).then(
|
||||||
() => this.hide(),
|
() => this.hide(),
|
||||||
() => {
|
() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
export default function saveConfig(config) {
|
|
||||||
const oldConfig = JSON.parse(JSON.stringify(app.config));
|
|
||||||
|
|
||||||
Object.assign(app.config, config);
|
|
||||||
|
|
||||||
return app.request({
|
|
||||||
method: 'POST',
|
|
||||||
url: app.forum.attribute('apiUrl') + '/config',
|
|
||||||
data: {config}
|
|
||||||
}).catch(error => {
|
|
||||||
app.config = oldConfig;
|
|
||||||
throw error;
|
|
||||||
});
|
|
||||||
}
|
|
14
framework/core/js/admin/src/utils/saveSettings.js
Normal file
14
framework/core/js/admin/src/utils/saveSettings.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
export default function saveSettings(settings) {
|
||||||
|
const oldSettings = JSON.parse(JSON.stringify(app.settings));
|
||||||
|
|
||||||
|
Object.assign(app.settings, settings);
|
||||||
|
|
||||||
|
return app.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: app.forum.attribute('apiUrl') + '/settings',
|
||||||
|
data: settings
|
||||||
|
}).catch(error => {
|
||||||
|
app.settings = oldSettings;
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
}
|
22
framework/core/js/forum/dist/app.js
vendored
22
framework/core/js/forum/dist/app.js
vendored
File diff suppressed because one or more lines are too long
@@ -96,6 +96,12 @@ class Composer extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config(isInitialized, context) {
|
config(isInitialized, context) {
|
||||||
|
let defaultHeight;
|
||||||
|
|
||||||
|
if (!isInitialized) {
|
||||||
|
defaultHeight = this.$().height();
|
||||||
|
}
|
||||||
|
|
||||||
this.updateHeight();
|
this.updateHeight();
|
||||||
|
|
||||||
if (isInitialized) return;
|
if (isInitialized) return;
|
||||||
@@ -107,7 +113,7 @@ class Composer extends Component {
|
|||||||
// Initialize the composer's intended height based on what the user has set
|
// Initialize the composer's intended height based on what the user has set
|
||||||
// it at previously, or otherwise the composer's default height. After that,
|
// it at previously, or otherwise the composer's default height. After that,
|
||||||
// we'll hide the composer.
|
// we'll hide the composer.
|
||||||
this.height = localStorage.getItem('composerHeight') || this.$().height();
|
this.height = localStorage.getItem('composerHeight') || defaultHeight;
|
||||||
this.$().hide().css('bottom', -this.height);
|
this.$().hide().css('bottom', -this.height);
|
||||||
|
|
||||||
// Whenever any of the inputs inside the composer are have focus, we want to
|
// Whenever any of the inputs inside the composer are have focus, we want to
|
||||||
|
@@ -73,7 +73,7 @@ export default class Post extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
config(isInitialized, context) {
|
config(isInitialized) {
|
||||||
const $actions = this.$('.Post-actions');
|
const $actions = this.$('.Post-actions');
|
||||||
const $controls = this.$('.Post-controls');
|
const $controls = this.$('.Post-controls');
|
||||||
|
|
||||||
|
@@ -196,6 +196,8 @@ class PostStream extends mixin(Component, evented) {
|
|||||||
this.visibleEnd = this.sanitizeIndex(this.visibleEnd);
|
this.visibleEnd = this.sanitizeIndex(this.visibleEnd);
|
||||||
this.viewingEnd = this.visibleEnd === this.count();
|
this.viewingEnd = this.visibleEnd === this.count();
|
||||||
|
|
||||||
|
const postIds = this.discussion.postIds();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="PostStream">
|
<div className="PostStream">
|
||||||
{this.posts().map((post, i) => {
|
{this.posts().map((post, i) => {
|
||||||
@@ -229,7 +231,7 @@ class PostStream extends mixin(Component, evented) {
|
|||||||
|
|
||||||
lastTime = time;
|
lastTime = time;
|
||||||
} else {
|
} else {
|
||||||
attrs.key = this.visibleStart + i;
|
attrs.key = 'post' + postIds[this.visibleStart + i];
|
||||||
|
|
||||||
content = PostLoading.component();
|
content = PostLoading.component();
|
||||||
}
|
}
|
||||||
@@ -277,7 +279,7 @@ class PostStream extends mixin(Component, evented) {
|
|||||||
const marginTop = this.getMarginTop();
|
const marginTop = this.getMarginTop();
|
||||||
const viewportHeight = $(window).height() - marginTop;
|
const viewportHeight = $(window).height() - marginTop;
|
||||||
const viewportTop = top + marginTop;
|
const viewportTop = top + marginTop;
|
||||||
const loadAheadDistance = 500;
|
const loadAheadDistance = 300;
|
||||||
|
|
||||||
if (this.visibleStart > 0) {
|
if (this.visibleStart > 0) {
|
||||||
const $item = this.$('.PostStream-item[data-index=' + this.visibleStart + ']');
|
const $item = this.$('.PostStream-item[data-index=' + this.visibleStart + ']');
|
||||||
|
@@ -88,7 +88,7 @@ export default class Model {
|
|||||||
// relationship data object.
|
// relationship data object.
|
||||||
for (const innerKey in data[key]) {
|
for (const innerKey in data[key]) {
|
||||||
if (data[key][innerKey] instanceof Model) {
|
if (data[key][innerKey] instanceof Model) {
|
||||||
data[key][innerKey] = {data: Model.getRelationshipData(data[key][innerKey])};
|
data[key][innerKey] = {data: Model.getIdentifier(data[key][innerKey])};
|
||||||
}
|
}
|
||||||
this.data[key][innerKey] = data[key][innerKey];
|
this.data[key][innerKey] = data[key][innerKey];
|
||||||
}
|
}
|
||||||
@@ -138,8 +138,8 @@ export default class Model {
|
|||||||
|
|
||||||
data.relationships[key] = {
|
data.relationships[key] = {
|
||||||
data: model instanceof Array
|
data: model instanceof Array
|
||||||
? model.map(Model.getRelationshipData)
|
? model.map(Model.getIdentifier)
|
||||||
: Model.getRelationshipData(model)
|
: Model.getIdentifier(model)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,13 +283,13 @@ export default class Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a relationship data object for the given model.
|
* Get a resource identifier object for the given model.
|
||||||
*
|
*
|
||||||
* @param {Model} model
|
* @param {Model} model
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
static getRelationshipData(model) {
|
static getIdentifier(model) {
|
||||||
return {
|
return {
|
||||||
type: model.data.type,
|
type: model.data.type,
|
||||||
id: model.data.id
|
id: model.data.id
|
||||||
|
@@ -87,7 +87,7 @@ export default class Store {
|
|||||||
let url = app.forum.attribute('apiUrl') + '/' + type;
|
let url = app.forum.attribute('apiUrl') + '/' + type;
|
||||||
|
|
||||||
if (id instanceof Array) {
|
if (id instanceof Array) {
|
||||||
url += '?ids[]=' + id.join('&ids[]=');
|
url += '?filter[id]=' + id.join(',');
|
||||||
} else if (typeof id === 'object') {
|
} else if (typeof id === 'object') {
|
||||||
data = id;
|
data = id;
|
||||||
} else if (id) {
|
} else if (id) {
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateAccessTokensTable extends Migration
|
class CreateAccessTokensTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('access_tokens', function (Blueprint $table) {
|
$this->schema->create('access_tokens', function (Blueprint $table) {
|
||||||
@@ -30,11 +25,6 @@ class CreateAccessTokensTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('access_tokens');
|
$this->schema->drop('access_tokens');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateApiKeysTable extends Migration
|
class CreateApiKeysTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('api_keys', function (Blueprint $table) {
|
$this->schema->create('api_keys', function (Blueprint $table) {
|
||||||
@@ -27,11 +22,6 @@ class CreateApiKeysTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('api_keys');
|
$this->schema->drop('api_keys');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateConfigTable extends Migration
|
class CreateConfigTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('config', function (Blueprint $table) {
|
$this->schema->create('config', function (Blueprint $table) {
|
||||||
@@ -28,11 +23,6 @@ class CreateConfigTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('config');
|
$this->schema->drop('config');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateDiscussionsTable extends Migration
|
class CreateDiscussionsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('discussions', function (Blueprint $table) {
|
$this->schema->create('discussions', function (Blueprint $table) {
|
||||||
@@ -40,11 +35,6 @@ class CreateDiscussionsTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('discussions');
|
$this->schema->drop('discussions');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateEmailTokensTable extends Migration
|
class CreateEmailTokensTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('email_tokens', function (Blueprint $table) {
|
$this->schema->create('email_tokens', function (Blueprint $table) {
|
||||||
@@ -30,11 +25,6 @@ class CreateEmailTokensTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('email_tokens');
|
$this->schema->drop('email_tokens');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateGroupsTable extends Migration
|
class CreateGroupsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('groups', function (Blueprint $table) {
|
$this->schema->create('groups', function (Blueprint $table) {
|
||||||
@@ -31,11 +26,6 @@ class CreateGroupsTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('groups');
|
$this->schema->drop('groups');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateNotificationsTable extends Migration
|
class CreateNotificationsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('notifications', function (Blueprint $table) {
|
$this->schema->create('notifications', function (Blueprint $table) {
|
||||||
@@ -36,11 +31,6 @@ class CreateNotificationsTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('notifications');
|
$this->schema->drop('notifications');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreatePasswordTokensTable extends Migration
|
class CreatePasswordTokensTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('password_tokens', function (Blueprint $table) {
|
$this->schema->create('password_tokens', function (Blueprint $table) {
|
||||||
@@ -29,11 +24,6 @@ class CreatePasswordTokensTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('password_tokens');
|
$this->schema->drop('password_tokens');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreatePermissionsTable extends Migration
|
class CreatePermissionsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('permissions', function (Blueprint $table) {
|
$this->schema->create('permissions', function (Blueprint $table) {
|
||||||
@@ -29,11 +24,6 @@ class CreatePermissionsTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('permissions');
|
$this->schema->drop('permissions');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreatePostsTable extends Migration
|
class CreatePostsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('posts', function (Blueprint $table) {
|
$this->schema->create('posts', function (Blueprint $table) {
|
||||||
@@ -46,11 +41,6 @@ class CreatePostsTable extends Migration
|
|||||||
$this->schema->getConnection()->statement('ALTER TABLE '.$prefix.'posts ADD FULLTEXT content (content)');
|
$this->schema->getConnection()->statement('ALTER TABLE '.$prefix.'posts ADD FULLTEXT content (content)');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('posts');
|
$this->schema->drop('posts');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateUsersDiscussionsTable extends Migration
|
class CreateUsersDiscussionsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('users_discussions', function (Blueprint $table) {
|
$this->schema->create('users_discussions', function (Blueprint $table) {
|
||||||
@@ -31,11 +26,6 @@ class CreateUsersDiscussionsTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('users_discussions');
|
$this->schema->drop('users_discussions');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateUsersGroupsTable extends Migration
|
class CreateUsersGroupsTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('users_groups', function (Blueprint $table) {
|
$this->schema->create('users_groups', function (Blueprint $table) {
|
||||||
@@ -29,11 +24,6 @@ class CreateUsersGroupsTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('users_groups');
|
$this->schema->drop('users_groups');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateUsersTable extends Migration
|
class CreateUsersTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('users', function (Blueprint $table) {
|
$this->schema->create('users', function (Blueprint $table) {
|
||||||
@@ -40,11 +35,6 @@ class CreateUsersTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('users');
|
$this->schema->drop('users');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
use Flarum\Migrations\Migration;
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateAuthTokensTable extends Migration
|
class CreateAuthTokensTable extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('auth_tokens', function (Blueprint $table) {
|
$this->schema->create('auth_tokens', function (Blueprint $table) {
|
||||||
@@ -29,11 +24,6 @@ class CreateAuthTokensTable extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->drop('auth_tokens');
|
$this->schema->drop('auth_tokens');
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Flarum\Migrations\Migration;
|
|
||||||
|
|
||||||
class AddHideToDiscussions extends Migration
|
class AddHideToDiscussions extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->table('discussions', function (Blueprint $table) {
|
$this->schema->table('discussions', function (Blueprint $table) {
|
||||||
@@ -28,11 +23,6 @@ class AddHideToDiscussions extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->table('discussions', function (Blueprint $table) {
|
$this->schema->table('discussions', function (Blueprint $table) {
|
||||||
|
@@ -8,18 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Core\Migrations;
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
|
use Flarum\Database\AbstractMigration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Flarum\Migrations\Migration;
|
|
||||||
|
|
||||||
class RenameNotificationReadTime extends Migration
|
class RenameNotificationReadTime extends AbstractMigration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->table('users', function (Blueprint $table) {
|
$this->schema->table('users', function (Blueprint $table) {
|
||||||
@@ -27,11 +22,6 @@ class RenameNotificationReadTime extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
$this->schema->table('users', function (Blueprint $table) {
|
$this->schema->table('users', function (Blueprint $table) {
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Core\Migration;
|
||||||
|
|
||||||
|
use Flarum\Database\AbstractMigration;
|
||||||
|
|
||||||
|
class RenameConfigToSettings extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->schema->rename('config', 'settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->schema->rename('settings', 'config');
|
||||||
|
}
|
||||||
|
}
|
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Admin\Actions;
|
|
||||||
|
|
||||||
use Flarum\Support\ClientAction as BaseClientAction;
|
|
||||||
use Flarum\Support\ClientView;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
||||||
use Flarum\Core\Groups\Permission;
|
|
||||||
use Flarum\Api\Client;
|
|
||||||
use Flarum\Core\Settings\SettingsRepository;
|
|
||||||
use Flarum\Locale\LocaleManager;
|
|
||||||
use Flarum\Events\UnserializeConfig;
|
|
||||||
|
|
||||||
class ClientAction extends BaseClientAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $clientName = 'admin';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $translationKeys = ['core.admin'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function __construct(Client $apiClient, LocaleManager $locales, SettingsRepository $settings)
|
|
||||||
{
|
|
||||||
parent::__construct($apiClient, $locales, $settings);
|
|
||||||
|
|
||||||
$this->layout = __DIR__.'/../../../views/admin.blade.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function render(Request $request, array $routeParams = [])
|
|
||||||
{
|
|
||||||
$view = parent::render($request, $routeParams);
|
|
||||||
|
|
||||||
$config = $this->settings->all();
|
|
||||||
|
|
||||||
event(new UnserializeConfig($config));
|
|
||||||
|
|
||||||
$view->setVariable('config', $config);
|
|
||||||
$view->setVariable('permissions', Permission::map());
|
|
||||||
$view->setVariable('extensions', app('flarum.extensions')->getInfo());
|
|
||||||
|
|
||||||
return $view;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -10,64 +10,83 @@
|
|||||||
|
|
||||||
namespace Flarum\Admin;
|
namespace Flarum\Admin;
|
||||||
|
|
||||||
|
use Flarum\Event\SettingWasSet;
|
||||||
|
use Flarum\Event\ExtensionWasDisabled;
|
||||||
|
use Flarum\Event\ExtensionWasEnabled;
|
||||||
use Flarum\Http\RouteCollection;
|
use Flarum\Http\RouteCollection;
|
||||||
use Flarum\Admin\UrlGenerator;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Flarum\Http\GenerateRouteHandlerTrait;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Zend\Diactoros\Response\RedirectResponse;
|
use Zend\Diactoros\Response\RedirectResponse;
|
||||||
|
|
||||||
class AdminServiceProvider extends ServiceProvider
|
class AdminServiceProvider extends AbstractServiceProvider
|
||||||
{
|
{
|
||||||
|
use GenerateRouteHandlerTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the service provider.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->singleton(
|
$this->app->singleton(UrlGenerator::class, function () {
|
||||||
UrlGenerator::class,
|
return new UrlGenerator($this->app, $this->app->make('flarum.admin.routes'));
|
||||||
function () {
|
});
|
||||||
return new UrlGenerator($this->app->make('flarum.admin.routes'));
|
|
||||||
}
|
$this->app->singleton('flarum.admin.routes', function () {
|
||||||
);
|
return $this->getRoutes();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap the application events.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$root = __DIR__.'/../..';
|
$this->flushAssetsWhenThemeChanged();
|
||||||
|
|
||||||
$this->loadViewsFrom($root.'/views', 'flarum.admin');
|
$this->flushAssetsWhenExtensionsChanged();
|
||||||
|
|
||||||
$this->publishes([
|
|
||||||
$root.'/public/fonts' => public_path('assets/fonts')
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->routes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function routes()
|
/**
|
||||||
|
* Register the admin client routes.
|
||||||
|
*
|
||||||
|
* @return RouteCollection
|
||||||
|
*/
|
||||||
|
protected function getRoutes()
|
||||||
{
|
{
|
||||||
$this->app->instance('flarum.admin.routes', $routes = new RouteCollection);
|
$routes = new RouteCollection;
|
||||||
|
|
||||||
|
$toController = $this->getHandlerGenerator($this->app);
|
||||||
|
|
||||||
$routes->get(
|
$routes->get(
|
||||||
'/',
|
'/',
|
||||||
'index',
|
'index',
|
||||||
$this->action('Flarum\Admin\Actions\ClientAction')
|
$toController('Flarum\Admin\Controller\ClientController')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function action($class)
|
protected function flushAssetsWhenThemeChanged()
|
||||||
{
|
{
|
||||||
return function (ServerRequestInterface $httpRequest, $routeParams) use ($class) {
|
$this->app->make('events')->listen(SettingWasSet::class, function (SettingWasSet $event) {
|
||||||
$action = $this->app->make($class);
|
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
|
||||||
|
$this->flushAssets();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return $action->handle($httpRequest, $routeParams);
|
protected function flushAssetsWhenExtensionsChanged()
|
||||||
};
|
{
|
||||||
|
$events = $this->app->make('events');
|
||||||
|
|
||||||
|
$events->listen(ExtensionWasEnabled::class, [$this, 'flushAssets']);
|
||||||
|
$events->listen(ExtensionWasDisabled::class, [$this, 'flushAssets']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function flushAssets()
|
||||||
|
{
|
||||||
|
$action = $this->app->make('Flarum\Admin\Controller\ClientController');
|
||||||
|
$action->flushAssets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
77
framework/core/src/Admin/Controller/ClientController.php
Normal file
77
framework/core/src/Admin/Controller/ClientController.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Admin\Controller;
|
||||||
|
|
||||||
|
use Flarum\Foundation\Application;
|
||||||
|
use Flarum\Http\Controller\AbstractClientController as BaseClientController;
|
||||||
|
use Flarum\Extension\ExtensionManager;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
use Flarum\Core\Permission;
|
||||||
|
use Flarum\Api\Client;
|
||||||
|
use Flarum\Settings\SettingsRepository;
|
||||||
|
use Flarum\Locale\LocaleManager;
|
||||||
|
use Flarum\Event\PrepareUnserializedSettings;
|
||||||
|
|
||||||
|
class ClientController extends BaseClientController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $clientName = 'admin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $translationKeys = ['core.admin'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ExtensionManager
|
||||||
|
*/
|
||||||
|
protected $extensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
Application $app,
|
||||||
|
Client $apiClient,
|
||||||
|
LocaleManager $locales,
|
||||||
|
SettingsRepository $settings,
|
||||||
|
Dispatcher $events,
|
||||||
|
ExtensionManager $extensions
|
||||||
|
) {
|
||||||
|
BaseClientController::__construct($app, $apiClient, $locales, $settings, $events);
|
||||||
|
|
||||||
|
$this->layout = __DIR__.'/../../../views/admin.blade.php';
|
||||||
|
$this->extensions = $extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function render(Request $request)
|
||||||
|
{
|
||||||
|
$view = BaseClientController::render($request);
|
||||||
|
|
||||||
|
$settings = $this->settings->all();
|
||||||
|
|
||||||
|
$this->events->fire(
|
||||||
|
new PrepareUnserializedSettings($settings)
|
||||||
|
);
|
||||||
|
|
||||||
|
$view->setVariable('settings', $settings);
|
||||||
|
$view->setVariable('permissions', Permission::map());
|
||||||
|
$view->setVariable('extensions', $this->extensions->getInfo());
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
}
|
@@ -10,34 +10,39 @@
|
|||||||
|
|
||||||
namespace Flarum\Admin\Middleware;
|
namespace Flarum\Admin\Middleware;
|
||||||
|
|
||||||
|
use Flarum\Core\Access\Gate;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Flarum\Forum\Middleware\LoginWithCookie;
|
use Flarum\Core\Exception\PermissionDeniedException;
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
use Zend\Stratigility\MiddlewareInterface;
|
||||||
|
|
||||||
class LoginWithCookieAndCheckAdmin extends LoginWithCookie
|
class RequireAdministrateAbility implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Gate
|
||||||
|
*/
|
||||||
|
protected $gate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Gate $gate
|
||||||
|
*/
|
||||||
|
public function __construct(Gate $gate)
|
||||||
|
{
|
||||||
|
$this->gate = $gate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function __invoke(Request $request, Response $response, callable $out = null)
|
public function __invoke(Request $request, Response $response, callable $out = null)
|
||||||
{
|
{
|
||||||
if (! $this->logIn($request)) {
|
$actor = $request->getAttribute('actor');
|
||||||
|
|
||||||
|
if (! $this->gate->forUser($actor)->allows('administrate')) {
|
||||||
throw new PermissionDeniedException;
|
throw new PermissionDeniedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out ? $out($request, $response) : $response;
|
return $out ? $out($request, $response) : $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getToken(Request $request)
|
|
||||||
{
|
|
||||||
$token = parent::getToken($request);
|
|
||||||
|
|
||||||
if ($token && $token->user && $token->user->isAdmin()) {
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
49
framework/core/src/Admin/Server.php
Normal file
49
framework/core/src/Admin/Server.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Admin;
|
||||||
|
|
||||||
|
use Flarum\Foundation\Application;
|
||||||
|
use Flarum\Http\AbstractServer;
|
||||||
|
use Zend\Stratigility\MiddlewarePipe;
|
||||||
|
use Flarum\Http\Middleware\HandleErrors;
|
||||||
|
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
|
||||||
|
|
||||||
|
class Server extends AbstractServer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function getMiddleware(Application $app)
|
||||||
|
{
|
||||||
|
$pipe = new MiddlewarePipe;
|
||||||
|
|
||||||
|
if ($app->isInstalled()) {
|
||||||
|
$app->register('Flarum\Admin\AdminServiceProvider');
|
||||||
|
|
||||||
|
$adminPath = parse_url($app->url('admin'), PHP_URL_PATH);
|
||||||
|
$routes = $app->make('flarum.admin.routes');
|
||||||
|
|
||||||
|
$pipe->pipe($adminPath, $app->make('Flarum\Http\Middleware\AuthenticateWithCookie'));
|
||||||
|
$pipe->pipe($adminPath, $app->make('Flarum\Http\Middleware\ParseJsonBody'));
|
||||||
|
$pipe->pipe($adminPath, $app->make('Flarum\Admin\Middleware\RequireAdministrateAbility'));
|
||||||
|
$pipe->pipe($adminPath, $app->make('Flarum\Http\Middleware\DispatchRoute', compact('routes')));
|
||||||
|
|
||||||
|
if ($app->inDebugMode()) {
|
||||||
|
$pipe->pipe(new WhoopsMiddleware);
|
||||||
|
} else {
|
||||||
|
$pipe->pipe(new HandleErrors(__DIR__.'/../../error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pipe;
|
||||||
|
}
|
||||||
|
}
|
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
namespace Flarum\Admin;
|
namespace Flarum\Admin;
|
||||||
|
|
||||||
use Flarum\Http\UrlGenerator as BaseUrlGenerator;
|
use Flarum\Http\AbstractUrlGenerator;
|
||||||
|
|
||||||
class UrlGenerator extends BaseUrlGenerator
|
class UrlGenerator extends AbstractUrlGenerator
|
||||||
{
|
{
|
||||||
protected $prefix = 'admin';
|
protected $path = 'admin';
|
||||||
}
|
}
|
||||||
|
@@ -10,14 +10,17 @@
|
|||||||
|
|
||||||
namespace Flarum\Api;
|
namespace Flarum\Api;
|
||||||
|
|
||||||
use Flarum\Core\Model;
|
use Flarum\Database\AbstractModel;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo document database columns with @property
|
* @property string $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property \Carbon\Carbon $created_at
|
||||||
|
* @property \Carbon\Carbon $expires_at
|
||||||
|
* @property \Flarum\Core\User|null $user
|
||||||
*/
|
*/
|
||||||
class AccessToken extends Model
|
class AccessToken extends AbstractModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -72,6 +75,6 @@ class AccessToken extends Model
|
|||||||
*/
|
*/
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('Flarum\Core\Users\User');
|
return $this->belongsTo('Flarum\Core\User');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Flarum\Core\Settings\SettingsRepository;
|
|
||||||
use Flarum\Core\Groups\Permission;
|
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
|
||||||
use Flarum\Events\SerializeConfig;
|
|
||||||
use Zend\Diactoros\Response\EmptyResponse;
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class ConfigAction implements Action
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var SettingsRepository
|
|
||||||
*/
|
|
||||||
protected $settings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SettingsRepository $settings
|
|
||||||
*/
|
|
||||||
public function __construct(SettingsRepository $settings)
|
|
||||||
{
|
|
||||||
$this->settings = $settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function handle(Request $request, array $routeParams = [])
|
|
||||||
{
|
|
||||||
if (! $request->actor->isAdmin()) {
|
|
||||||
throw new PermissionDeniedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$config = $request->get('config', []);
|
|
||||||
|
|
||||||
// TODO: throw HTTP status 400 or 422
|
|
||||||
if (! is_array($config)) {
|
|
||||||
throw new Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($config as $k => $v) {
|
|
||||||
event($event = new SerializeConfig($k, $v));
|
|
||||||
|
|
||||||
$this->settings->set($k, $v);
|
|
||||||
|
|
||||||
if (strpos($k, 'theme_') === 0 || $k === 'custom_less') {
|
|
||||||
$forum = app('Flarum\Forum\Actions\ClientAction');
|
|
||||||
$forum->flushAssets();
|
|
||||||
|
|
||||||
$admin = app('Flarum\Admin\Actions\ClientAction');
|
|
||||||
$admin->flushAssets();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmptyResponse(204);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
abstract class CreateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Set a 201 Created status code on the response.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
|
||||||
*/
|
|
||||||
public function respond(Request $request)
|
|
||||||
{
|
|
||||||
return parent::respond($request)->withStatus(201);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the newly created resource to be serialized and assigned to the response document.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->create($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the resource.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @return \Flarum\Core\Model
|
|
||||||
*/
|
|
||||||
abstract protected function create(JsonApiRequest $request);
|
|
||||||
}
|
|
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Discussions;
|
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Commands\StartDiscussion;
|
|
||||||
use Flarum\Core\Discussions\Commands\ReadDiscussion;
|
|
||||||
use Flarum\Api\Actions\CreateAction as BaseCreateAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
|
|
||||||
class CreateAction extends BaseCreateAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The command bus.
|
|
||||||
*
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'posts' => true,
|
|
||||||
'startUser' => true,
|
|
||||||
'lastUser' => true,
|
|
||||||
'startPost' => true,
|
|
||||||
'lastPost' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate the action.
|
|
||||||
*
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a discussion according to input from the API request.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @return \Flarum\Core\Discussions\Discussion
|
|
||||||
*/
|
|
||||||
protected function create(JsonApiRequest $request)
|
|
||||||
{
|
|
||||||
$actor = $request->actor;
|
|
||||||
|
|
||||||
$discussion = $this->bus->dispatch(
|
|
||||||
new StartDiscussion($actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
|
|
||||||
// After creating the discussion, we assume that the user has seen all
|
|
||||||
// of the posts in the discussion; thus, we will mark the discussion
|
|
||||||
// as read if they are logged in.
|
|
||||||
if ($actor->exists) {
|
|
||||||
$this->bus->dispatch(
|
|
||||||
new ReadDiscussion($discussion->id, $actor, 1)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $discussion;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Discussions;
|
|
||||||
|
|
||||||
use Flarum\Core\Search\SearchCriteria;
|
|
||||||
use Flarum\Core\Discussions\Search\DiscussionSearcher;
|
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Flarum\Api\UrlGenerator;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class IndexAction extends SerializeCollectionAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var DiscussionSearcher
|
|
||||||
*/
|
|
||||||
protected $searcher;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var UrlGenerator
|
|
||||||
*/
|
|
||||||
protected $url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'startUser' => true,
|
|
||||||
'lastUser' => true,
|
|
||||||
'startPost' => false,
|
|
||||||
'lastPost' => false,
|
|
||||||
'relevantPosts' => true,
|
|
||||||
'relevantPosts.discussion' => true,
|
|
||||||
'relevantPosts.user' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = ['lastTime', 'commentsCount', 'startTime'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DiscussionSearcher $searcher
|
|
||||||
* @param UrlGenerator $url
|
|
||||||
*/
|
|
||||||
public function __construct(DiscussionSearcher $searcher, UrlGenerator $url)
|
|
||||||
{
|
|
||||||
$this->searcher = $searcher;
|
|
||||||
$this->url = $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the discussion results, ready to be serialized and assigned to the
|
|
||||||
* document response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$criteria = new SearchCriteria(
|
|
||||||
$request->actor,
|
|
||||||
$request->get('filter.q'),
|
|
||||||
$request->sort
|
|
||||||
);
|
|
||||||
|
|
||||||
$load = array_merge($request->include, ['state']);
|
|
||||||
|
|
||||||
$results = $this->searcher->search($criteria, $request->limit, $request->offset, $load);
|
|
||||||
|
|
||||||
// TODO: add query params (filter, sort, include) to the pagination URLs
|
|
||||||
$this->addPaginationLinks(
|
|
||||||
$document,
|
|
||||||
$request,
|
|
||||||
$request->http ? $this->url->toRoute('discussions.index') : '',
|
|
||||||
$results->areMoreResults()
|
|
||||||
);
|
|
||||||
|
|
||||||
return $results->getResults();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,117 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Discussions;
|
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionRepository;
|
|
||||||
use Flarum\Core\Posts\PostRepository;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\Actions\Posts\GetsPosts;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class ShowAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
use GetsPosts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Flarum\Core\Discussions\DiscussionRepository
|
|
||||||
*/
|
|
||||||
protected $discussions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'startUser' => false,
|
|
||||||
'lastUser' => false,
|
|
||||||
'startPost' => false,
|
|
||||||
'lastPost' => false,
|
|
||||||
'posts' => true,
|
|
||||||
'posts.user' => true,
|
|
||||||
'posts.user.groups' => true,
|
|
||||||
'posts.editUser' => true,
|
|
||||||
'posts.hideUser' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = ['posts', 'posts.discussion'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = ['time'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort = ['time' => 'asc'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate the action.
|
|
||||||
*
|
|
||||||
* @param DiscussionRepository $discussions
|
|
||||||
* @param PostRepository $posts
|
|
||||||
*/
|
|
||||||
public function __construct(DiscussionRepository $discussions, PostRepository $posts)
|
|
||||||
{
|
|
||||||
$this->discussions = $discussions;
|
|
||||||
$this->posts = $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a single discussion, ready to be serialized and assigned to the
|
|
||||||
* JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Discussions\Discussion
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$discussionId = $request->get('id');
|
|
||||||
$actor = $request->actor;
|
|
||||||
|
|
||||||
$discussion = $this->discussions->findOrFail($discussionId, $actor);
|
|
||||||
|
|
||||||
$discussion->posts_ids = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
|
|
||||||
|
|
||||||
// TODO: Refactor to be simpler, and get posts straight from the
|
|
||||||
// discussion's postsVisibleTo relation method.
|
|
||||||
if (in_array('posts', $request->include)) {
|
|
||||||
$prefixLength = strlen($prefix = 'posts.');
|
|
||||||
|
|
||||||
$postRelations = array_filter(array_map(function ($relation) use ($prefix, $prefixLength) {
|
|
||||||
return substr($relation, 0, $prefixLength) === $prefix ? substr($relation, $prefixLength) : false;
|
|
||||||
}, $request->include));
|
|
||||||
|
|
||||||
$discussion->posts = $this->getPosts($request, ['discussion_id' => $discussion->id])->load($postRelations);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $discussion;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,111 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Discussions;
|
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Commands\EditDiscussion;
|
|
||||||
use Flarum\Core\Discussions\Commands\ReadDiscussion;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UpdateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a discussion according to input from the API request, and return
|
|
||||||
* it ready to be serialized and assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Discussions\Discussion
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$actor = $request->actor;
|
|
||||||
$discussionId = $request->get('id');
|
|
||||||
$data = $request->get('data');
|
|
||||||
|
|
||||||
$discussion = $this->bus->dispatch(
|
|
||||||
new EditDiscussion($discussionId, $actor, $data)
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: Refactor the ReadDiscussion (state) command into EditDiscussion?
|
|
||||||
// That's what extensions will do anyway.
|
|
||||||
if ($readNumber = array_get($data, 'attributes.readNumber')) {
|
|
||||||
$state = $this->bus->dispatch(
|
|
||||||
new ReadDiscussion($discussionId, $actor, $readNumber)
|
|
||||||
);
|
|
||||||
|
|
||||||
$discussion = $state->discussion;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($posts = $discussion->getModifiedPosts()) {
|
|
||||||
$discussion->posts_ids = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
|
|
||||||
|
|
||||||
$discussion->posts = array_filter($posts, function ($post) {
|
|
||||||
return $post->exists;
|
|
||||||
});
|
|
||||||
|
|
||||||
$request->include = array_merge($request->include, ['posts']);
|
|
||||||
$request->link = array_merge($request->include, ['posts', 'posts.discussion', 'posts.user']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $discussion;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Extensions;
|
|
||||||
|
|
||||||
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
|
||||||
use Flarum\Support\ExtensionManager;
|
|
||||||
|
|
||||||
class DeleteAction extends BaseDeleteAction
|
|
||||||
{
|
|
||||||
protected $extensions;
|
|
||||||
|
|
||||||
public function __construct(ExtensionManager $extensions)
|
|
||||||
{
|
|
||||||
$this->extensions = $extensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function delete(Request $request)
|
|
||||||
{
|
|
||||||
if (! $request->actor->isAdmin()) {
|
|
||||||
throw new PermissionDeniedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$name = $request->get('name');
|
|
||||||
|
|
||||||
$this->extensions->disable($name);
|
|
||||||
$this->extensions->uninstall($name);
|
|
||||||
|
|
||||||
app('flarum.formatter')->flush();
|
|
||||||
|
|
||||||
$forum = app('Flarum\Forum\Actions\ClientAction');
|
|
||||||
$forum->flushAssets();
|
|
||||||
|
|
||||||
$admin = app('Flarum\Admin\Actions\ClientAction');
|
|
||||||
$admin->flushAssets();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Extensions;
|
|
||||||
|
|
||||||
use Flarum\Api\Actions\Action;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
|
||||||
use Flarum\Support\ExtensionManager;
|
|
||||||
|
|
||||||
class UpdateAction implements Action
|
|
||||||
{
|
|
||||||
protected $extensions;
|
|
||||||
|
|
||||||
public function __construct(ExtensionManager $extensions)
|
|
||||||
{
|
|
||||||
$this->extensions = $extensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Request $request)
|
|
||||||
{
|
|
||||||
if (! $request->actor->isAdmin()) {
|
|
||||||
throw new PermissionDeniedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$enabled = $request->get('enabled');
|
|
||||||
$name = $request->get('name');
|
|
||||||
|
|
||||||
if ($enabled === true) {
|
|
||||||
$this->extensions->enable($name);
|
|
||||||
} elseif ($enabled === false) {
|
|
||||||
$this->extensions->disable($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
app('flarum.formatter')->flush();
|
|
||||||
|
|
||||||
$forum = app('Flarum\Forum\Actions\ClientAction');
|
|
||||||
$forum->flushAssets();
|
|
||||||
|
|
||||||
$admin = app('Flarum\Admin\Actions\ClientAction');
|
|
||||||
$admin->flushAssets();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Flarum\Core\Users\UserRepository;
|
|
||||||
use Flarum\Core\Users\Commands\RequestPasswordReset;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Zend\Diactoros\Response\EmptyResponse;
|
|
||||||
|
|
||||||
class ForgotAction implements Action
|
|
||||||
{
|
|
||||||
protected $users;
|
|
||||||
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
public function __construct(UserRepository $users, Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->users = $users;
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log in and return a token.
|
|
||||||
*
|
|
||||||
* @param \Flarum\Api\Request $request
|
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
|
||||||
*/
|
|
||||||
public function handle(Request $request)
|
|
||||||
{
|
|
||||||
$email = $request->get('email');
|
|
||||||
|
|
||||||
$this->bus->dispatch(
|
|
||||||
new RequestPasswordReset($email)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new EmptyResponse();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Forum;
|
|
||||||
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Flarum\Core\Groups\Group;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class ShowAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\ForumSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'groups' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the forum, ready to be serialized and assigned to the JsonApi
|
|
||||||
* response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Forum
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$forum = app('flarum.forum');
|
|
||||||
|
|
||||||
$forum->groups = Group::whereVisibleTo($request->actor)->get();
|
|
||||||
|
|
||||||
return $forum;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Forum;
|
|
||||||
|
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
|
||||||
use Flarum\Core\Settings\SettingsRepository;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UpdateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\ForumSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var SettingsRepository
|
|
||||||
*/
|
|
||||||
protected $settings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SettingsRepository $settings
|
|
||||||
*/
|
|
||||||
public function __construct(SettingsRepository $settings)
|
|
||||||
{
|
|
||||||
$this->settings = $settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the forum, ready to be serialized and assigned to the JsonApi
|
|
||||||
* response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Forum
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
if (! $request->actor->isAdmin()) {
|
|
||||||
throw new PermissionDeniedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$config = $request->get('data.attributes.config');
|
|
||||||
|
|
||||||
if (is_array($config)) {
|
|
||||||
foreach ($config as $k => $v) {
|
|
||||||
$this->settings->set($k, $v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return app('flarum.forum');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Groups;
|
|
||||||
|
|
||||||
use Flarum\Core\Groups\Commands\CreateGroup;
|
|
||||||
use Flarum\Api\Actions\CreateAction as BaseCreateAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
|
|
||||||
class CreateAction extends BaseCreateAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\GroupSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a group according to input from the API request.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @return \Flarum\Core\Groups\Group
|
|
||||||
*/
|
|
||||||
protected function create(JsonApiRequest $request)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new CreateGroup($request->actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Groups;
|
|
||||||
|
|
||||||
use Flarum\Core\Groups\Group;
|
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class IndexAction extends SerializeCollectionAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\GroupSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the groups, ready to be serialized and assigned to the document
|
|
||||||
* response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return Group::all();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Groups;
|
|
||||||
|
|
||||||
use Flarum\Core\Groups\Commands\EditGroup;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UpdateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\GroupSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a group according to input from the API request, and return it
|
|
||||||
* ready to be serialized and assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Groups\Group
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new EditGroup($request->get('id'), $request->actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Notifications;
|
|
||||||
|
|
||||||
use Flarum\Core\Notifications\NotificationRepository;
|
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class IndexAction extends SerializeCollectionAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var NotificationRepository
|
|
||||||
*/
|
|
||||||
protected $notifications;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\NotificationSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'sender' => true,
|
|
||||||
'subject' => true,
|
|
||||||
'subject.discussion' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate the action.
|
|
||||||
*
|
|
||||||
* @param NotificationRepository $notifications
|
|
||||||
*/
|
|
||||||
public function __construct(NotificationRepository $notifications)
|
|
||||||
{
|
|
||||||
$this->notifications = $notifications;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the notification results, ready to be serialized and assigned to the
|
|
||||||
* document response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
* @throws PermissionDeniedException
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$actor = $request->actor;
|
|
||||||
|
|
||||||
if ($actor->isGuest()) {
|
|
||||||
throw new PermissionDeniedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$actor->markNotificationsAsRead()->save();
|
|
||||||
|
|
||||||
return $this->notifications->findByUser($actor, $request->limit, $request->offset)
|
|
||||||
->load($request->include);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Notifications;
|
|
||||||
|
|
||||||
use Flarum\Core\Notifications\Commands\ReadNotification;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UpdateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\NotificationSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark a notification as read, and return it ready to be serialized and
|
|
||||||
* assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Notifications\Notification
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new ReadNotification($request->get('id'), $request->actor)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Posts;
|
|
||||||
|
|
||||||
use Flarum\Core\Posts\Commands\PostReply;
|
|
||||||
use Flarum\Core\Discussions\Commands\ReadDiscussion;
|
|
||||||
use Flarum\Api\Actions\CreateAction as BaseCreateAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
|
|
||||||
class CreateAction extends BaseCreateAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'user' => true,
|
|
||||||
'discussion' => true,
|
|
||||||
'discussion.lastUser' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = ['discussion.posts'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate the action.
|
|
||||||
*
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reply to a discussion according to input from the API request.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @return \Flarum\Core\Posts\Post
|
|
||||||
*/
|
|
||||||
protected function create(JsonApiRequest $request)
|
|
||||||
{
|
|
||||||
$actor = $request->actor;
|
|
||||||
$discussionId = $request->get('data.relationships.discussion.data.id');
|
|
||||||
|
|
||||||
$post = $this->bus->dispatch(
|
|
||||||
new PostReply($discussionId, $actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
|
|
||||||
// After replying, we assume that the user has seen all of the posts
|
|
||||||
// in the discussion; thus, we will mark the discussion as read if
|
|
||||||
// they are logged in.
|
|
||||||
if ($actor->exists) {
|
|
||||||
$this->bus->dispatch(
|
|
||||||
new ReadDiscussion($discussionId, $actor, $post->number)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$discussion = $post->discussion;
|
|
||||||
$discussion->posts_ids = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
|
|
||||||
|
|
||||||
return $post;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Posts;
|
|
||||||
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
|
|
||||||
trait GetsPosts
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var \Flarum\Core\Posts\PostRepository
|
|
||||||
*/
|
|
||||||
protected $posts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param array $where
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
protected function getPosts(JsonApiRequest $request, array $where)
|
|
||||||
{
|
|
||||||
$actor = $request->actor;
|
|
||||||
|
|
||||||
if (isset($where['discussion_id']) && ($near = $request->get('page.near')) > 1) {
|
|
||||||
$offset = $this->posts->getIndexForNumber($where['discussion_id'], $near, $actor);
|
|
||||||
$offset = max(0, $offset - $request->limit / 2);
|
|
||||||
} else {
|
|
||||||
$offset = $request->offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->posts->findWhere(
|
|
||||||
$where,
|
|
||||||
$actor,
|
|
||||||
$request->sort,
|
|
||||||
$request->limit,
|
|
||||||
$offset
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,105 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Posts;
|
|
||||||
|
|
||||||
use Flarum\Core\Posts\PostRepository;
|
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class IndexAction extends SerializeCollectionAction
|
|
||||||
{
|
|
||||||
use GetsPosts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'user' => true,
|
|
||||||
'user.groups' => true,
|
|
||||||
'editUser' => true,
|
|
||||||
'hideUser' => true,
|
|
||||||
'discussion' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = ['time'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PostRepository $posts
|
|
||||||
*/
|
|
||||||
public function __construct(PostRepository $posts)
|
|
||||||
{
|
|
||||||
$this->posts = $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the post results, ready to be serialized and assigned to the
|
|
||||||
* document response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$postIds = (array) $request->get('ids');
|
|
||||||
$actor = $request->actor;
|
|
||||||
|
|
||||||
if (count($postIds)) {
|
|
||||||
$posts = $this->posts->findByIds($postIds, $actor);
|
|
||||||
} else {
|
|
||||||
$where = [];
|
|
||||||
if ($discussionId = $request->get('filter.discussion')) {
|
|
||||||
$where['discussion_id'] = $discussionId;
|
|
||||||
}
|
|
||||||
if ($number = $request->get('filter.number')) {
|
|
||||||
$where['number'] = $number;
|
|
||||||
}
|
|
||||||
if ($userId = $request->get('filter.user')) {
|
|
||||||
$where['user_id'] = $userId;
|
|
||||||
}
|
|
||||||
if ($type = $request->get('filter.type')) {
|
|
||||||
$where['type'] = $type;
|
|
||||||
}
|
|
||||||
$posts = $this->getPosts($request, $where);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $posts;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Posts;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use Flarum\Core\Posts\PostRepository;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class ShowAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var PostRepository
|
|
||||||
*/
|
|
||||||
protected $posts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'user' => true,
|
|
||||||
'user.groups' => true,
|
|
||||||
'editUser' => true,
|
|
||||||
'hideUser' => true,
|
|
||||||
'discussion' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PostRepository $posts
|
|
||||||
*/
|
|
||||||
public function __construct(PostRepository $posts)
|
|
||||||
{
|
|
||||||
$this->posts = $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a single post, ready to be serialized and assigned to the JsonApi
|
|
||||||
* response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Posts\Post
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->posts->findOrFail($request->get('id'), $request->actor);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Posts;
|
|
||||||
|
|
||||||
use Flarum\Core\Posts\Commands\EditPost;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UpdateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'editUser' => true,
|
|
||||||
'discussion' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a post according to input from the API request, and return it
|
|
||||||
* ready to be serialized and assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new EditPost($request->get('id'), $request->actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,210 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Flarum\Events\BuildApiAction;
|
|
||||||
use Flarum\Events\WillSerializeData;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Criteria;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
use Tobscure\JsonApi\SerializerInterface;
|
|
||||||
use Zend\Diactoros\Response\JsonResponse;
|
|
||||||
|
|
||||||
abstract class SerializeAction implements Action
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name of the serializer class to output results with.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $serializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The relationships that are available to be included (keys), and which
|
|
||||||
* ones are included by default (boolean values).
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $include = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The relationships that are linked by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum number of records that can be requested.
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of records included by default.
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The fields that are available to be sorted by.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default sort field and order to user.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle an API request and return an API response.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function handle(Request $request)
|
|
||||||
{
|
|
||||||
$request = $this->buildJsonApiRequest($request);
|
|
||||||
$document = new Document();
|
|
||||||
|
|
||||||
$data = $this->data($request, $document);
|
|
||||||
|
|
||||||
event(new WillSerializeData($this, $data, $request));
|
|
||||||
|
|
||||||
$serializer = new $this->serializer($request->actor, $request->include, $request->link);
|
|
||||||
|
|
||||||
$document->setData($this->serialize($serializer, $data));
|
|
||||||
|
|
||||||
return new JsonResponse($document, 200, ['content-type' => 'application/vnd.api+json']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the data to be serialized and assigned to the response document.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
abstract protected function data(JsonApiRequest $request, Document $document);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialize the data as appropriate.
|
|
||||||
*
|
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
* @param array $data
|
|
||||||
* @return \Tobscure\JsonApi\Elements\ElementInterface
|
|
||||||
*/
|
|
||||||
abstract protected function serialize(SerializerInterface $serializer, $data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract parameters from the request input and assign them to the
|
|
||||||
* request, restricted by the action's specifications.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonApiRequest
|
|
||||||
*/
|
|
||||||
protected function buildJsonApiRequest(Request $request)
|
|
||||||
{
|
|
||||||
$request = new JsonApiRequest($request->input, $request->actor, $request->http);
|
|
||||||
|
|
||||||
$criteria = new Criteria($request->input);
|
|
||||||
|
|
||||||
event(new BuildApiAction($this));
|
|
||||||
|
|
||||||
$request->include = $this->sanitizeInclude($criteria->getInclude());
|
|
||||||
$request->sort = $this->sanitizeSort($criteria->getSort());
|
|
||||||
$request->offset = $criteria->getOffset();
|
|
||||||
$request->limit = $this->sanitizeLimit($criteria->getLimit());
|
|
||||||
$request->link = $this->link;
|
|
||||||
|
|
||||||
return $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sanitize an array of included relationships according to the action's
|
|
||||||
* configuration.
|
|
||||||
*
|
|
||||||
* @param array $include
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function sanitizeInclude(array $include)
|
|
||||||
{
|
|
||||||
return array_intersect($include, array_keys($this->include)) ?: array_keys(array_filter($this->include));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sanitize an array of sort criteria according to the action's
|
|
||||||
* configuration.
|
|
||||||
*
|
|
||||||
* @param array $sort
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function sanitizeSort(array $sort)
|
|
||||||
{
|
|
||||||
return array_intersect_key($sort, array_flip($this->sortFields)) ?: $this->sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sanitize a limit according to the action's configuration.
|
|
||||||
*
|
|
||||||
* @param int $limit
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
protected function sanitizeLimit($limit)
|
|
||||||
{
|
|
||||||
return min($limit, $this->limitMax) ?: $this->limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add pagination links to a JSON-API response, based on input parameters
|
|
||||||
* and the default parameters of this action.
|
|
||||||
*
|
|
||||||
* @param Document $document
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param string $url The base URL to build pagination links with.
|
|
||||||
* @param integer|boolean $total The total number of results (used to build
|
|
||||||
* a 'last' link), or just true if there are more results but how many
|
|
||||||
* is unknown ('last' link is ommitted).
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function addPaginationLinks(Document $document, JsonApiRequest $request, $url, $total = true)
|
|
||||||
{
|
|
||||||
$input = [];
|
|
||||||
if ($request->limit != $this->limit) {
|
|
||||||
array_set($input, 'page.limit', $request->limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
array_set($input, 'page.offset', 0);
|
|
||||||
$document->addLink('first', $url.'?'.http_build_query($input));
|
|
||||||
|
|
||||||
if ($request->offset > 0) {
|
|
||||||
array_set($input, 'page.offset', max(0, $request->offset - $request->limit));
|
|
||||||
$document->addLink('prev', $url.'?'.http_build_query($input));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($total === true || $request->offset + $request->limit < $total) {
|
|
||||||
array_set($input, 'page.offset', $request->offset + $request->limit);
|
|
||||||
$document->addLink('next', $url.'?'.http_build_query($input));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($total && $total !== true) {
|
|
||||||
array_set($input, 'page.offset', $total - $request->limit);
|
|
||||||
$document->addLink('last', $url.'?'.http_build_query($input));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Tobscure\JsonApi\SerializerInterface;
|
|
||||||
|
|
||||||
abstract class SerializeCollectionAction extends SerializeAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Serialize the data as appropriate.
|
|
||||||
*
|
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
* @param array $data
|
|
||||||
* @return \Tobscure\JsonApi\Elements\Collection
|
|
||||||
*/
|
|
||||||
protected function serialize(SerializerInterface $serializer, $data)
|
|
||||||
{
|
|
||||||
return $serializer->collection($data);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Tobscure\JsonApi\SerializerInterface;
|
|
||||||
|
|
||||||
abstract class SerializeResourceAction extends SerializeAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Serialize the data as appropriate.
|
|
||||||
*
|
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
* @param array $data
|
|
||||||
* @return \Tobscure\JsonApi\Elements\Resource
|
|
||||||
*/
|
|
||||||
protected function serialize(SerializerInterface $serializer, $data)
|
|
||||||
{
|
|
||||||
return $serializer->resource($data);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
|
||||||
|
|
||||||
use Flarum\Api\Commands\GenerateAccessToken;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Flarum\Core\Users\UserRepository;
|
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
|
||||||
use Flarum\Events\UserEmailChangeWasRequested;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Zend\Diactoros\Response\JsonResponse;
|
|
||||||
|
|
||||||
class TokenAction implements Action
|
|
||||||
{
|
|
||||||
protected $users;
|
|
||||||
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
public function __construct(UserRepository $users, Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->users = $users;
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log in and return a token.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
|
||||||
* @throws PermissionDeniedException
|
|
||||||
*/
|
|
||||||
public function handle(Request $request)
|
|
||||||
{
|
|
||||||
$identification = $request->get('identification');
|
|
||||||
$password = $request->get('password');
|
|
||||||
|
|
||||||
$user = $this->users->findByIdentification($identification);
|
|
||||||
|
|
||||||
if (! $user || ! $user->checkPassword($password)) {
|
|
||||||
throw new PermissionDeniedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $user->is_activated) {
|
|
||||||
event(new UserEmailChangeWasRequested($user, $user->email));
|
|
||||||
|
|
||||||
return new JsonResponse([
|
|
||||||
'code' => 'confirm_email',
|
|
||||||
'email' => $user->email
|
|
||||||
], 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
$token = $this->bus->dispatch(
|
|
||||||
new GenerateAccessToken($user->id)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new JsonResponse([
|
|
||||||
'token' => $token->id,
|
|
||||||
'userId' => $user->id
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\Commands\RegisterUser;
|
|
||||||
use Flarum\Api\Actions\CreateAction as BaseCreateAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
|
|
||||||
class CreateAction extends BaseCreateAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a user according to input from the API request.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @return \Flarum\Core\Users\User
|
|
||||||
*/
|
|
||||||
protected function create(JsonApiRequest $request)
|
|
||||||
{
|
|
||||||
$user = $this->bus->dispatch(
|
|
||||||
new RegisterUser($request->actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
|
|
||||||
$request->actor = $user;
|
|
||||||
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\Commands\DeleteAvatar;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class DeleteAvatarAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a user's avatar, and return the user ready to be serialized and
|
|
||||||
* assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Users\User
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new DeleteAvatar($request->get('id'), $request->actor)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,106 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
|
||||||
|
|
||||||
use Flarum\Core\Search\SearchCriteria;
|
|
||||||
use Flarum\Core\Users\Search\UserSearcher;
|
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Flarum\Api\UrlGenerator;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class IndexAction extends SerializeCollectionAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var UserSearcher
|
|
||||||
*/
|
|
||||||
protected $searcher;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var UrlGenerator
|
|
||||||
*/
|
|
||||||
protected $url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'groups' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = ['username', 'postsCount', 'discussionsCount', 'lastSeenTime', 'joinTime'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param UserSearcher $searcher
|
|
||||||
* @param UrlGenerator $url
|
|
||||||
*/
|
|
||||||
public function __construct(UserSearcher $searcher, UrlGenerator $url)
|
|
||||||
{
|
|
||||||
$this->searcher = $searcher;
|
|
||||||
$this->url = $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the user results, ready to be serialized and assigned to the
|
|
||||||
* document response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$criteria = new SearchCriteria(
|
|
||||||
$request->actor,
|
|
||||||
$request->get('filter.q'),
|
|
||||||
$request->sort
|
|
||||||
);
|
|
||||||
|
|
||||||
$results = $this->searcher->search($criteria, $request->limit, $request->offset, $request->include);
|
|
||||||
|
|
||||||
$this->addPaginationLinks(
|
|
||||||
$document,
|
|
||||||
$request,
|
|
||||||
$this->url->toRoute('users.index'),
|
|
||||||
$results->areMoreResults()
|
|
||||||
);
|
|
||||||
|
|
||||||
return $results->getResults();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\UserRepository;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class ShowAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var UserRepository
|
|
||||||
*/
|
|
||||||
protected $users;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\CurrentUserSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'groups' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param UserRepository $users
|
|
||||||
*/
|
|
||||||
public function __construct(UserRepository $users)
|
|
||||||
{
|
|
||||||
$this->users = $users;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a single user, ready to be serialized and assigned to the JsonApi
|
|
||||||
* response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Users\User
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
$id = $request->get('id');
|
|
||||||
|
|
||||||
if (! is_numeric($id)) {
|
|
||||||
$id = $this->users->getIdForUsername($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->users->findOrFail($id, $request->actor);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,85 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\Commands\EditUser;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UpdateAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\CurrentUserSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [
|
|
||||||
'groups' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a user according to input from the API request, and return it
|
|
||||||
* ready to be serialized and assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Users\User
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new EditUser($request->get('id'), $request->actor, $request->get('data'))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\Commands\UploadAvatar;
|
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
|
||||||
use Flarum\Api\JsonApiRequest;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
|
||||||
use Tobscure\JsonApi\Document;
|
|
||||||
|
|
||||||
class UploadAvatarAction extends SerializeResourceAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Dispatcher
|
|
||||||
*/
|
|
||||||
protected $bus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $include = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $link = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limitMax = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $limit = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sortFields = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public $sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Dispatcher $bus
|
|
||||||
*/
|
|
||||||
public function __construct(Dispatcher $bus)
|
|
||||||
{
|
|
||||||
$this->bus = $bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Upload an avatar for a user, and return the user ready to be serialized
|
|
||||||
* and assigned to the JsonApi response.
|
|
||||||
*
|
|
||||||
* @param JsonApiRequest $request
|
|
||||||
* @param Document $document
|
|
||||||
* @return \Flarum\Core\Users\User
|
|
||||||
*/
|
|
||||||
protected function data(JsonApiRequest $request, Document $document)
|
|
||||||
{
|
|
||||||
return $this->bus->dispatch(
|
|
||||||
new UploadAvatar(
|
|
||||||
$request->get('id'),
|
|
||||||
$request->http->getUploadedFiles()['avatar'],
|
|
||||||
$request->actor
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -10,13 +10,12 @@
|
|||||||
|
|
||||||
namespace Flarum\Api;
|
namespace Flarum\Api;
|
||||||
|
|
||||||
use Flarum\Core\Model;
|
use Flarum\Database\AbstractModel;
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo document database columns with @property
|
* @property string $id
|
||||||
*/
|
*/
|
||||||
class ApiKey extends Model
|
class ApiKey extends AbstractModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@@ -10,48 +10,46 @@
|
|||||||
|
|
||||||
namespace Flarum\Api;
|
namespace Flarum\Api;
|
||||||
|
|
||||||
use Flarum\Api\Serializers\ActivitySerializer;
|
use Flarum\Api\Controller\AbstractSerializeController;
|
||||||
use Flarum\Api\Serializers\NotificationSerializer;
|
use Flarum\Api\Serializer\AbstractSerializer;
|
||||||
use Flarum\Core\Users\Guest;
|
use Flarum\Api\Serializer\NotificationSerializer;
|
||||||
use Flarum\Events\RegisterApiRoutes;
|
use Flarum\Event\ConfigureApiRoutes;
|
||||||
use Flarum\Events\RegisterActivityTypes;
|
use Flarum\Event\ConfigureNotificationTypes;
|
||||||
use Flarum\Events\RegisterNotificationTypes;
|
use Flarum\Http\GenerateRouteHandlerTrait;
|
||||||
use Flarum\Http\RouteCollection;
|
use Flarum\Http\RouteCollection;
|
||||||
use Flarum\Api\UrlGenerator;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class ApiServiceProvider extends ServiceProvider
|
class ApiServiceProvider extends AbstractServiceProvider
|
||||||
{
|
{
|
||||||
|
use GenerateRouteHandlerTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the service provider.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind('flarum.actor', function () {
|
$this->app->singleton(UrlGenerator::class, function () {
|
||||||
return new Guest;
|
return new UrlGenerator($this->app, $this->app->make('flarum.api.routes'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->singleton(
|
$this->app->singleton('flarum.api.routes', function () {
|
||||||
UrlGenerator::class,
|
return $this->getRoutes();
|
||||||
function () {
|
});
|
||||||
return new UrlGenerator($this->app->make('flarum.api.routes'));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap the application events.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->routes();
|
|
||||||
|
|
||||||
$this->registerNotificationSerializers();
|
$this->registerNotificationSerializers();
|
||||||
|
|
||||||
|
AbstractSerializeController::setContainer($this->app);
|
||||||
|
AbstractSerializeController::setEventDispatcher($events = $this->app->make('events'));
|
||||||
|
|
||||||
|
AbstractSerializer::setContainer($this->app);
|
||||||
|
AbstractSerializer::setEventDispatcher($events);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,46 +59,55 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
$blueprints = [];
|
$blueprints = [];
|
||||||
$serializers = [
|
$serializers = [
|
||||||
'discussionRenamed' => 'Flarum\Api\Serializers\DiscussionBasicSerializer'
|
'discussionRenamed' => 'Flarum\Api\Serializer\DiscussionBasicSerializer'
|
||||||
];
|
];
|
||||||
|
|
||||||
event(new RegisterNotificationTypes($blueprints, $serializers));
|
$this->app->make('events')->fire(
|
||||||
|
new ConfigureNotificationTypes($blueprints, $serializers)
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($serializers as $type => $serializer) {
|
foreach ($serializers as $type => $serializer) {
|
||||||
NotificationSerializer::setSubjectSerializer($type, $serializer);
|
NotificationSerializer::setSubjectSerializer($type, $serializer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function routes()
|
/**
|
||||||
|
* Get the API routes.
|
||||||
|
*
|
||||||
|
* @return RouteCollection
|
||||||
|
*/
|
||||||
|
protected function getRoutes()
|
||||||
{
|
{
|
||||||
$this->app->instance('flarum.api.routes', $routes = new RouteCollection);
|
$routes = new RouteCollection;
|
||||||
|
|
||||||
|
$toController = $this->getHandlerGenerator($this->app);
|
||||||
|
|
||||||
// Get forum information
|
// Get forum information
|
||||||
$routes->get(
|
$routes->get(
|
||||||
'/forum',
|
'/forum',
|
||||||
'forum.show',
|
'forum.show',
|
||||||
$this->action('Flarum\Api\Actions\Forum\ShowAction')
|
$toController('Flarum\Api\Controller\ShowForumController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Save forum information
|
// Save forum information
|
||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/forum',
|
'/forum',
|
||||||
'forum.update',
|
'forum.update',
|
||||||
$this->action('Flarum\Api\Actions\Forum\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdateForumController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Retrieve authentication token
|
// Retrieve authentication token
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/token',
|
'/token',
|
||||||
'token',
|
'token',
|
||||||
$this->action('Flarum\Api\Actions\TokenAction')
|
$toController('Flarum\Api\Controller\TokenController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send forgot password email
|
// Send forgot password email
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/forgot',
|
'/forgot',
|
||||||
'forgot',
|
'forgot',
|
||||||
$this->action('Flarum\Api\Actions\ForgotAction')
|
$toController('Flarum\Api\Controller\ForgotPasswordController')
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -113,83 +120,76 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
$routes->get(
|
$routes->get(
|
||||||
'/users',
|
'/users',
|
||||||
'users.index',
|
'users.index',
|
||||||
$this->action('Flarum\Api\Actions\Users\IndexAction')
|
$toController('Flarum\Api\Controller\ListUsersController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Register a user
|
// Register a user
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/users',
|
'/users',
|
||||||
'users.create',
|
'users.create',
|
||||||
$this->action('Flarum\Api\Actions\Users\CreateAction')
|
$toController('Flarum\Api\Controller\CreateUserController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get a single user
|
// Get a single user
|
||||||
$routes->get(
|
$routes->get(
|
||||||
'/users/{id}',
|
'/users/{id}',
|
||||||
'users.show',
|
'users.show',
|
||||||
$this->action('Flarum\Api\Actions\Users\ShowAction')
|
$toController('Flarum\Api\Controller\ShowUserController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Edit a user
|
// Edit a user
|
||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/users/{id}',
|
'/users/{id}',
|
||||||
'users.update',
|
'users.update',
|
||||||
$this->action('Flarum\Api\Actions\Users\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdateUserController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete a user
|
// Delete a user
|
||||||
$routes->delete(
|
$routes->delete(
|
||||||
'/users/{id}',
|
'/users/{id}',
|
||||||
'users.delete',
|
'users.delete',
|
||||||
$this->action('Flarum\Api\Actions\Users\DeleteAction')
|
$toController('Flarum\Api\Controller\DeleteUserController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Upload avatar
|
// Upload avatar
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/users/{id}/avatar',
|
'/users/{id}/avatar',
|
||||||
'users.avatar.upload',
|
'users.avatar.upload',
|
||||||
$this->action('Flarum\Api\Actions\Users\UploadAvatarAction')
|
$toController('Flarum\Api\Controller\UploadAvatarController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove avatar
|
// Remove avatar
|
||||||
$routes->delete(
|
$routes->delete(
|
||||||
'/users/{id}/avatar',
|
'/users/{id}/avatar',
|
||||||
'users.avatar.delete',
|
'users.avatar.delete',
|
||||||
$this->action('Flarum\Api\Actions\Users\DeleteAvatarAction')
|
$toController('Flarum\Api\Controller\DeleteAvatarController')
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Activity
|
| Notifications
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// List activity
|
|
||||||
$routes->get(
|
|
||||||
'/activity',
|
|
||||||
'activity.index',
|
|
||||||
$this->action('Flarum\Api\Actions\Activity\IndexAction')
|
|
||||||
);
|
|
||||||
|
|
||||||
// List notifications for the current user
|
// List notifications for the current user
|
||||||
$routes->get(
|
$routes->get(
|
||||||
'/notifications',
|
'/notifications',
|
||||||
'notifications.index',
|
'notifications.index',
|
||||||
$this->action('Flarum\Api\Actions\Notifications\IndexAction')
|
$toController('Flarum\Api\Controller\ListNotificationsController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mark all notifications as read
|
// Mark all notifications as read
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/notifications/read',
|
'/notifications/read',
|
||||||
'notifications.readAll',
|
'notifications.readAll',
|
||||||
$this->action('Flarum\Api\Actions\Notifications\ReadAllAction')
|
$toController('Flarum\Api\Controller\ReadAllNotificationsController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mark a single notification as read
|
// Mark a single notification as read
|
||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/notifications/{id}',
|
'/notifications/{id}',
|
||||||
'notifications.update',
|
'notifications.update',
|
||||||
$this->action('Flarum\Api\Actions\Notifications\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdateNotificationController')
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -202,35 +202,35 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
$routes->get(
|
$routes->get(
|
||||||
'/discussions',
|
'/discussions',
|
||||||
'discussions.index',
|
'discussions.index',
|
||||||
$this->action('Flarum\Api\Actions\Discussions\IndexAction')
|
$toController('Flarum\Api\Controller\ListDiscussionsController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create a discussion
|
// Create a discussion
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/discussions',
|
'/discussions',
|
||||||
'discussions.create',
|
'discussions.create',
|
||||||
$this->action('Flarum\Api\Actions\Discussions\CreateAction')
|
$toController('Flarum\Api\Controller\CreateDiscussionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show a single discussion
|
// Show a single discussion
|
||||||
$routes->get(
|
$routes->get(
|
||||||
'/discussions/{id}',
|
'/discussions/{id}',
|
||||||
'discussions.show',
|
'discussions.show',
|
||||||
$this->action('Flarum\Api\Actions\Discussions\ShowAction')
|
$toController('Flarum\Api\Controller\ShowDiscussionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Edit a discussion
|
// Edit a discussion
|
||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/discussions/{id}',
|
'/discussions/{id}',
|
||||||
'discussions.update',
|
'discussions.update',
|
||||||
$this->action('Flarum\Api\Actions\Discussions\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdateDiscussionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete a discussion
|
// Delete a discussion
|
||||||
$routes->delete(
|
$routes->delete(
|
||||||
'/discussions/{id}',
|
'/discussions/{id}',
|
||||||
'discussions.delete',
|
'discussions.delete',
|
||||||
$this->action('Flarum\Api\Actions\Discussions\DeleteAction')
|
$toController('Flarum\Api\Controller\DeleteDiscussionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -243,35 +243,35 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
$routes->get(
|
$routes->get(
|
||||||
'/posts',
|
'/posts',
|
||||||
'posts.index',
|
'posts.index',
|
||||||
$this->action('Flarum\Api\Actions\Posts\IndexAction')
|
$toController('Flarum\Api\Controller\ListPostsController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create a post
|
// Create a post
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/posts',
|
'/posts',
|
||||||
'posts.create',
|
'posts.create',
|
||||||
$this->action('Flarum\Api\Actions\Posts\CreateAction')
|
$toController('Flarum\Api\Controller\CreatePostController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show a single or multiple posts by ID
|
// Show a single or multiple posts by ID
|
||||||
$routes->get(
|
$routes->get(
|
||||||
'/posts/{id}',
|
'/posts/{id}',
|
||||||
'posts.show',
|
'posts.show',
|
||||||
$this->action('Flarum\Api\Actions\Posts\ShowAction')
|
$toController('Flarum\Api\Controller\ShowPostController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Edit a post
|
// Edit a post
|
||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/posts/{id}',
|
'/posts/{id}',
|
||||||
'posts.update',
|
'posts.update',
|
||||||
$this->action('Flarum\Api\Actions\Posts\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdatePostController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete a post
|
// Delete a post
|
||||||
$routes->delete(
|
$routes->delete(
|
||||||
'/posts/{id}',
|
'/posts/{id}',
|
||||||
'posts.delete',
|
'posts.delete',
|
||||||
$this->action('Flarum\Api\Actions\Posts\DeleteAction')
|
$toController('Flarum\Api\Controller\DeletePostController')
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -284,28 +284,28 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
$routes->get(
|
$routes->get(
|
||||||
'/groups',
|
'/groups',
|
||||||
'groups.index',
|
'groups.index',
|
||||||
$this->action('Flarum\Api\Actions\Groups\IndexAction')
|
$toController('Flarum\Api\Controller\ListGroupsController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create a group
|
// Create a group
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/groups',
|
'/groups',
|
||||||
'groups.create',
|
'groups.create',
|
||||||
$this->action('Flarum\Api\Actions\Groups\CreateAction')
|
$toController('Flarum\Api\Controller\CreateGroupController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Edit a group
|
// Edit a group
|
||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/groups/{id}',
|
'/groups/{id}',
|
||||||
'groups.update',
|
'groups.update',
|
||||||
$this->action('Flarum\Api\Actions\Groups\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdateGroupController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete a group
|
// Delete a group
|
||||||
$routes->delete(
|
$routes->delete(
|
||||||
'/groups/{id}',
|
'/groups/{id}',
|
||||||
'groups.delete',
|
'groups.delete',
|
||||||
$this->action('Flarum\Api\Actions\Groups\DeleteAction')
|
$toController('Flarum\Api\Controller\DeleteGroupController')
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -318,49 +318,34 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
$routes->patch(
|
$routes->patch(
|
||||||
'/extensions/{name}',
|
'/extensions/{name}',
|
||||||
'extensions.update',
|
'extensions.update',
|
||||||
$this->action('Flarum\Api\Actions\Extensions\UpdateAction')
|
$toController('Flarum\Api\Controller\UpdateExtensionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Uninstall an extension
|
// Uninstall an extension
|
||||||
$routes->delete(
|
$routes->delete(
|
||||||
'/extensions/{name}',
|
'/extensions/{name}',
|
||||||
'extensions.delete',
|
'extensions.delete',
|
||||||
$this->action('Flarum\Api\Actions\Extensions\DeleteAction')
|
$toController('Flarum\Api\Controller\UninstallExtensionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update config settings
|
// Update settings
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/config',
|
'/settings',
|
||||||
'config',
|
'settings',
|
||||||
$this->action('Flarum\Api\Actions\ConfigAction')
|
$toController('Flarum\Api\Controller\SetSettingsController')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update a permission
|
// Update a permission
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/permission',
|
'/permission',
|
||||||
'permission',
|
'permission',
|
||||||
$this->action('Flarum\Api\Actions\PermissionAction')
|
$toController('Flarum\Api\Controller\SetPermissionController')
|
||||||
);
|
);
|
||||||
|
|
||||||
event(new RegisterApiRoutes($routes));
|
$this->app->make('events')->fire(
|
||||||
}
|
new ConfigureApiRoutes($routes, $toController)
|
||||||
|
);
|
||||||
|
|
||||||
protected function action($class)
|
return $routes;
|
||||||
{
|
|
||||||
return function (ServerRequestInterface $httpRequest, $routeParams) use ($class) {
|
|
||||||
$action = app($class);
|
|
||||||
$actor = app('flarum.actor');
|
|
||||||
|
|
||||||
$input = array_merge(
|
|
||||||
$httpRequest->getQueryParams(),
|
|
||||||
$httpRequest->getAttributes(),
|
|
||||||
$httpRequest->getParsedBody(),
|
|
||||||
$routeParams
|
|
||||||
);
|
|
||||||
|
|
||||||
$request = new Request($input, $actor, $httpRequest);
|
|
||||||
|
|
||||||
return $action->handle($request);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
namespace Flarum\Api;
|
namespace Flarum\Api;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Http\Controller\ControllerInterface;
|
||||||
|
use Flarum\Core\User;
|
||||||
use Illuminate\Contracts\Container\Container;
|
use Illuminate\Contracts\Container\Container;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\Middleware\JsonApiErrors;
|
use InvalidArgumentException;
|
||||||
|
use Zend\Diactoros\ServerRequestFactory;
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
@@ -33,24 +35,31 @@ class Client
|
|||||||
/**
|
/**
|
||||||
* Execute the given API action class, pass the input and return its response.
|
* Execute the given API action class, pass the input and return its response.
|
||||||
*
|
*
|
||||||
|
* @param string|ControllerInterface $controller
|
||||||
* @param User $actor
|
* @param User $actor
|
||||||
* @param string $actionClass
|
* @param array $queryParams
|
||||||
* @param array $input
|
* @param array $body
|
||||||
* @return object
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function send(User $actor, $actionClass, array $input = [])
|
public function send($controller, User $actor, array $queryParams = [], array $body = [])
|
||||||
{
|
{
|
||||||
/** @var \Flarum\Api\Actions\Action $action */
|
$request = ServerRequestFactory::fromGlobals(null, $queryParams, $body)->withAttribute('actor', $actor);
|
||||||
$action = $this->container->make($actionClass);
|
|
||||||
|
|
||||||
try {
|
if (is_string($controller)) {
|
||||||
$response = $action->handle(new Request($input, $actor));
|
$controller = $this->container->make($controller);
|
||||||
} catch (Exception $e) {
|
|
||||||
$middleware = new JsonApiErrors();
|
|
||||||
|
|
||||||
$response = $middleware->handle($e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response($response);
|
if (! ($controller instanceof ControllerInterface)) {
|
||||||
|
throw new InvalidArgumentException('Endpoint must be an instance of '
|
||||||
|
. ControllerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $controller->handle($request);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$response = $this->container->make('Flarum\Api\Middleware\HandleErrors')->handle($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Commands;
|
namespace Flarum\Api\Command;
|
||||||
|
|
||||||
class GenerateAccessToken
|
class GenerateAccessToken
|
||||||
{
|
{
|
@@ -8,9 +8,10 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Commands;
|
namespace Flarum\Api\Command;
|
||||||
|
|
||||||
use Flarum\Api\AccessToken;
|
use Flarum\Api\AccessToken;
|
||||||
|
use Flarum\Api\Command\GenerateAccessToken;
|
||||||
|
|
||||||
class GenerateAccessTokenHandler
|
class GenerateAccessTokenHandler
|
||||||
{
|
{
|
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Tobscure\JsonApi\Collection;
|
||||||
|
use Tobscure\JsonApi\SerializerInterface;
|
||||||
|
|
||||||
|
abstract class AbstractCollectionController extends AbstractSerializeController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function createElement($data, SerializerInterface $serializer)
|
||||||
|
{
|
||||||
|
return new Collection($data, $serializer);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
|
abstract class AbstractCreateController extends AbstractResourceController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function handle(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return parent::handle($request)->withStatus(201);
|
||||||
|
}
|
||||||
|
}
|
@@ -8,21 +8,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Actions;
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Api\Request;
|
use Flarum\Http\Controller\ControllerInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Zend\Diactoros\Response\EmptyResponse;
|
use Zend\Diactoros\Response\EmptyResponse;
|
||||||
|
|
||||||
abstract class DeleteAction implements Action
|
abstract class AbstractDeleteController implements ControllerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Delegate deletion of the resource, and return a 204 No Content
|
* {@inheritdoc}
|
||||||
* response.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return EmptyResponse
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request)
|
public function handle(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->delete($request);
|
$this->delete($request);
|
||||||
|
|
||||||
@@ -32,8 +29,7 @@ abstract class DeleteAction implements Action
|
|||||||
/**
|
/**
|
||||||
* Delete the resource.
|
* Delete the resource.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param ServerRequestInterface $request
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
abstract protected function delete(Request $request);
|
abstract protected function delete(ServerRequestInterface $request);
|
||||||
}
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Tobscure\JsonApi\Resource;
|
||||||
|
use Tobscure\JsonApi\SerializerInterface;
|
||||||
|
|
||||||
|
abstract class AbstractResourceController extends AbstractSerializeController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function createElement($data, SerializerInterface $serializer)
|
||||||
|
{
|
||||||
|
return new Resource($data, $serializer);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,231 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Api\JsonApiResponse;
|
||||||
|
use Flarum\Http\Controller\ControllerInterface;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
use Flarum\Event\ConfigureApiController;
|
||||||
|
use Flarum\Event\PrepareApiData;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
use Tobscure\JsonApi\Parameters;
|
||||||
|
use Tobscure\JsonApi\SerializerInterface;
|
||||||
|
|
||||||
|
abstract class AbstractSerializeController implements ControllerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the serializer class to output results with.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationships that are included by default.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $include = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationships that are available to be included.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $optionalInclude = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of records that can be requested.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $maxLimit = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of records included by default.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $limit = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fields that are available to be sorted by.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $sortFields = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default sort field and order to user.
|
||||||
|
*
|
||||||
|
* @var array|null
|
||||||
|
*/
|
||||||
|
public $sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Container
|
||||||
|
*/
|
||||||
|
protected static $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected static $events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function handle(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
$document = new Document;
|
||||||
|
|
||||||
|
static::$events->fire(
|
||||||
|
new ConfigureApiController($this)
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = $this->data($request, $document);
|
||||||
|
|
||||||
|
static::$events->fire(
|
||||||
|
new PrepareApiData($this, $data, $request, $document)
|
||||||
|
);
|
||||||
|
|
||||||
|
$serializer = static::$container->make($this->serializer);
|
||||||
|
$serializer->setActor($request->getAttribute('actor'));
|
||||||
|
|
||||||
|
$element = $this->createElement($data, $serializer)
|
||||||
|
->with($this->extractInclude($request))
|
||||||
|
->fields($this->extractFields($request));
|
||||||
|
|
||||||
|
$document->setData($element);
|
||||||
|
|
||||||
|
return new JsonApiResponse($document);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data to be serialized and assigned to the response document.
|
||||||
|
*
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @param Document $document
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
abstract protected function data(ServerRequestInterface $request, Document $document);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a PHP JSON-API Element for output in the document.
|
||||||
|
*
|
||||||
|
* @param mixed $data
|
||||||
|
* @param SerializerInterface $serializer
|
||||||
|
* @return \Tobscure\JsonApi\ElementInterface
|
||||||
|
*/
|
||||||
|
abstract protected function createElement($data, SerializerInterface $serializer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return array
|
||||||
|
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
|
||||||
|
*/
|
||||||
|
protected function extractInclude(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
$available = array_merge($this->include, $this->optionalInclude);
|
||||||
|
|
||||||
|
return $this->buildParameters($request)->getInclude($available) ?: $this->include;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function extractFields(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return $this->buildParameters($request)->getFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return array|null
|
||||||
|
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
|
||||||
|
*/
|
||||||
|
protected function extractSort(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return $this->buildParameters($request)->getSort($this->sortFields) ?: $this->sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return int
|
||||||
|
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
|
||||||
|
*/
|
||||||
|
protected function extractOffset(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return $this->buildParameters($request)->getOffset($this->extractLimit($request)) ?: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function extractLimit(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return $this->buildParameters($request)->getLimit($this->maxLimit) ?: $this->limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function extractFilter(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return $this->buildParameters($request)->getFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ServerRequestInterface $request
|
||||||
|
* @return Parameters
|
||||||
|
*/
|
||||||
|
protected function buildParameters(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return new Parameters($request->getQueryParams());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Dispatcher
|
||||||
|
*/
|
||||||
|
public static function getEventDispatcher()
|
||||||
|
{
|
||||||
|
return static::$events;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $events
|
||||||
|
*/
|
||||||
|
public static function setEventDispatcher(Dispatcher $events)
|
||||||
|
{
|
||||||
|
static::$events = $events;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Container
|
||||||
|
*/
|
||||||
|
public static function getContainer()
|
||||||
|
{
|
||||||
|
return static::$container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Container $container
|
||||||
|
*/
|
||||||
|
public static function setContainer(Container $container)
|
||||||
|
{
|
||||||
|
static::$container = $container;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Core\Command\StartDiscussion;
|
||||||
|
use Flarum\Core\Command\ReadDiscussion;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
class CreateDiscussionController extends AbstractCreateController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $serializer = 'Flarum\Api\Serializer\DiscussionSerializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $include = [
|
||||||
|
'posts',
|
||||||
|
'startUser',
|
||||||
|
'lastUser',
|
||||||
|
'startPost',
|
||||||
|
'lastPost'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected $bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $bus
|
||||||
|
*/
|
||||||
|
public function __construct(Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
|
{
|
||||||
|
$actor = $request->getAttribute('actor');
|
||||||
|
|
||||||
|
$discussion = $this->bus->dispatch(
|
||||||
|
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data'))
|
||||||
|
);
|
||||||
|
|
||||||
|
// After creating the discussion, we assume that the user has seen all
|
||||||
|
// of the posts in the discussion; thus, we will mark the discussion
|
||||||
|
// as read if they are logged in.
|
||||||
|
if ($actor->exists) {
|
||||||
|
$this->bus->dispatch(
|
||||||
|
new ReadDiscussion($discussion->id, $actor, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $discussion;
|
||||||
|
}
|
||||||
|
}
|
47
framework/core/src/Api/Controller/CreateGroupController.php
Normal file
47
framework/core/src/Api/Controller/CreateGroupController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Core\Command\CreateGroup;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
class CreateGroupController extends AbstractCreateController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $serializer = 'Flarum\Api\Serializer\GroupSerializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected $bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $bus
|
||||||
|
*/
|
||||||
|
public function __construct(Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
|
{
|
||||||
|
return $this->bus->dispatch(
|
||||||
|
new CreateGroup($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
76
framework/core/src/Api/Controller/CreatePostController.php
Normal file
76
framework/core/src/Api/Controller/CreatePostController.php
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Core\Command\PostReply;
|
||||||
|
use Flarum\Core\Command\ReadDiscussion;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
class CreatePostController extends AbstractCreateController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $serializer = 'Flarum\Api\Serializer\PostSerializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $include = [
|
||||||
|
'user',
|
||||||
|
'discussion',
|
||||||
|
'discussion.posts',
|
||||||
|
'discussion.lastUser'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected $bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $bus
|
||||||
|
*/
|
||||||
|
public function __construct(Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
|
{
|
||||||
|
$actor = $request->getAttribute('actor');
|
||||||
|
$data = array_get($request->getParsedBody(), 'data');
|
||||||
|
$discussionId = array_get($data, 'relationships.discussion.data.id');
|
||||||
|
|
||||||
|
$post = $this->bus->dispatch(
|
||||||
|
new PostReply($discussionId, $actor, $data)
|
||||||
|
);
|
||||||
|
|
||||||
|
// After replying, we assume that the user has seen all of the posts
|
||||||
|
// in the discussion; thus, we will mark the discussion as read if
|
||||||
|
// they are logged in.
|
||||||
|
if ($actor->exists) {
|
||||||
|
$this->bus->dispatch(
|
||||||
|
new ReadDiscussion($discussionId, $actor, $post->number)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$discussion = $post->discussion;
|
||||||
|
$discussion->posts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
|
||||||
|
|
||||||
|
return $post;
|
||||||
|
}
|
||||||
|
}
|
47
framework/core/src/Api/Controller/CreateUserController.php
Normal file
47
framework/core/src/Api/Controller/CreateUserController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Core\Command\RegisterUser;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
class CreateUserController extends AbstractCreateController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $serializer = 'Flarum\Api\Serializer\CurrentUserSerializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected $bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $bus
|
||||||
|
*/
|
||||||
|
public function __construct(Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
|
{
|
||||||
|
return $this->bus->dispatch(
|
||||||
|
new RegisterUser($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
47
framework/core/src/Api/Controller/DeleteAvatarController.php
Normal file
47
framework/core/src/Api/Controller/DeleteAvatarController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Core\Command\DeleteAvatar;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
class DeleteAvatarController extends AbstractResourceController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $serializer = 'Flarum\Api\Serializer\UserSerializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected $bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $bus
|
||||||
|
*/
|
||||||
|
public function __construct(Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
|
{
|
||||||
|
return $this->bus->dispatch(
|
||||||
|
new DeleteAvatar(array_get($request->getQueryParams(), 'id'), $request->getAttribute('actor'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -8,14 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Discussions;
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Commands\DeleteDiscussion;
|
use Flarum\Core\Command\DeleteDiscussion;
|
||||||
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class DeleteAction extends BaseDeleteAction
|
class DeleteDiscussionController extends AbstractDeleteController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Dispatcher
|
* @var Dispatcher
|
||||||
@@ -33,11 +32,11 @@ class DeleteAction extends BaseDeleteAction
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function delete(Request $request)
|
protected function delete(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$id = $request->get('id');
|
$id = array_get($request->getQueryParams(), 'id');
|
||||||
$actor = $request->actor;
|
$actor = $request->getAttribute('actor');
|
||||||
$input = $request->all();
|
$input = $request->getParsedBody();
|
||||||
|
|
||||||
$this->bus->dispatch(
|
$this->bus->dispatch(
|
||||||
new DeleteDiscussion($id, $actor, $input)
|
new DeleteDiscussion($id, $actor, $input)
|
@@ -8,14 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Users;
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Core\Users\Commands\DeleteUser;
|
use Flarum\Core\Command\DeleteGroup;
|
||||||
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class DeleteAction extends BaseDeleteAction
|
class DeleteGroupController extends AbstractDeleteController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Dispatcher
|
* @var Dispatcher
|
||||||
@@ -31,14 +30,12 @@ class DeleteAction extends BaseDeleteAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a user.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
*/
|
||||||
protected function delete(Request $request)
|
protected function delete(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->bus->dispatch(
|
$this->bus->dispatch(
|
||||||
new DeleteUser($request->get('id'), $request->actor)
|
new DeleteGroup(array_get($request->getQueryParams(), 'id'), $request->getAttribute('actor'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -8,14 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Groups;
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Core\Groups\Commands\DeleteGroup;
|
use Flarum\Core\Command\DeletePost;
|
||||||
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class DeleteAction extends BaseDeleteAction
|
class DeletePostController extends AbstractDeleteController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Dispatcher
|
* @var Dispatcher
|
||||||
@@ -31,14 +30,12 @@ class DeleteAction extends BaseDeleteAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a group.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
*/
|
||||||
protected function delete(Request $request)
|
protected function delete(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->bus->dispatch(
|
$this->bus->dispatch(
|
||||||
new DeleteGroup($request->get('id'), $request->actor)
|
new DeletePost(array_get($request->getQueryParams(), 'id'), $request->getAttribute('actor'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -8,14 +8,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Api\Actions\Posts;
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Commands\DeletePost;
|
use Flarum\Core\Command\DeleteUser;
|
||||||
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
|
||||||
use Flarum\Api\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class DeleteAction extends BaseDeleteAction
|
class DeleteUserController extends AbstractDeleteController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Dispatcher
|
* @var Dispatcher
|
||||||
@@ -31,15 +30,12 @@ class DeleteAction extends BaseDeleteAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a post.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function delete(Request $request)
|
protected function delete(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->bus->dispatch(
|
$this->bus->dispatch(
|
||||||
new DeletePost($request->get('id'), $request->actor)
|
new DeleteUser(array_get($request->getQueryParams(), 'id'), $request->getAttribute('actor'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Core\Repository\UserRepository;
|
||||||
|
use Flarum\Core\Command\RequestPasswordReset;
|
||||||
|
use Flarum\Http\Controller\ControllerInterface;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Zend\Diactoros\Response\EmptyResponse;
|
||||||
|
|
||||||
|
class ForgotPasswordController implements ControllerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Flarum\Core\Repository\UserRepository
|
||||||
|
*/
|
||||||
|
protected $users;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Dispatcher
|
||||||
|
*/
|
||||||
|
protected $bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Flarum\Core\Repository\UserRepository $users
|
||||||
|
* @param Dispatcher $bus
|
||||||
|
*/
|
||||||
|
public function __construct(UserRepository $users, Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->users = $users;
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function handle(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
$email = array_get($request->getParsedBody(), 'email');
|
||||||
|
|
||||||
|
$this->bus->dispatch(
|
||||||
|
new RequestPasswordReset($email)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new EmptyResponse;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user