mirror of
https://github.com/flarum/framework.git
synced 2025-05-26 00:29:59 +08:00
Upgrade to L5 + huge refactor + more. closes #2
New stuff: - Signup + email confirmation. - Updated authentication strategy with remember cookies. closes #5 - New search system with some example gambits! This is cool - check out the source. Fulltext drivers will be implemented as decorators overriding the EloquentPostRepository’s findByContent method. - Lay down the foundation for bootstrapping the Ember app. - Update Web layer’s asset manager to properly publish CSS/JS files. - Console commands to run installation migrations and seeds. Refactoring: - New structure: move models, repositories, commands, and events into their own namespaces, rather than grouping by entity. - All events are classes. - Use L5 middleware and command bus implementations. - Clearer use of repositories and the Active Record pattern. Repositories are used only for retrieval of ActiveRecord objects, and then save/delete operations are called directly on those ActiveRecords. This way, we don’t over-abstract at the cost of Eloquent magic, but testing is still easy. - Refactor of Web layer so that it uses the Actions routing architecture. - “Actor” concept instead of depending on Laravel’s Auth. - General cleanup!
This commit is contained in:
@ -9,8 +9,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"illuminate/support": "4.2.*",
|
"illuminate/support": "5.0.*",
|
||||||
"laracasts/commander": "1.1.*",
|
|
||||||
"tobscure/json-api": "dev-master",
|
"tobscure/json-api": "dev-master",
|
||||||
"tobscure/permissible": "dev-master",
|
"tobscure/permissible": "dev-master",
|
||||||
"misd/linkify": "1.1.*"
|
"misd/linkify": "1.1.*"
|
||||||
@ -23,12 +22,10 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"src/migrations"
|
"seeds"
|
||||||
],
|
],
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Flarum\\Core\\": "src/Flarum/Core",
|
"Flarum\\": "src/"
|
||||||
"Flarum\\Api\\": "src/Flarum/Api",
|
|
||||||
"Flarum\\Web\\": "src/Flarum/Web"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev"
|
"minimum-stability": "dev"
|
||||||
|
429
composer.lock
generated
429
composer.lock
generated
@ -4,35 +4,158 @@
|
|||||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "f965b67cdaace68ab3e159d2c058c449",
|
"hash": "eacf297f994d4976c0c3a9d9ded71bf6",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "danielstjules/stringy",
|
||||||
|
"version": "1.9.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/danielstjules/Stringy.git",
|
||||||
|
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||||
|
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Stringy\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/Create.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Daniel St. Jules",
|
||||||
|
"email": "danielst.jules@gmail.com",
|
||||||
|
"homepage": "http://www.danielstjules.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A string manipulation library with multibyte support",
|
||||||
|
"homepage": "https://github.com/danielstjules/Stringy",
|
||||||
|
"keywords": [
|
||||||
|
"UTF",
|
||||||
|
"helpers",
|
||||||
|
"manipulation",
|
||||||
|
"methods",
|
||||||
|
"multibyte",
|
||||||
|
"string",
|
||||||
|
"utf-8",
|
||||||
|
"utility",
|
||||||
|
"utils"
|
||||||
|
],
|
||||||
|
"time": "2015-02-10 06:19:18"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "doctrine/inflector",
|
||||||
|
"version": "dev-master",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/doctrine/inflector.git",
|
||||||
|
"reference": "e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/doctrine/inflector/zipball/e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d",
|
||||||
|
"reference": "e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "4.*"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Doctrine\\Common\\Inflector\\": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Roman Borschel",
|
||||||
|
"email": "roman@code-factory.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Benjamin Eberlei",
|
||||||
|
"email": "kontakt@beberlei.de"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Guilherme Blanco",
|
||||||
|
"email": "guilhermeblanco@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonathan Wage",
|
||||||
|
"email": "jonwage@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Johannes Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
|
||||||
|
"homepage": "http://www.doctrine-project.org",
|
||||||
|
"keywords": [
|
||||||
|
"inflection",
|
||||||
|
"pluralize",
|
||||||
|
"singularize",
|
||||||
|
"string"
|
||||||
|
],
|
||||||
|
"time": "2015-01-01 18:34:57"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/container",
|
"name": "illuminate/container",
|
||||||
"version": "4.2.x-dev",
|
"version": "5.0.x-dev",
|
||||||
"target-dir": "Illuminate/Container",
|
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/container.git",
|
"url": "https://github.com/illuminate/container.git",
|
||||||
"reference": "8db091c1b4e503ef8dcd4586d5c63e3997bc4e89"
|
"reference": "7ffdad0a2b2c600445deb57f5f7e93092e44ca2a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/container/zipball/8db091c1b4e503ef8dcd4586d5c63e3997bc4e89",
|
"url": "https://api.github.com/repos/illuminate/container/zipball/7ffdad0a2b2c600445deb57f5f7e93092e44ca2a",
|
||||||
"reference": "8db091c1b4e503ef8dcd4586d5c63e3997bc4e89",
|
"reference": "7ffdad0a2b2c600445deb57f5f7e93092e44ca2a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"illuminate/contracts": "5.0.*",
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.4.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "4.2-dev"
|
"dev-master": "5.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-4": {
|
||||||
"Illuminate\\Container": ""
|
"Illuminate\\Container\\": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
@ -45,45 +168,86 @@
|
|||||||
"email": "taylorotwell@gmail.com"
|
"email": "taylorotwell@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2014-12-17 20:39:51"
|
"description": "The Illuminate Container package.",
|
||||||
|
"time": "2015-02-11 16:00:31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "illuminate/contracts",
|
||||||
|
"version": "5.0.x-dev",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/illuminate/contracts.git",
|
||||||
|
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/illuminate/contracts/zipball/78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||||
|
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "5.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Illuminate\\Contracts\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylorotwell@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The Illuminate Contracts package.",
|
||||||
|
"time": "2015-01-30 16:27:08"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/database",
|
"name": "illuminate/database",
|
||||||
"version": "4.2.x-dev",
|
"version": "5.0.x-dev",
|
||||||
"target-dir": "Illuminate/Database",
|
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/database.git",
|
"url": "https://github.com/illuminate/database.git",
|
||||||
"reference": "eabb5ad0db896339f821ef088ca2fd0d6972e137"
|
"reference": "0c86cd20e7b0fb0bd0979bbddc7946239c58ad66"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/database/zipball/eabb5ad0db896339f821ef088ca2fd0d6972e137",
|
"url": "https://api.github.com/repos/illuminate/database/zipball/0c86cd20e7b0fb0bd0979bbddc7946239c58ad66",
|
||||||
"reference": "eabb5ad0db896339f821ef088ca2fd0d6972e137",
|
"reference": "0c86cd20e7b0fb0bd0979bbddc7946239c58ad66",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"illuminate/container": "4.2.*",
|
"illuminate/container": "5.0.*",
|
||||||
"illuminate/events": "4.2.*",
|
"illuminate/contracts": "5.0.*",
|
||||||
"illuminate/support": "4.2.*",
|
"illuminate/support": "5.0.*",
|
||||||
"nesbot/carbon": "~1.0",
|
"nesbot/carbon": "~1.0",
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"suggest": {
|
||||||
"illuminate/cache": "4.2.*",
|
"doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).",
|
||||||
"illuminate/console": "4.2.*",
|
"illuminate/console": "Required to use the database commands (5.0.*).",
|
||||||
"illuminate/filesystem": "4.2.*",
|
"illuminate/events": "Required to use the observers with Eloquent (5.0.*).",
|
||||||
"illuminate/pagination": "4.2.*"
|
"illuminate/filesystem": "Required to use the migrations (5.0.*)."
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "4.2-dev"
|
"dev-master": "5.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-4": {
|
||||||
"Illuminate\\Database": ""
|
"Illuminate\\Database\\": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
@ -96,91 +260,51 @@
|
|||||||
"email": "taylorotwell@gmail.com"
|
"email": "taylorotwell@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"description": "The Illuminate Database package.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"database",
|
"database",
|
||||||
"laravel",
|
"laravel",
|
||||||
"orm",
|
"orm",
|
||||||
"sql"
|
"sql"
|
||||||
],
|
],
|
||||||
"time": "2015-01-27 20:51:43"
|
"time": "2015-02-18 02:07:31"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "illuminate/events",
|
|
||||||
"version": "4.2.x-dev",
|
|
||||||
"target-dir": "Illuminate/Events",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/illuminate/events.git",
|
|
||||||
"reference": "a8471d3f6c3e87c50e25e18f13908fffaef159df"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/illuminate/events/zipball/a8471d3f6c3e87c50e25e18f13908fffaef159df",
|
|
||||||
"reference": "a8471d3f6c3e87c50e25e18f13908fffaef159df",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"illuminate/container": "4.2.*",
|
|
||||||
"illuminate/support": "4.2.*",
|
|
||||||
"php": ">=5.4.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "4.2-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Illuminate\\Events": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Taylor Otwell",
|
|
||||||
"email": "taylorotwell@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2014-10-02 19:49:50"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/support",
|
"name": "illuminate/support",
|
||||||
"version": "4.2.x-dev",
|
"version": "5.0.x-dev",
|
||||||
"target-dir": "Illuminate/Support",
|
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/support.git",
|
"url": "https://github.com/illuminate/support.git",
|
||||||
"reference": "db61f3f6d507ce417ca993e1f93585db7efd8b12"
|
"reference": "405a2241fefa49cfc39b7fba8cc54f69fce2f101"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/support/zipball/db61f3f6d507ce417ca993e1f93585db7efd8b12",
|
"url": "https://api.github.com/repos/illuminate/support/zipball/405a2241fefa49cfc39b7fba8cc54f69fce2f101",
|
||||||
"reference": "db61f3f6d507ce417ca993e1f93585db7efd8b12",
|
"reference": "405a2241fefa49cfc39b7fba8cc54f69fce2f101",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"danielstjules/stringy": "~1.8",
|
||||||
|
"doctrine/inflector": "~1.0",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"illuminate/contracts": "5.0.*",
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"suggest": {
|
||||||
"jeremeamia/superclosure": "~1.0.1",
|
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.0)."
|
||||||
"patchwork/utf8": "~1.1"
|
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "4.2-dev"
|
"dev-master": "5.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-4": {
|
||||||
"Illuminate\\Support": ""
|
"Illuminate\\Support\\": ""
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"Illuminate/Support/helpers.php"
|
"helpers.php"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
@ -193,44 +317,8 @@
|
|||||||
"email": "taylorotwell@gmail.com"
|
"email": "taylorotwell@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2015-01-27 20:51:43"
|
"description": "The Illuminate Support package.",
|
||||||
},
|
"time": "2015-02-11 11:08:03"
|
||||||
{
|
|
||||||
"name": "laracasts/commander",
|
|
||||||
"version": "1.1.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/laracasts/Commander.git",
|
|
||||||
"reference": "89b47ceb08e26d6beae35781010522e7110aded3"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/laracasts/Commander/zipball/89b47ceb08e26d6beae35781010522e7110aded3",
|
|
||||||
"reference": "89b47ceb08e26d6beae35781010522e7110aded3",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"illuminate/support": "~4.0",
|
|
||||||
"php": ">=5.4.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Laracasts\\Commander": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jeffrey Way",
|
|
||||||
"email": "jeffrey@laracasts.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Commands and domain events in Laravel",
|
|
||||||
"time": "2014-07-03 13:05:27"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "misd/linkify",
|
"name": "misd/linkify",
|
||||||
@ -371,16 +459,16 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tobscure/permissible.git",
|
"url": "https://github.com/tobscure/permissible.git",
|
||||||
"reference": "223a62784672981a45170d2192c9786971b3abee"
|
"reference": "35d92ad11e66bafc94666cae3224d0ca08f44a6a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/tobscure/permissible/zipball/223a62784672981a45170d2192c9786971b3abee",
|
"url": "https://api.github.com/repos/tobscure/permissible/zipball/35d92ad11e66bafc94666cae3224d0ca08f44a6a",
|
||||||
"reference": "223a62784672981a45170d2192c9786971b3abee",
|
"reference": "35d92ad11e66bafc94666cae3224d0ca08f44a6a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"illuminate/database": "4.2.*",
|
"illuminate/database": "5.0.*",
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@ -400,7 +488,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Powerful, flexible, relational permissions using Eloquent.",
|
"description": "Powerful, flexible, relational permissions using Eloquent.",
|
||||||
"time": "2014-07-26 05:00:03"
|
"time": "2015-02-18 23:38:49"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
@ -410,12 +498,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Codeception/Codeception.git",
|
"url": "https://github.com/Codeception/Codeception.git",
|
||||||
"reference": "1416a5ed429615664ba406a37de141a7cba2982b"
|
"reference": "4e267293bb8070e03fb358f27e74271c2d10acbe"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/1416a5ed429615664ba406a37de141a7cba2982b",
|
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/4e267293bb8070e03fb358f27e74271c2d10acbe",
|
||||||
"reference": "1416a5ed429615664ba406a37de141a7cba2982b",
|
"reference": "4e267293bb8070e03fb358f27e74271c2d10acbe",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -482,7 +570,7 @@
|
|||||||
"functional testing",
|
"functional testing",
|
||||||
"unit testing"
|
"unit testing"
|
||||||
],
|
],
|
||||||
"time": "2015-02-07 01:27:55"
|
"time": "2015-02-16 11:49:51"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "codeception/mockery-module",
|
"name": "codeception/mockery-module",
|
||||||
@ -727,12 +815,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/RingPHP.git",
|
"url": "https://github.com/guzzle/RingPHP.git",
|
||||||
"reference": "0b13b4f0d595c4e886ae8eecdfe27e049ba38375"
|
"reference": "a1da305d1c5c0175abf7bc912cb065e906de9500"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/0b13b4f0d595c4e886ae8eecdfe27e049ba38375",
|
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a1da305d1c5c0175abf7bc912cb065e906de9500",
|
||||||
"reference": "0b13b4f0d595c4e886ae8eecdfe27e049ba38375",
|
"reference": "a1da305d1c5c0175abf7bc912cb065e906de9500",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -770,7 +858,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
|
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
|
||||||
"time": "2015-01-20 22:24:03"
|
"time": "2015-02-08 23:29:08"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/streams",
|
"name": "guzzlehttp/streams",
|
||||||
@ -875,12 +963,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/padraic/mockery.git",
|
"url": "https://github.com/padraic/mockery.git",
|
||||||
"reference": "0bf3f7346cb49a24587a1a6292e7f20fcd80af0a"
|
"reference": "a450aa28455781c7a72e50794b0f9d954cf8decb"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/padraic/mockery/zipball/0bf3f7346cb49a24587a1a6292e7f20fcd80af0a",
|
"url": "https://api.github.com/repos/padraic/mockery/zipball/a450aa28455781c7a72e50794b0f9d954cf8decb",
|
||||||
"reference": "0bf3f7346cb49a24587a1a6292e7f20fcd80af0a",
|
"reference": "a450aa28455781c7a72e50794b0f9d954cf8decb",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -889,8 +977,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"hamcrest/hamcrest-php": "~1.1",
|
"hamcrest/hamcrest-php": "~1.1",
|
||||||
"phpunit/phpunit": "~4.0",
|
"phpunit/phpunit": "~4.0"
|
||||||
"satooshi/php-coveralls": "~0.7@dev"
|
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
@ -933,7 +1020,7 @@
|
|||||||
"test double",
|
"test double",
|
||||||
"testing"
|
"testing"
|
||||||
],
|
],
|
||||||
"time": "2015-02-05 10:30:00"
|
"time": "2015-02-18 18:54:04"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
@ -1185,12 +1272,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a"
|
"reference": "5fbd35c52d9ad2a12683a11a138e5c05b31da95a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2e8580deebb7d1ac92ac878595e6bffe01069c2a",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5fbd35c52d9ad2a12683a11a138e5c05b31da95a",
|
||||||
"reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a",
|
"reference": "5fbd35c52d9ad2a12683a11a138e5c05b31da95a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1249,7 +1336,7 @@
|
|||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-01-27 16:06:15"
|
"time": "2015-02-09 06:34:32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit-mock-objects",
|
"name": "phpunit/phpunit-mock-objects",
|
||||||
@ -1728,12 +1815,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/BrowserKit.git",
|
"url": "https://github.com/symfony/BrowserKit.git",
|
||||||
"reference": "432c0593d5367b1bb8aa893cb2272172934ad371"
|
"reference": "7b8c4f5e8839122a931f45978c1330749ef9e83a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/432c0593d5367b1bb8aa893cb2272172934ad371",
|
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/7b8c4f5e8839122a931f45978c1330749ef9e83a",
|
||||||
"reference": "432c0593d5367b1bb8aa893cb2272172934ad371",
|
"reference": "7b8c4f5e8839122a931f45978c1330749ef9e83a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1774,7 +1861,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony BrowserKit Component",
|
"description": "Symfony BrowserKit Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-01-09 06:51:41"
|
"time": "2015-02-11 07:17:51"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/console",
|
"name": "symfony/console",
|
||||||
@ -1783,12 +1870,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Console.git",
|
"url": "https://github.com/symfony/Console.git",
|
||||||
"reference": "e30a2778069b48bd1e560e4a2815d15c9ab2f563"
|
"reference": "289113e60aad754d35b50347f66ecd3a4d96d03c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Console/zipball/e30a2778069b48bd1e560e4a2815d15c9ab2f563",
|
"url": "https://api.github.com/repos/symfony/Console/zipball/289113e60aad754d35b50347f66ecd3a4d96d03c",
|
||||||
"reference": "e30a2778069b48bd1e560e4a2815d15c9ab2f563",
|
"reference": "289113e60aad754d35b50347f66ecd3a4d96d03c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1831,7 +1918,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Console Component",
|
"description": "Symfony Console Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-02-05 07:11:58"
|
"time": "2015-02-12 11:03:31"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/css-selector",
|
"name": "symfony/css-selector",
|
||||||
@ -1840,12 +1927,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/CssSelector.git",
|
"url": "https://github.com/symfony/CssSelector.git",
|
||||||
"reference": "1f8617c67bef17192d28c0f2dda3a04b632629bb"
|
"reference": "e37b4cd8a5ea27d2bd4775a4980f32d39d5daf31"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/1f8617c67bef17192d28c0f2dda3a04b632629bb",
|
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/e37b4cd8a5ea27d2bd4775a4980f32d39d5daf31",
|
||||||
"reference": "1f8617c67bef17192d28c0f2dda3a04b632629bb",
|
"reference": "e37b4cd8a5ea27d2bd4775a4980f32d39d5daf31",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1882,7 +1969,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony CssSelector Component",
|
"description": "Symfony CssSelector Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-01-09 06:51:41"
|
"time": "2015-02-11 07:17:51"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/dom-crawler",
|
"name": "symfony/dom-crawler",
|
||||||
@ -1891,12 +1978,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/DomCrawler.git",
|
"url": "https://github.com/symfony/DomCrawler.git",
|
||||||
"reference": "49d1657a690eaa6e8fd4f92d828b89bed05dd55d"
|
"reference": "e1355f67898ca94fe18425c3f2d2d4e905ea894f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/49d1657a690eaa6e8fd4f92d828b89bed05dd55d",
|
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/e1355f67898ca94fe18425c3f2d2d4e905ea894f",
|
||||||
"reference": "49d1657a690eaa6e8fd4f92d828b89bed05dd55d",
|
"reference": "e1355f67898ca94fe18425c3f2d2d4e905ea894f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1935,7 +2022,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony DomCrawler Component",
|
"description": "Symfony DomCrawler Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-02-05 06:58:17"
|
"time": "2015-02-11 07:17:51"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/event-dispatcher",
|
"name": "symfony/event-dispatcher",
|
||||||
@ -1944,12 +2031,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||||
"reference": "e9298668dce8dd219d1ee2290c7f313954f1f984"
|
"reference": "2dc33aff298b20ad099ac456034aebc5055f02fb"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e9298668dce8dd219d1ee2290c7f313954f1f984",
|
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/2dc33aff298b20ad099ac456034aebc5055f02fb",
|
||||||
"reference": "e9298668dce8dd219d1ee2290c7f313954f1f984",
|
"reference": "2dc33aff298b20ad099ac456034aebc5055f02fb",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1993,7 +2080,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony EventDispatcher Component",
|
"description": "Symfony EventDispatcher Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-02-05 06:58:17"
|
"time": "2015-02-11 07:17:51"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/finder",
|
"name": "symfony/finder",
|
||||||
@ -2002,12 +2089,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Finder.git",
|
"url": "https://github.com/symfony/Finder.git",
|
||||||
"reference": "0c737de96a94d14a51738d285ad426a102baac0e"
|
"reference": "509d125782f31ebbd0bb3cd9824f1ccc1e5d5a18"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Finder/zipball/0c737de96a94d14a51738d285ad426a102baac0e",
|
"url": "https://api.github.com/repos/symfony/Finder/zipball/509d125782f31ebbd0bb3cd9824f1ccc1e5d5a18",
|
||||||
"reference": "0c737de96a94d14a51738d285ad426a102baac0e",
|
"reference": "509d125782f31ebbd0bb3cd9824f1ccc1e5d5a18",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -2040,7 +2127,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Finder Component",
|
"description": "Symfony Finder Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-01-09 06:51:41"
|
"time": "2015-02-11 07:17:51"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/yaml",
|
"name": "symfony/yaml",
|
||||||
@ -2049,12 +2136,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Yaml.git",
|
"url": "https://github.com/symfony/Yaml.git",
|
||||||
"reference": "02ba3dc638c5d3f0ab3b47ddb74f98c11dcc0c60"
|
"reference": "43aac3461a5679f486f7c96e4d7e780a59fec997"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/02ba3dc638c5d3f0ab3b47ddb74f98c11dcc0c60",
|
"url": "https://api.github.com/repos/symfony/Yaml/zipball/43aac3461a5679f486f7c96e4d7e780a59fec997",
|
||||||
"reference": "02ba3dc638c5d3f0ab3b47ddb74f98c11dcc0c60",
|
"reference": "43aac3461a5679f486f7c96e4d7e780a59fec997",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -2087,7 +2174,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Yaml Component",
|
"description": "Symfony Yaml Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-01-25 04:39:35"
|
"time": "2015-02-11 07:17:51"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
{
|
{
|
||||||
/**
|
"output-path": "../public"
|
||||||
Ember CLI sends analytics information by default. The data is completely
|
|
||||||
anonymous, but there are times when you might want to disable this behavior.
|
|
||||||
|
|
||||||
Setting `disableAnalytics` to true will prevent any data from being sent.
|
|
||||||
*/
|
|
||||||
"disableAnalytics": false
|
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,11 @@ import config from '../config/environment';
|
|||||||
|
|
||||||
export default Base.extend({
|
export default Base.extend({
|
||||||
|
|
||||||
restore: function(data) {
|
|
||||||
var container = this.container;
|
|
||||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
|
||||||
Ember.run.next(function() {
|
|
||||||
container.lookup('store:main').find('user', data.userId).then(function(user) {
|
|
||||||
resolve( { token: data.token, userId: data.userId, user: user } );
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
authenticate: function(credentials) {
|
authenticate: function(credentials) {
|
||||||
var container = this.container;
|
var container = this.container;
|
||||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||||
Ember.$.ajax({
|
Ember.$.ajax({
|
||||||
url: config.apiURL+'/auth/login',
|
url: config.baseURL+'login',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { identification: credentials.identification, password: credentials.password }
|
data: { identification: credentials.identification, password: credentials.password }
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
@ -31,7 +20,9 @@ export default Base.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// invalidate: function(data) {
|
invalidate: function(data) {
|
||||||
// return new Ember.RSVP.Promise();
|
return new Ember.RSVP.Promise(function() {
|
||||||
// }
|
window.location = config.baseURL+'logout';
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
@ -1,7 +1,6 @@
|
|||||||
import Base from 'simple-auth/authorizers/base';
|
import Base from 'simple-auth/authorizers/base';
|
||||||
|
|
||||||
export default Base.extend({
|
export default Base.extend({
|
||||||
|
|
||||||
authorize: function(jqXHR, requestOptions) {
|
authorize: function(jqXHR, requestOptions) {
|
||||||
var token = this.get('session.token');
|
var token = this.get('session.token');
|
||||||
if (this.get('session.isAuthenticated') && !Ember.isEmpty(token)) {
|
if (this.get('session.isAuthenticated') && !Ember.isEmpty(token)) {
|
||||||
|
@ -54,6 +54,8 @@ export default Ember.Controller.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var results = Ember.RSVP.resolve(FLARUM_DATA.discussions);
|
||||||
|
|
||||||
return this.store.find('discussion', params).then(function(discussions) {
|
return this.store.find('discussion', params).then(function(discussions) {
|
||||||
var results = Ember.A();
|
var results = Ember.A();
|
||||||
discussions.forEach(function(discussion) {
|
discussions.forEach(function(discussion) {
|
||||||
|
@ -3,6 +3,19 @@ import Ember from 'ember';
|
|||||||
import ModalController from 'flarum/mixins/modal-controller';
|
import ModalController from 'flarum/mixins/modal-controller';
|
||||||
|
|
||||||
export default Ember.Controller.extend(ModalController, {
|
export default Ember.Controller.extend(ModalController, {
|
||||||
|
emailProviderName: Ember.computed('welcomeUser.email', function() {
|
||||||
|
if (!this.get('welcomeUser.email')) { return; }
|
||||||
|
return this.get('welcomeUser.email').split('@')[1];
|
||||||
|
}),
|
||||||
|
|
||||||
|
emailProviderUrl: Ember.computed('emailProviderName', function() {
|
||||||
|
return 'http://'+this.get('emailProviderName');
|
||||||
|
}),
|
||||||
|
|
||||||
|
welcomeStyle: Ember.computed('welcomeUser.color', function() {
|
||||||
|
return 'background:'+this.get('welcomeUser.color');
|
||||||
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
submit: function() {
|
submit: function() {
|
||||||
var data = this.getProperties('username', 'email', 'password');
|
var data = this.getProperties('username', 'email', 'password');
|
||||||
@ -12,15 +25,9 @@ export default Ember.Controller.extend(ModalController, {
|
|||||||
|
|
||||||
var user = this.store.createRecord('user', data);
|
var user = this.store.createRecord('user', data);
|
||||||
|
|
||||||
return user.save().then(function() {
|
return user.save().then(function(user) {
|
||||||
controller.get('session').authenticate('authenticator:flarum', {
|
controller.set('welcomeUser', user);
|
||||||
identification: data.email,
|
|
||||||
password: data.password
|
|
||||||
}).then(function() {
|
|
||||||
controller.send('closeModal');
|
|
||||||
controller.send('sessionChanged');
|
|
||||||
controller.set('loading', false);
|
controller.set('loading', false);
|
||||||
});
|
|
||||||
}, function(reason) {
|
}, function(reason) {
|
||||||
controller.set('loading', false);
|
controller.set('loading', false);
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import FlarumAuthorizer from 'flarum/authorizers/flarum';
|
import FlarumAuthorizer from 'flarum/authorizers/flarum';
|
||||||
|
import Config from 'flarum/config/environment';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'authentication',
|
name: 'authentication',
|
||||||
before: 'simple-auth',
|
before: 'simple-auth',
|
||||||
initialize: function(container) {
|
initialize: function(container) {
|
||||||
container.register('authorizer:flarum', FlarumAuthorizer);
|
container.register('authorizer:flarum', FlarumAuthorizer);
|
||||||
|
Config['simple-auth'] = {authorizer: 'authorizer:flarum'};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
20
ember/app/initializers/preload-data.js
Normal file
20
ember/app/initializers/preload-data.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'preload-data',
|
||||||
|
after: 'store',
|
||||||
|
initialize: function(container) {
|
||||||
|
var store = container.lookup('store:main');
|
||||||
|
if (!Ember.isEmpty(FLARUM_DATA)) {
|
||||||
|
store.pushPayload(FLARUM_DATA);
|
||||||
|
}
|
||||||
|
if (!Ember.isEmpty(FLARUM_SESSION)) {
|
||||||
|
FLARUM_SESSION.user = store.getById('user', FLARUM_SESSION.userId);
|
||||||
|
container.lookup('simple-auth-session:main').setProperties({
|
||||||
|
isAuthenticated: true,
|
||||||
|
authenticator: 'authenticator:flarum',
|
||||||
|
content: FLARUM_SESSION
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -1,7 +1,15 @@
|
|||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
|
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
|
||||||
|
|
||||||
|
import AlertMessage from 'flarum/components/ui/alert-message';
|
||||||
|
|
||||||
export default Ember.Route.extend(ApplicationRouteMixin, {
|
export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||||
|
activate: function() {
|
||||||
|
if (!Ember.isEmpty(FLARUM_ALERT)) {
|
||||||
|
this.controllerFor('alerts').send('alert', AlertMessage.create(FLARUM_ALERT));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
login: function() {
|
login: function() {
|
||||||
this.controllerFor('login').set('error', null);
|
this.controllerFor('login').set('error', null);
|
||||||
@ -9,7 +17,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
signup: function() {
|
signup: function() {
|
||||||
this.controllerFor('signup').set('error', null);
|
this.controllerFor('signup').set('error', null).set('welcomeUser', null);
|
||||||
this.send('showModal', 'signup');
|
this.send('showModal', 'signup');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,3 +26,4 @@
|
|||||||
@import "@{flarum-base}index.less";
|
@import "@{flarum-base}index.less";
|
||||||
@import "@{flarum-base}discussion.less";
|
@import "@{flarum-base}discussion.less";
|
||||||
@import "@{flarum-base}login.less";
|
@import "@{flarum-base}login.less";
|
||||||
|
@import "@{flarum-base}signup.less";
|
||||||
|
23
ember/app/styles/flarum/signup.less
Normal file
23
ember/app/styles/flarum/signup.less
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
.signup-welcome {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
border-radius: @border-radius-base - 1px;
|
||||||
|
padding: 60px;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
& .avatar {
|
||||||
|
.avatar-size(64px);
|
||||||
|
.box-shadow(0 0 0 4px #fff);
|
||||||
|
}
|
||||||
|
& h3, & p {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
& .btn-default {
|
||||||
|
background: fade(#000, 10%);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
@ -26,3 +26,15 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{{ui/loading-indicator classNameBindings=":modal-loading loading:active"}}
|
{{ui/loading-indicator classNameBindings=":modal-loading loading:active"}}
|
||||||
|
|
||||||
|
{{#if welcomeUser}}
|
||||||
|
<div {{bind-attr class=":signup-welcome :fade" style=welcomeStyle}}>
|
||||||
|
{{user-avatar welcomeUser}}
|
||||||
|
<h3>Welcome, {{welcomeUser.username}}!</h3>
|
||||||
|
|
||||||
|
{{#unless welcomeUser.isConfirmed}}
|
||||||
|
<p>We've sent a confirmation email to <strong>{{welcomeUser.email}}</strong>. If it doesn't arrive soon, check your spam folder.</p>
|
||||||
|
<p><a {{bind-attr href=emailProviderUrl}} class="btn btn-default">Go to {{emailProviderName}}</a></p>
|
||||||
|
{{/unless}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
@ -7,5 +7,13 @@ export default Ember.View.extend(ModalView, {
|
|||||||
templateName: 'signup',
|
templateName: 'signup',
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
}
|
},
|
||||||
|
|
||||||
|
welcomeUserDidChange: Ember.observer('welcomeUser', function() {
|
||||||
|
if (this.get('welcomeUser')) {
|
||||||
|
Ember.run.scheduleOnce('afterRender', this, function() {
|
||||||
|
this.$('.signup-welcome').addClass('in');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
class CreateSessionsTable extends Migration {
|
class CreateAccessTokensTable extends Migration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@ -12,11 +12,10 @@ class CreateSessionsTable extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('sessions', function(Blueprint $table)
|
Schema::create('access_tokens', function(Blueprint $table)
|
||||||
{
|
{
|
||||||
$table->string('id')->unique();
|
$table->string('id');
|
||||||
$table->binary('payload');
|
$table->integer('user_id')->unsigned();
|
||||||
$table->integer('last_activity');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ class CreateSessionsTable extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::drop('sessions');
|
Schema::drop('access_tokens');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -19,8 +19,8 @@ class CreateUsersTable extends Migration {
|
|||||||
$table->string('email');
|
$table->string('email');
|
||||||
$table->boolean('is_confirmed')->default(0);
|
$table->boolean('is_confirmed')->default(0);
|
||||||
$table->string('confirmation_token')->nullable();
|
$table->string('confirmation_token')->nullable();
|
||||||
|
$table->boolean('is_activated')->default(0);
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->string('token');
|
|
||||||
$table->dateTime('join_time')->nullable();
|
$table->dateTime('join_time')->nullable();
|
||||||
$table->dateTime('last_seen_time')->nullable();
|
$table->dateTime('last_seen_time')->nullable();
|
||||||
$table->dateTime('read_time')->nullable();
|
$table->dateTime('read_time')->nullable();
|
89
src/Api/Actions/ApiParams.php
Normal file
89
src/Api/Actions/ApiParams.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions;
|
||||||
|
|
||||||
|
class ApiParams
|
||||||
|
{
|
||||||
|
protected $params;
|
||||||
|
|
||||||
|
public function __construct(array $params)
|
||||||
|
{
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key, $default = null)
|
||||||
|
{
|
||||||
|
return array_get($this->params, $key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function range($key, $default = null, $min = null, $max = null)
|
||||||
|
{
|
||||||
|
$value = (int) $this->get($key, $default);
|
||||||
|
|
||||||
|
if (! is_null($min)) {
|
||||||
|
$value = max($value, $min);
|
||||||
|
}
|
||||||
|
if (! is_null($max)) {
|
||||||
|
$value = min($value, $max);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function included($available)
|
||||||
|
{
|
||||||
|
$requested = explode(',', $this->get('include'));
|
||||||
|
return array_intersect((array) $available, $requested);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function explodeIds($ids)
|
||||||
|
// {
|
||||||
|
// return array_unique(array_map('intval', array_filter(explode(',', $ids))));
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function in($key, $options)
|
||||||
|
{
|
||||||
|
$value = $this->get($key);
|
||||||
|
|
||||||
|
if (array_key_exists($key, $options)) {
|
||||||
|
return $options[$key];
|
||||||
|
}
|
||||||
|
if (! in_array($value, $options)) {
|
||||||
|
$value = reset($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sort($options)
|
||||||
|
{
|
||||||
|
$criteria = (string) $this->get('sort', '');
|
||||||
|
$order = null;
|
||||||
|
|
||||||
|
if ($criteria && $criteria[0] == '-') {
|
||||||
|
$order = 'desc';
|
||||||
|
$criteria = substr($criteria, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! in_array($criteria, $options)) {
|
||||||
|
$criteria = reset($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($criteria && ! $order) {
|
||||||
|
$order = 'asc';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'field' => $criteria,
|
||||||
|
'order' => $order,
|
||||||
|
'string' => ($order == 'desc' ? '-' : '').$criteria
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function start()
|
||||||
|
{
|
||||||
|
return $this->range('start', 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function count($default, $max = 100)
|
||||||
|
{
|
||||||
|
return $this->range('count', $default, 1, $max);
|
||||||
|
}
|
||||||
|
}
|
130
src/Api/Actions/BaseAction.php
Normal file
130
src/Api/Actions/BaseAction.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Tobscure\JsonApi\Document;
|
||||||
|
use Flarum\Core\Support\Actor;
|
||||||
|
use Flarum\Api\Events\CommandWillBeDispatched;
|
||||||
|
use Flarum\Api\Events\WillRespondWithDocument;
|
||||||
|
use Flarum\Web\Actions\Action;
|
||||||
|
use Config;
|
||||||
|
use App;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
abstract class BaseAction extends Action
|
||||||
|
{
|
||||||
|
abstract protected function run(ApiParams $params);
|
||||||
|
|
||||||
|
public function __construct(Actor $actor, Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(Request $request, $routeParams = [])
|
||||||
|
{
|
||||||
|
$this->registerErrorHandlers(); // @todo convert to middleware and add to route group?
|
||||||
|
|
||||||
|
$params = array_merge($request->all(), $routeParams);
|
||||||
|
|
||||||
|
return $this->call($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function call($params = [])
|
||||||
|
{
|
||||||
|
$params = new ApiParams($params);
|
||||||
|
|
||||||
|
return $this->run($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hydrate($object, $params)
|
||||||
|
{
|
||||||
|
foreach ($params as $k => $v) {
|
||||||
|
$object->$k = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function dispatch($command, $params)
|
||||||
|
{
|
||||||
|
$this->event(new CommandWillBeDispatched($command, $params));
|
||||||
|
return $this->bus->dispatch($command);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function event($event)
|
||||||
|
{
|
||||||
|
event($event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function document()
|
||||||
|
{
|
||||||
|
return new Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildUrl($route, $params = [], $input = [])
|
||||||
|
{
|
||||||
|
$url = route('flarum.api.'.$route, $params);
|
||||||
|
$queryString = $input ? '?'.http_build_query($input) : '';
|
||||||
|
|
||||||
|
return $url.$queryString;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function respondWithoutContent($statusCode = 204, $headers = [])
|
||||||
|
{
|
||||||
|
return Response::make('', $statusCode, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function respondWithArray($array, $statusCode = 200, $headers = [])
|
||||||
|
{
|
||||||
|
return Response::json($array, $statusCode, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function respondWithDocument($document, $statusCode = 200, $headers = [])
|
||||||
|
{
|
||||||
|
$headers['Content-Type'] = 'application/vnd.api+json';
|
||||||
|
|
||||||
|
$this->event(new WillRespondWithDocument($document, $statusCode, $headers));
|
||||||
|
|
||||||
|
return $this->respondWithArray($document->toArray(), $statusCode, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerErrorHandlers()
|
||||||
|
{
|
||||||
|
// if (! Config::get('app.debug')) {
|
||||||
|
// App::error(function ($exception, $code) {
|
||||||
|
// return $this->respondWithError('ApplicationError', $code);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// App::error(function (ModelNotFoundException $exception) {
|
||||||
|
// return $this->respondWithError('ResourceNotFound', 404);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// App::error(function (ValidationFailureException $exception) {
|
||||||
|
// $errors = [];
|
||||||
|
// foreach ($exception->getErrors()->getMessages() as $field => $messages) {
|
||||||
|
// $errors[] = [
|
||||||
|
// 'code' => 'ValidationFailure',
|
||||||
|
// 'detail' => implode("\n", $messages),
|
||||||
|
// 'path' => $field
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
// return $this->respondWithErrors($errors, 422);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function respondWithErrors($errors, $httpCode = 500)
|
||||||
|
{
|
||||||
|
return Response::json(['errors' => $errors], $httpCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function respondWithError($error, $httpCode = 500, $detail = null)
|
||||||
|
{
|
||||||
|
$error = ['code' => $error];
|
||||||
|
|
||||||
|
if ($detail) {
|
||||||
|
$error['detail'] = $detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respondWithErrors([$error], $httpCode);
|
||||||
|
}
|
||||||
|
}
|
@ -1,45 +1,41 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Discussions;
|
<?php namespace Flarum\Api\Actions\Discussions;
|
||||||
|
|
||||||
use Event;
|
use Flarum\Core\Commands\StartDiscussionCommand;
|
||||||
|
use Flarum\Core\Commands\ReadDiscussionCommand;
|
||||||
use Flarum\Core\Discussions\Commands\StartDiscussionCommand;
|
use Flarum\Api\Actions\BaseAction;
|
||||||
use Flarum\Core\Discussions\Commands\ReadDiscussionCommand;
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
use Flarum\Api\Actions\Base;
|
|
||||||
use Flarum\Api\Serializers\DiscussionSerializer;
|
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||||
|
|
||||||
class Create extends Base
|
class CreateAction extends BaseAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Start a new discussion.
|
* Start a new discussion.
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
// By default, the only required attributes of a discussion are the
|
// By default, the only required attributes of a discussion are the
|
||||||
// title and the content. We'll extract these from the request data
|
// title and the content. We'll extract these from the rbaseequest data
|
||||||
// and pass them through to the StartDiscussionCommand.
|
// and pass them through to the StartDiscussionCommand.
|
||||||
$title = $this->input('discussions.title');
|
$title = $params->get('discussions.title');
|
||||||
$content = $this->input('discussions.content');
|
$content = $params->get('discussions.content');
|
||||||
$user = User::current();
|
$user = $this->actor->getUser();
|
||||||
$command = new StartDiscussionCommand($title, $content, $user);
|
|
||||||
|
|
||||||
Event::fire('Flarum.Api.Actions.Discussions.Create.WillExecuteCommand', [$command, $this->document]);
|
$command = new StartDiscussionCommand($title, $content, $user, app('flarum.forum'));
|
||||||
|
$discussion = $this->dispatch($command, $params);
|
||||||
$discussion = $this->commandBus->execute($command);
|
|
||||||
|
|
||||||
// After creating the discussion, we assume that the user has seen all
|
// After creating the discussion, we assume that the user has seen all
|
||||||
// of the posts in the discussion; thus, we will mark the discussion
|
// of the posts in the discussion; thus, we will mark the discussion
|
||||||
// as read if they are logged in.
|
// as read if they are logged in.
|
||||||
if ($user->exists) {
|
if ($user->exists) {
|
||||||
$command = new ReadDiscussionCommand($discussion->id, $user, 1);
|
$command = new ReadDiscussionCommand($discussion->id, $user, 1);
|
||||||
$this->commandBus->execute($command);
|
$this->dispatch($command, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$serializer = new DiscussionSerializer(['posts']);
|
$serializer = new DiscussionSerializer(['posts']);
|
||||||
$this->document->setPrimaryElement($serializer->resource($discussion));
|
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
|
||||||
|
|
||||||
return $this->respondWithDocument();
|
return $this->respondWithDocument($document);
|
||||||
}
|
}
|
||||||
}
|
}
|
23
src/Api/Actions/Discussions/DeleteAction.php
Normal file
23
src/Api/Actions/Discussions/DeleteAction.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Discussions;
|
||||||
|
|
||||||
|
use Flarum\Core\Commands\DeleteDiscussionCommand;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
|
||||||
|
class DeleteAction extends BaseAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Delete a discussion.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$discussionId = $params->get('id');
|
||||||
|
|
||||||
|
$command = new DeleteDiscussionCommand($discussionId, $this->actor->getUser());
|
||||||
|
$this->dispatch($command, $params);
|
||||||
|
|
||||||
|
return $this->respondWithoutContent();
|
||||||
|
}
|
||||||
|
}
|
81
src/Api/Actions/Discussions/IndexAction.php
Normal file
81
src/Api/Actions/Discussions/IndexAction.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Discussions;
|
||||||
|
|
||||||
|
use Flarum\Core\Search\Discussions\DiscussionSearchCriteria;
|
||||||
|
use Flarum\Core\Search\Discussions\DiscussionSearcher;
|
||||||
|
use Flarum\Core\Support\Actor;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||||
|
|
||||||
|
class IndexAction extends BaseAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The discussion searcher.
|
||||||
|
*
|
||||||
|
* @var DiscussionSearcher
|
||||||
|
*/
|
||||||
|
protected $searcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate the action.
|
||||||
|
*
|
||||||
|
* @param DiscussionSearcher $searcher
|
||||||
|
*/
|
||||||
|
public function __construct(Actor $actor, DiscussionSearcher $searcher)
|
||||||
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
|
$this->searcher = $searcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a list of discussions.
|
||||||
|
*
|
||||||
|
* @todo custom rate limit for this function? determined by if $key was valid?
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$query = $params->get('q');
|
||||||
|
$start = $params->start();
|
||||||
|
$include = $params->included(['startPost', 'lastPost', 'relevantPosts']);
|
||||||
|
$count = $params->count(20, 50);
|
||||||
|
$sort = $params->sort(['', 'lastPost', 'replies', 'created']);
|
||||||
|
|
||||||
|
$relations = array_merge(['startUser', 'lastUser'], $include);
|
||||||
|
|
||||||
|
// Set up the discussion finder with our search criteria, and get the
|
||||||
|
// requested range of results with the necessary relations loaded.
|
||||||
|
$criteria = new DiscussionSearchCriteria($this->actor->getUser(), $query, $sort['field'], $sort['order']);
|
||||||
|
$load = array_merge($relations, ['state']);
|
||||||
|
|
||||||
|
$results = $this->searcher->search($criteria, $count, $start, $load);
|
||||||
|
|
||||||
|
$document = $this->document();
|
||||||
|
|
||||||
|
if (($total = $results->getTotal()) !== null) {
|
||||||
|
$document->addMeta('total', $total);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are more results, then we need to construct a URL to the
|
||||||
|
// next results page and add that to the metadata. We do this by
|
||||||
|
// compacting all of the valid query parameters which have been
|
||||||
|
// specified.
|
||||||
|
if ($results->areMoreResults()) {
|
||||||
|
$start += $count;
|
||||||
|
$include = implode(',', $include);
|
||||||
|
$sort = $sort['string'];
|
||||||
|
$input = array_filter(compact('query', 'sort', 'start', 'count', 'include'));
|
||||||
|
$moreUrl = $this->buildUrl('discussions.index', [], $input);
|
||||||
|
} else {
|
||||||
|
$moreUrl = '';
|
||||||
|
}
|
||||||
|
$document->addMeta('moreUrl', $moreUrl);
|
||||||
|
|
||||||
|
// Finally, we can set up the discussion serializer and use it to create
|
||||||
|
// a collection of discussion results.
|
||||||
|
$serializer = new DiscussionSerializer($relations);
|
||||||
|
$document->setPrimaryElement($serializer->collection($results->getDiscussions()));
|
||||||
|
|
||||||
|
return $this->respondWithDocument($document);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,24 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Discussions;
|
<?php namespace Flarum\Api\Actions\Discussions;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Discussion;
|
use Flarum\Core\Support\Actor;
|
||||||
use Flarum\Core\Posts\PostRepository;
|
use Flarum\Core\Repositories\DiscussionRepositoryInterface as DiscussionRepository;
|
||||||
use Flarum\Api\Actions\Base;
|
use Flarum\Core\Repositories\PostRepositoryInterface as PostRepository;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Api\Actions\Posts\GetsPostsForDiscussion;
|
use Flarum\Api\Actions\Posts\GetsPostsForDiscussion;
|
||||||
use Flarum\Api\Serializers\DiscussionSerializer;
|
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||||
|
|
||||||
class Show extends Base
|
class ShowAction extends BaseAction
|
||||||
{
|
{
|
||||||
use GetsPostsForDiscussion;
|
use GetsPostsForDiscussion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The discussion repository.
|
||||||
|
*
|
||||||
|
* @var DiscussionRepository
|
||||||
|
*/
|
||||||
|
protected $discussions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The post repository.
|
* The post repository.
|
||||||
*
|
*
|
||||||
@ -22,8 +31,10 @@ class Show extends Base
|
|||||||
*
|
*
|
||||||
* @param PostRepository $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepository $posts)
|
public function __construct(Actor $actor, DiscussionRepository $discussions, PostRepository $posts)
|
||||||
{
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
|
$this->discussions = $discussions;
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,15 +43,15 @@ class Show extends Base
|
|||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
$include = $this->included(['startPost', 'lastPost', 'posts']);
|
$include = $params->included(['startPost', 'lastPost', 'posts']);
|
||||||
|
|
||||||
$discussion = Discussion::whereCanView()->findOrFail($this->param('id'));
|
$discussion = $this->discussions->findOrFail($params->get('id'), $this->actor->getUser());
|
||||||
|
|
||||||
if (in_array('posts', $include)) {
|
if (in_array('posts', $include)) {
|
||||||
$relations = ['user', 'user.groups', 'editUser', 'hideUser'];
|
$relations = ['user', 'user.groups', 'editUser', 'hideUser'];
|
||||||
$discussion->posts = $this->getPostsForDiscussion($this->posts, $discussion->id, $relations);
|
$discussion->posts = $this->getPostsForDiscussion($params, $discussion->id)->load($relations);
|
||||||
|
|
||||||
$include = array_merge($include, array_map(function ($relation) {
|
$include = array_merge($include, array_map(function ($relation) {
|
||||||
return 'posts.'.$relation;
|
return 'posts.'.$relation;
|
||||||
@ -52,8 +63,8 @@ class Show extends Base
|
|||||||
// relations, we will specify that we want the 'posts' relation to be
|
// relations, we will specify that we want the 'posts' relation to be
|
||||||
// linked so that a list of post IDs will show up in the response.
|
// linked so that a list of post IDs will show up in the response.
|
||||||
$serializer = new DiscussionSerializer($include, ['posts']);
|
$serializer = new DiscussionSerializer($include, ['posts']);
|
||||||
$this->document->setPrimaryElement($serializer->resource($discussion));
|
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
|
||||||
|
|
||||||
return $this->respondWithDocument();
|
return $this->respondWithDocument($document);
|
||||||
}
|
}
|
||||||
}
|
}
|
54
src/Api/Actions/Discussions/UpdateAction.php
Normal file
54
src/Api/Actions/Discussions/UpdateAction.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Discussions;
|
||||||
|
|
||||||
|
use Flarum\Core\Commands\EditDiscussionCommand;
|
||||||
|
use Flarum\Core\Commands\ReadDiscussionCommand;
|
||||||
|
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||||
|
|
||||||
|
class UpdateAction extends BaseAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Edit a discussion. Allows renaming the discussion, and updating its read
|
||||||
|
* state with regards to the current user.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$discussionId = $params->get('id');
|
||||||
|
$user = $this->actor->getUser();
|
||||||
|
|
||||||
|
// First, we will run the EditDiscussionCommand. This will update the
|
||||||
|
// discussion's direct properties; by default, this is just the title.
|
||||||
|
// As usual, however, we will fire an event to allow plugins to update
|
||||||
|
// additional properties.
|
||||||
|
if ($data = array_except($params->get('discussions'), ['readNumber'])) {
|
||||||
|
$command = new EditDiscussionCommand($discussionId, $user);
|
||||||
|
$this->hydrate($command, $params->get('discussions'));
|
||||||
|
$discussion = $this->dispatch($command, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, if a read number was specified in the request, we will run the
|
||||||
|
// ReadDiscussionCommand.
|
||||||
|
//
|
||||||
|
// @todo Currently, if the user doesn't have permission to edit a
|
||||||
|
// discussion, they're unable to update their readNumber because a
|
||||||
|
// PermissionsDeniedException is thrown by the
|
||||||
|
// EditDiscussionCommand above. So this needs to be extracted into
|
||||||
|
// its own endpoint.
|
||||||
|
if ($readNumber = $params->get('discussions.readNumber')) {
|
||||||
|
$command = new ReadDiscussionCommand($discussionId, $user, $readNumber);
|
||||||
|
$this->dispatch($command, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Presumably, the discussion was updated successfully. (One of the command
|
||||||
|
// handlers would have thrown an exception if not.) We set this
|
||||||
|
// discussion as our document's primary element.
|
||||||
|
$serializer = new DiscussionSerializer(['addedPosts', 'addedPosts.user']);
|
||||||
|
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
|
||||||
|
|
||||||
|
return $this->respondWithDocument($document);
|
||||||
|
}
|
||||||
|
}
|
@ -1,50 +1,47 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Posts;
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
use Event;
|
use Flarum\Core\Commands\PostReplyCommand;
|
||||||
use Flarum\Core\Posts\Commands\PostReplyCommand;
|
use Flarum\Core\Commands\ReadDiscussionCommand;
|
||||||
use Flarum\Core\Discussions\Commands\ReadDiscussionCommand;
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Api\Actions\BaseAction;
|
||||||
use Flarum\Api\Actions\Base;
|
|
||||||
use Flarum\Api\Serializers\PostSerializer;
|
use Flarum\Api\Serializers\PostSerializer;
|
||||||
|
|
||||||
class Create extends Base
|
class CreateAction extends BaseAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Reply to a discussion.
|
* Reply to a discussion.
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
$user = User::current();
|
$user = $this->actor->getUser();
|
||||||
|
|
||||||
// We've received a request to post a reply. By default, the only
|
// We've received a request to post a reply. By default, the only
|
||||||
// required attributes of a post is the ID of the discussion to post in,
|
// required attributes of a post is the ID of the discussion to post in,
|
||||||
// the post content, and the author's user account. Let's set up a
|
// the post content, and the author's user account. Let's set up a
|
||||||
// command with this information. We also fire an event to allow plugins
|
// command with this information. We also fire an event to allow plugins
|
||||||
// to add data to the command.
|
// to add data to the command.
|
||||||
$discussionId = $this->input('posts.links.discussion');
|
$discussionId = $params->get('posts.links.discussion');
|
||||||
$content = $this->input('posts.content');
|
$content = $params->get('posts.content');
|
||||||
|
|
||||||
$command = new PostReplyCommand($discussionId, $content, $user);
|
$command = new PostReplyCommand($discussionId, $content, $user);
|
||||||
|
$post = $this->dispatch($command, $params);
|
||||||
Event::fire('Flarum.Api.Actions.Posts.Create.WillExecuteCommand', [$command]);
|
|
||||||
|
|
||||||
$post = $this->commandBus->execute($command);
|
|
||||||
|
|
||||||
// After replying, we assume that the user has seen all of the posts
|
// 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
|
// in the discussion; thus, we will mark the discussion as read if
|
||||||
// they are logged in.
|
// they are logged in.
|
||||||
if ($user->exists) {
|
if ($user->exists) {
|
||||||
$command = new ReadDiscussionCommand($discussionId, $user, $post->number);
|
$command = new ReadDiscussionCommand($discussionId, $user, $post->number);
|
||||||
$this->commandBus->execute($command);
|
$this->dispatch($command, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Presumably, the post was created successfully. (The command handler
|
// Presumably, the post was created successfully. (The command handler
|
||||||
// would have thrown an exception if not.) We set this post as our
|
// would have thrown an exception if not.) We set this post as our
|
||||||
// document's primary element.
|
// document's primary element.
|
||||||
$serializer = new PostSerializer;
|
$serializer = new PostSerializer;
|
||||||
$this->document->setPrimaryElement($serializer->resource($post));
|
$document = $this->document()->setPrimaryElement($serializer->resource($post));
|
||||||
|
|
||||||
return $this->respondWithDocument(201);
|
return $this->respondWithDocument($document, 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
23
src/Api/Actions/Posts/DeleteAction.php
Normal file
23
src/Api/Actions/Posts/DeleteAction.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
|
use Flarum\Core\Commands\DeletePostCommand;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
|
||||||
|
class DeleteAction extends BaseAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Delete a post.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$postId = $params->get('id');
|
||||||
|
|
||||||
|
$command = new DeletePostCommand($postId, $this->actor->getUser());
|
||||||
|
$this->dispatch($command, $params);
|
||||||
|
|
||||||
|
return $this->respondWithoutContent();
|
||||||
|
}
|
||||||
|
}
|
31
src/Api/Actions/Posts/GetsPostsForDiscussion.php
Normal file
31
src/Api/Actions/Posts/GetsPostsForDiscussion.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
|
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||||
|
use Flarum\Core\Models\User;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
|
||||||
|
trait GetsPostsForDiscussion
|
||||||
|
{
|
||||||
|
protected function getPostsForDiscussion(ApiParams $params, $discussionId)
|
||||||
|
{
|
||||||
|
$sort = $params->sort(['time']);
|
||||||
|
$count = $params->count(20, 50);
|
||||||
|
$user = $this->actor->getUser();
|
||||||
|
|
||||||
|
if (($near = $params->get('near')) > 1) {
|
||||||
|
$start = $this->posts->getIndexForNumber($discussionId, $near, $user);
|
||||||
|
$start = max(0, $start - $count / 2);
|
||||||
|
} else {
|
||||||
|
$start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->posts->findByDiscussion(
|
||||||
|
$discussionId,
|
||||||
|
$user,
|
||||||
|
$sort['field'],
|
||||||
|
$sort['order'] ?: 'asc',
|
||||||
|
$count,
|
||||||
|
$start
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,31 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Posts;
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||||
use Flarum\Core\Posts\PostRepository;
|
use Flarum\Core\Support\Actor;
|
||||||
use Flarum\Api\Actions\Base;
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Api\Serializers\PostSerializer;
|
use Flarum\Api\Serializers\PostSerializer;
|
||||||
|
|
||||||
class Index extends Base
|
class IndexAction extends BaseAction
|
||||||
{
|
{
|
||||||
use GetsPostsForDiscussion;
|
use GetsPostsForDiscussion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The post repository.
|
* The post repository.
|
||||||
*
|
*
|
||||||
* @var PostRepository
|
* @var Post
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate the action.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
* @param PostRepository $posts
|
* @param Post $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepository $posts)
|
public function __construct(Actor $actor, PostRepositoryInterface $posts)
|
||||||
{
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,16 +34,17 @@ class Index extends Base
|
|||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
$postIds = (array) $this->input('ids');
|
$postIds = (array) $params->get('ids');
|
||||||
$include = ['user', 'user.groups', 'editUser', 'hideUser'];
|
$include = ['user', 'user.groups', 'editUser', 'hideUser'];
|
||||||
|
$user = $this->actor->getUser();
|
||||||
|
|
||||||
if (count($postIds)) {
|
if (count($postIds)) {
|
||||||
$posts = $this->posts->findMany($postIds, $include);
|
$posts = $this->posts->findByIds($postIds, $user);
|
||||||
} else {
|
} else {
|
||||||
$discussionId = $this->input('discussions');
|
$discussionId = $params->get('discussions');
|
||||||
$posts = $this->getPostsForDiscussion($this->posts, $discussionId, $include);
|
$posts = $this->getPostsForDiscussion($params, $discussionId, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! count($posts)) {
|
if (! count($posts)) {
|
||||||
@ -52,8 +55,8 @@ class Index extends Base
|
|||||||
// a post resource or collection, depending on how many posts were
|
// a post resource or collection, depending on how many posts were
|
||||||
// requested.
|
// requested.
|
||||||
$serializer = new PostSerializer($include);
|
$serializer = new PostSerializer($include);
|
||||||
$this->document->setPrimaryElement($serializer->collection($posts));
|
$document = $this->document()->setPrimaryElement($serializer->collection($posts->load($include)));
|
||||||
|
|
||||||
return $this->respondWithDocument();
|
return $this->respondWithDocument($document);
|
||||||
}
|
}
|
||||||
}
|
}
|
42
src/Api/Actions/Posts/ShowAction.php
Normal file
42
src/Api/Actions/Posts/ShowAction.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||||
|
use Flarum\Core\Support\Actor;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
use Flarum\Api\Serializers\PostSerializer;
|
||||||
|
|
||||||
|
class ShowAction extends BaseAction
|
||||||
|
{
|
||||||
|
protected $posts;
|
||||||
|
|
||||||
|
public function __construct(Actor $actor, PostRepositoryInterface $posts)
|
||||||
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
|
$this->posts = $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a single post by ID.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$id = $params->get('id');
|
||||||
|
$posts = $this->posts->findOrFail($id, $this->actor->getUser());
|
||||||
|
|
||||||
|
$include = $params->included(['discussion', 'replyTo']);
|
||||||
|
$relations = array_merge(['user', 'editUser', 'hideUser'], $include);
|
||||||
|
$posts->load($relations);
|
||||||
|
|
||||||
|
// Finally, we can set up the post serializer and use it to create
|
||||||
|
// a post resource or collection, depending on how many posts were
|
||||||
|
// requested.
|
||||||
|
$serializer = new PostSerializer($relations);
|
||||||
|
$document = $this->document()->setPrimaryElement($serializer->resource($posts->first()));
|
||||||
|
|
||||||
|
return $this->respondWithDocument($document);
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +1,34 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Posts;
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
use Event;
|
use Flarum\Core\Commands\EditPostCommand;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Core\Posts\Commands\EditPostCommand;
|
use Flarum\Api\Actions\BaseAction;
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
use Flarum\Api\Actions\Base;
|
|
||||||
use Flarum\Api\Serializers\PostSerializer;
|
use Flarum\Api\Serializers\PostSerializer;
|
||||||
|
|
||||||
class Update extends Base
|
class UpdateAction extends BaseAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Edit a post. Allows revision of content, and hiding/unhiding.
|
* Edit a post. Allows revision of content, and hiding/unhiding.
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
$postId = $this->param('id');
|
$postId = $params->get('id');
|
||||||
|
|
||||||
// EditPost is a single command because we don't want to allow partial
|
// EditPost is a single command because we don't want to allow partial
|
||||||
// updates (i.e. if we were to run one command and then another, if the
|
// updates (i.e. if we were to run one command and then another, if the
|
||||||
// second one failed, the first one would still have succeeded.)
|
// second one failed, the first one would still have succeeded.)
|
||||||
$command = new EditPostCommand($postId, User::current());
|
$command = new EditPostCommand($postId, $this->actor->getUser());
|
||||||
$this->fillCommandWithInput($command, 'posts');
|
$this->hydrate($command, $params->get('posts'));
|
||||||
|
$post = $this->dispatch($command, $params);
|
||||||
Event::fire('Flarum.Api.Actions.Posts.Update.WillExecuteCommand', [$command]);
|
|
||||||
|
|
||||||
$post = $this->commandBus->execute($command);
|
|
||||||
|
|
||||||
// Presumably, the post was updated successfully. (The command handler
|
// Presumably, the post was updated successfully. (The command handler
|
||||||
// would have thrown an exception if not.) We set this post as our
|
// would have thrown an exception if not.) We set this post as our
|
||||||
// document's primary element.
|
// document's primary element.
|
||||||
$serializer = new PostSerializer;
|
$serializer = new PostSerializer;
|
||||||
$this->document->setPrimaryElement($serializer->resource($post));
|
$document = $this->document()->setPrimaryElement($serializer->resource($post));
|
||||||
|
|
||||||
return $this->respondWithDocument();
|
return $this->respondWithDocument($document);
|
||||||
}
|
}
|
||||||
}
|
}
|
43
src/Api/Actions/TokenAction.php
Normal file
43
src/Api/Actions/TokenAction.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Flarum\Core\Commands\GenerateAccessTokenCommand;
|
||||||
|
use Flarum\Core\Repositories\UserRepositoryInterface;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
|
||||||
|
class TokenAction extends BaseAction
|
||||||
|
{
|
||||||
|
protected $users;
|
||||||
|
|
||||||
|
public function __construct(UserRepositoryInterface $users, Dispatcher $bus)
|
||||||
|
{
|
||||||
|
$this->users = $users;
|
||||||
|
$this->bus = $bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log in and return a token.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$identification = $params->get('identification');
|
||||||
|
$password = $params->get('password');
|
||||||
|
|
||||||
|
$user = $this->users->findByIdentification($identification);
|
||||||
|
|
||||||
|
if (! $user || ! $user->checkPassword($password)) {
|
||||||
|
return $this->respondWithError('invalidLogin', 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$command = new GenerateAccessTokenCommand($user->id);
|
||||||
|
$token = $this->dispatch($command, $params);
|
||||||
|
|
||||||
|
return new JsonResponse([
|
||||||
|
'token' => $token->id,
|
||||||
|
'userId' => $user->id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +1,36 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Users;
|
<?php namespace Flarum\Api\Actions\Users;
|
||||||
|
|
||||||
use Event;
|
use Flarum\Core\Commands\RegisterUserCommand;
|
||||||
use Flarum\Core\Users\Commands\RegisterUserCommand;
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Api\Actions\BaseAction;
|
||||||
use Flarum\Api\Actions\Base;
|
|
||||||
use Flarum\Api\Serializers\UserSerializer;
|
use Flarum\Api\Serializers\UserSerializer;
|
||||||
|
|
||||||
class Create extends Base
|
class CreateAction extends BaseAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Register a user.
|
* Register a user.
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
// We've received a request to register a user. By default, the only
|
// We've received a request to register a user. By default, the only
|
||||||
// required attributes of a user is the username, email, and password.
|
// required attributes of a user is the username, email, and password.
|
||||||
// Let's set up a command with this information. We also fire an event
|
// Let's set up a command with this information. We also fire an event
|
||||||
// to allow plugins to add data to the command.
|
// to allow plugins to add data to the command.
|
||||||
$username = $this->input('users.username');
|
$username = $params->get('users.username');
|
||||||
$email = $this->input('users.email');
|
$email = $params->get('users.email');
|
||||||
$password = $this->input('users.password');
|
$password = $params->get('users.password');
|
||||||
$command = new RegisterUserCommand($username, $email, $password, User::current());
|
|
||||||
|
|
||||||
Event::fire('Flarum.Api.Actions.Users.Create.WillExecuteCommand', [$command]);
|
$command = new RegisterUserCommand($username, $email, $password, $this->actor->getUser());
|
||||||
|
$this->dispatch($command, $params);
|
||||||
$user = $this->commandBus->execute($command);
|
|
||||||
|
|
||||||
// Presumably, the user was created successfully. (The command handler
|
// Presumably, the user was created successfully. (The command handler
|
||||||
// would have thrown an exception if not.) We set this post as our
|
// would have thrown an exception if not.) We set this post as our
|
||||||
// document's primary element.
|
// document's primary element.
|
||||||
$serializer = new UserSerializer;
|
$serializer = new UserSerializer;
|
||||||
$this->document->setPrimaryElement($serializer->resource($user));
|
$document = $this->document()->setPrimaryElement($serializer->resource($user));
|
||||||
|
|
||||||
return $this->respondWithDocument(201);
|
return $this->respondWithDocument($document, 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
23
src/Api/Actions/Users/DeleteAction.php
Normal file
23
src/Api/Actions/Users/DeleteAction.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Users;
|
||||||
|
|
||||||
|
use Flarum\Core\Commands\DeleteUserCommand;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
|
||||||
|
class DeleteAction extends BaseAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Delete a user.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$userId = $params->get('id');
|
||||||
|
|
||||||
|
$command = new DeleteUserCommand($userId, $this->actor->getUser());
|
||||||
|
$this->dispatch($command, $params);
|
||||||
|
|
||||||
|
return $this->respondWithoutContent();
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ use Flarum\Core\Users\UserFinder;
|
|||||||
use Flarum\Api\Actions\Base;
|
use Flarum\Api\Actions\Base;
|
||||||
use Flarum\Api\Serializers\UserSerializer;
|
use Flarum\Api\Serializers\UserSerializer;
|
||||||
|
|
||||||
class Index extends Base
|
class IndexAction extends BaseAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The user finder.
|
* The user finder.
|
38
src/Api/Actions/Users/ShowAction.php
Normal file
38
src/Api/Actions/Users/ShowAction.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Users;
|
||||||
|
|
||||||
|
use Flarum\Core\Repositories\UserRepositoryInterface;
|
||||||
|
use Flarum\Core\Support\Actor;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
|
use Flarum\Api\Actions\BaseAction;
|
||||||
|
use Flarum\Api\Serializers\UserSerializer;
|
||||||
|
|
||||||
|
class ShowAction extends BaseAction
|
||||||
|
{
|
||||||
|
protected $actor;
|
||||||
|
|
||||||
|
protected $users;
|
||||||
|
|
||||||
|
public function __construct(Actor $actor, UserRepositoryInterface $users)
|
||||||
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
|
$this->users = $users;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a single user.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function run(ApiParams $params)
|
||||||
|
{
|
||||||
|
$user = $this->users->findOrFail($params->get('id'), $this->actor->getUser());
|
||||||
|
|
||||||
|
// Set up the user serializer, which we will use to create the
|
||||||
|
// document's primary resource. We will specify that we want the
|
||||||
|
// 'groups' relation to be included by default.
|
||||||
|
$serializer = new UserSerializer(['groups']);
|
||||||
|
$document = $this->document()->setPrimaryElement($serializer->resource($user));
|
||||||
|
|
||||||
|
return $this->respondWithDocument($document);
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,11 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Users;
|
<?php namespace Flarum\Api\Actions\Users;
|
||||||
|
|
||||||
use Event;
|
use Flarum\Core\Commands\EditUserCommand;
|
||||||
|
use Flarum\Api\Actions\ApiParams;
|
||||||
use Flarum\Core\Users\Commands\EditUserCommand;
|
use Flarum\Api\Actions\BaseAction;
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
use Flarum\Api\Actions\Base;
|
|
||||||
use Flarum\Api\Serializers\UserSerializer;
|
use Flarum\Api\Serializers\UserSerializer;
|
||||||
|
|
||||||
class Update extends Base
|
class UpdateAction extends BaseAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Edit a user. Allows renaming the user, changing their email, and setting
|
* Edit a user. Allows renaming the user, changing their email, and setting
|
||||||
@ -15,26 +13,23 @@ class Update extends Base
|
|||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function run()
|
protected function run(ApiParams $params)
|
||||||
{
|
{
|
||||||
$userId = $this->param('id');
|
$userId = $params->get('id');
|
||||||
|
|
||||||
// EditUser is a single command because we don't want to allow partial
|
// EditUser is a single command because we don't want to allow partial
|
||||||
// updates (i.e. if we were to run one command and then another, if the
|
// updates (i.e. if we were to run one command and then another, if the
|
||||||
// second one failed, the first one would still have succeeded.)
|
// second one failed, the first one would still have succeeded.)
|
||||||
$command = new EditUserCommand($userId, User::current());
|
$command = new EditUserCommand($userId, $this->actor->getUser());
|
||||||
$this->fillCommandWithInput($command, 'users');
|
$this->hydrate($command, $params->get('users'));
|
||||||
|
$this->dispatch($command);
|
||||||
Event::fire('Flarum.Api.Actions.Users.Update.WillExecuteCommand', [$command]);
|
|
||||||
|
|
||||||
$user = $this->commandBus->execute($command);
|
|
||||||
|
|
||||||
// Presumably, the user was updated successfully. (The command handler
|
// Presumably, the user was updated successfully. (The command handler
|
||||||
// would have thrown an exception if not.) We set this user as our
|
// would have thrown an exception if not.) We set this user as our
|
||||||
// document's primary element.
|
// document's primary element.
|
||||||
$serializer = new UserSerializer;
|
$serializer = new UserSerializer;
|
||||||
$this->document->setPrimaryElement($serializer->resource($user));
|
$document = $this->document()->setPrimaryElement($serializer->resource($user));
|
||||||
|
|
||||||
return $this->respondWithDocument();
|
return $this->respondWithDocument($document);
|
||||||
}
|
}
|
||||||
}
|
}
|
29
src/Api/ApiServiceProvider.php
Normal file
29
src/Api/ApiServiceProvider.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php namespace Flarum\Api;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Flarum\Api\Serializers\BaseSerializer;
|
||||||
|
|
||||||
|
class ApiServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
include __DIR__.'/routes.php';
|
||||||
|
|
||||||
|
BaseSerializer::setActor($this->app['Flarum\Core\Support\Actor']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->app->singleton('Flarum\Core\Support\Actor');
|
||||||
|
}
|
||||||
|
}
|
14
src/Api/Events/CommandWillBeDispatched.php
Normal file
14
src/Api/Events/CommandWillBeDispatched.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php namespace Flarum\Api\Events;
|
||||||
|
|
||||||
|
class CommandWillBeDispatched
|
||||||
|
{
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public $params;
|
||||||
|
|
||||||
|
public function __construct($command, $params)
|
||||||
|
{
|
||||||
|
$this->command = $command;
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
|
}
|
17
src/Api/Events/SerializeAttributes.php
Normal file
17
src/Api/Events/SerializeAttributes.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php namespace Flarum\Api\Events;
|
||||||
|
|
||||||
|
class SerializeAttributes
|
||||||
|
{
|
||||||
|
public $serializer;
|
||||||
|
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
public $attributes;
|
||||||
|
|
||||||
|
public function __construct($serializer, $model, &$attributes)
|
||||||
|
{
|
||||||
|
$this->serializer = $serializer;
|
||||||
|
$this->model = $model;
|
||||||
|
$this->attributes = $attributes;
|
||||||
|
}
|
||||||
|
}
|
23
src/Api/Events/SerializeRelationship.php
Normal file
23
src/Api/Events/SerializeRelationship.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php namespace Flarum\Api\Events;
|
||||||
|
|
||||||
|
class SerializeRelationship
|
||||||
|
{
|
||||||
|
public $serializer;
|
||||||
|
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
public $relations;
|
||||||
|
|
||||||
|
public function __construct($serializer, $model, $type, $name, $relations)
|
||||||
|
{
|
||||||
|
$this->serializer = $serializer;
|
||||||
|
$this->model = $model;
|
||||||
|
$this->type = $type;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->relations = $relations;
|
||||||
|
}
|
||||||
|
}
|
17
src/Api/Events/WillRespondWithDocument.php
Normal file
17
src/Api/Events/WillRespondWithDocument.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php namespace Flarum\Api\Events;
|
||||||
|
|
||||||
|
class WillRespondWithDocument
|
||||||
|
{
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
public $statusCode;
|
||||||
|
|
||||||
|
public $headers;
|
||||||
|
|
||||||
|
public function __construct($document, &$statusCode, &$headers)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
$this->statusCode = $statusCode;
|
||||||
|
$this->headers = $headers;
|
||||||
|
}
|
||||||
|
}
|
29
src/Api/Middleware/LoginWithHeaderMiddleware.php
Normal file
29
src/Api/Middleware/LoginWithHeaderMiddleware.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php namespace Flarum\Api\Middleware;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\AccessToken;
|
||||||
|
use Flarum\Core\Support\Actor;
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class LoginWithHeaderMiddleware
|
||||||
|
{
|
||||||
|
protected $actor;
|
||||||
|
|
||||||
|
protected $prefix = 'Token ';
|
||||||
|
|
||||||
|
public function __construct(Actor $actor)
|
||||||
|
{
|
||||||
|
$this->actor = $actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
$header = $request->headers->get('authorization');
|
||||||
|
if (starts_with($header, $this->prefix) &&
|
||||||
|
($token = substr($header, strlen($this->prefix))) &&
|
||||||
|
($accessToken = AccessToken::where('id', $token)->first())) {
|
||||||
|
$this->actor->setUser($accessToken->user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
62
src/Api/Serializers/BaseSerializer.php
Normal file
62
src/Api/Serializers/BaseSerializer.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
|
use Tobscure\JsonApi\SerializerAbstract;
|
||||||
|
use Flarum\Api\Events\SerializeAttributes;
|
||||||
|
use Flarum\Api\Events\SerializeRelationship;
|
||||||
|
use Flarum\Core\Support\Actor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base serializer to call Flarum events at common serialization points.
|
||||||
|
*/
|
||||||
|
abstract class BaseSerializer extends SerializerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The actor who is requesting the serialized objects.
|
||||||
|
*
|
||||||
|
* @var \Flarum\Core\Support\Actor
|
||||||
|
*/
|
||||||
|
protected static $actor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the actor who is requesting the serialized objects.
|
||||||
|
*
|
||||||
|
* @param \Flarum\Core\Support\Actor $actor
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function setActor(Actor $actor)
|
||||||
|
{
|
||||||
|
static::$actor = $actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire an event to allow custom serialization of attributes.
|
||||||
|
*
|
||||||
|
* @param mixed $model The model to serialize.
|
||||||
|
* @param array $attributes Attributes that have already been serialized.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function attributesEvent($model, $attributes = [])
|
||||||
|
{
|
||||||
|
event(new SerializeAttributes($this, $model, $attributes));
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire an event to allow for custom links and includes.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array $arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __call($name, $arguments)
|
||||||
|
{
|
||||||
|
if ($link = starts_with($name, 'link') || starts_with($name, 'include')) {
|
||||||
|
$model = isset($arguments[0]) ? $arguments[0] : null;
|
||||||
|
$relations = isset($arguments[1]) ? $arguments[1] : null;
|
||||||
|
$type = $link ? 'link' : 'include';
|
||||||
|
$name = substr($name, strlen($type));
|
||||||
|
return event(new SerializeRelationship($this, $model, $type, $name, $relations), null, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,9 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Discussion;
|
use Flarum\Core\Models\Discussion;
|
||||||
|
|
||||||
class DiscussionBasicSerializer extends BaseSerializer
|
class DiscussionBasicSerializer extends BaseSerializer
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The name to use for Flarum events.
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected static $eventName = 'DiscussionBasic';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resource type.
|
* The resource type.
|
||||||
* @var string
|
* @var string
|
@ -1,16 +1,10 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Discussion;
|
use Flarum\Core\Models\Discussion;
|
||||||
use Flarum\Core\Discussions\DiscussionState;
|
use Flarum\Core\Models\DiscussionState;
|
||||||
|
|
||||||
class DiscussionSerializer extends DiscussionBasicSerializer
|
class DiscussionSerializer extends DiscussionBasicSerializer
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The name to use for Flarum events.
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected static $eventName = 'Discussion';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default relations to include.
|
* Default relations to include.
|
||||||
* @var array
|
* @var array
|
||||||
@ -27,22 +21,25 @@ class DiscussionSerializer extends DiscussionBasicSerializer
|
|||||||
{
|
{
|
||||||
$attributes = parent::attributes($discussion);
|
$attributes = parent::attributes($discussion);
|
||||||
|
|
||||||
$state = $discussion->state;
|
$user = static::$actor->getUser();
|
||||||
|
$state = $discussion->stateFor($user);
|
||||||
|
|
||||||
$attributes += [
|
$attributes += [
|
||||||
'commentsCount' => (int) $discussion->comments_count,
|
'commentsCount' => (int) $discussion->comments_count,
|
||||||
'startTime' => $discussion->start_time->toRFC3339String(),
|
'startTime' => $discussion->start_time->toRFC3339String(),
|
||||||
'lastTime' => $discussion->last_time ? $discussion->last_time->toRFC3339String() : null,
|
'lastTime' => $discussion->last_time ? $discussion->last_time->toRFC3339String() : null,
|
||||||
'lastPostNumber' => $discussion->last_post_number,
|
'lastPostNumber' => $discussion->last_post_number,
|
||||||
'canReply' => $discussion->permission('reply'),
|
'canReply' => $discussion->can($user, 'reply'),
|
||||||
'canEdit' => $discussion->permission('edit'),
|
'canEdit' => $discussion->can($user, 'edit'),
|
||||||
'canDelete' => $discussion->permission('delete'),
|
'canDelete' => $discussion->can($user, 'delete'),
|
||||||
|
|
||||||
'readTime' => $state && $state->read_time ? $state->read_time->toRFC3339String() : null,
|
'readTime' => $state && $state->read_time ? $state->read_time->toRFC3339String() : null,
|
||||||
'readNumber' => $state ? (int) $state->read_number : 0
|
'readNumber' => $state ? (int) $state->read_number : 0
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->attributesEvent($discussion, $attributes);
|
$this->attributesEvent($discussion, $attributes);
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +50,9 @@ class DiscussionSerializer extends DiscussionBasicSerializer
|
|||||||
*/
|
*/
|
||||||
public function linkPosts(Discussion $discussion)
|
public function linkPosts(Discussion $discussion)
|
||||||
{
|
{
|
||||||
return (new PostBasicSerializer)->collection($discussion->posts()->whereCanView()->orderBy('time', 'asc')->ids());
|
$user = static::$actor->getUser();
|
||||||
|
|
||||||
|
return (new PostBasicSerializer)->collection($discussion->posts()->whereCan($user, 'view')->orderBy('time', 'asc')->ids());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Groups\Group;
|
use Flarum\Core\Models\Group;
|
||||||
|
|
||||||
class GroupSerializer extends BaseSerializer
|
class GroupSerializer extends BaseSerializer
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
class PostBasicSerializer extends BaseSerializer
|
class PostBasicSerializer extends BaseSerializer
|
||||||
{
|
{
|
@ -1,16 +1,10 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class PostSerializer extends PostBasicSerializer
|
class PostSerializer extends PostBasicSerializer
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The name to use for Flarum events.
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected static $eventName = 'Post';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default relations to link.
|
* Default relations to link.
|
||||||
* @var array
|
* @var array
|
||||||
@ -32,7 +26,7 @@ class PostSerializer extends PostBasicSerializer
|
|||||||
protected function attributes(Post $post)
|
protected function attributes(Post $post)
|
||||||
{
|
{
|
||||||
$attributes = parent::attributes($post);
|
$attributes = parent::attributes($post);
|
||||||
$user = User::current();
|
$user = static::$actor->getUser();
|
||||||
|
|
||||||
unset($attributes['content']);
|
unset($attributes['content']);
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class UserBasicSerializer extends BaseSerializer
|
class UserBasicSerializer extends BaseSerializer
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Serializers;
|
<?php namespace Flarum\Api\Serializers;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class UserSerializer extends UserBasicSerializer
|
class UserSerializer extends UserBasicSerializer
|
||||||
{
|
{
|
||||||
@ -26,16 +26,32 @@ class UserSerializer extends UserBasicSerializer
|
|||||||
{
|
{
|
||||||
$attributes = parent::attributes($user);
|
$attributes = parent::attributes($user);
|
||||||
|
|
||||||
|
$actorUser = static::$actor->getUser();
|
||||||
|
$canEdit = $user->can($actorUser, 'edit');
|
||||||
|
|
||||||
$attributes += [
|
$attributes += [
|
||||||
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
|
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
|
||||||
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
|
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
|
||||||
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
|
|
||||||
'discussionsCount' => (int) $user->discussions_count,
|
'discussionsCount' => (int) $user->discussions_count,
|
||||||
'postsCount' => (int) $user->posts_count,
|
'postsCount' => (int) $user->posts_count,
|
||||||
'canEdit' => $user->permission('edit'),
|
'canEdit' => $canEdit,
|
||||||
'canDelete' => $user->permission('delete'),
|
'canDelete' => $user->can($actorUser, 'delete'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($canEdit) {
|
||||||
|
$attributes += [
|
||||||
|
'isActivated' => $user->is_activated,
|
||||||
|
'email' => $user->email,
|
||||||
|
'isConfirmed' => $user->is_confirmed
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->id === $actorUser->id) {
|
||||||
|
$attributes += [
|
||||||
|
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->attributesEvent($user, $attributes);
|
return $this->attributesEvent($user, $attributes);
|
||||||
}
|
}
|
||||||
|
|
@ -2,36 +2,18 @@
|
|||||||
|
|
||||||
$action = function ($class) {
|
$action = function ($class) {
|
||||||
return function () use ($class) {
|
return function () use ($class) {
|
||||||
$action = App::make($class);
|
$action = $this->app->make($class);
|
||||||
$request = app('request');
|
$request = $this->app['request']->instance();
|
||||||
$parameters = Route::current()->parameters();
|
$parameters = $this->app['router']->current()->parameters();
|
||||||
return $action->handle($request, $parameters);
|
return $action->handle($request, $parameters);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// @todo refactor into a unit-testable class
|
Route::group(['prefix' => 'api', 'middleware' => 'Flarum\Api\Middleware\LoginWithHeaderMiddleware'], function () use ($action) {
|
||||||
Route::filter('attemptLogin', function($route, $request) {
|
|
||||||
$prefix = 'Token ';
|
|
||||||
if (starts_with($request->headers->get('authorization'), $prefix)) {
|
|
||||||
$token = substr($request->headers->get('authorization'), strlen($prefix));
|
|
||||||
if ($user = Flarum\Core\Users\User::where('token', $token)->first()) {
|
|
||||||
Auth::setUser($user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($action) {
|
Route::post('token', [
|
||||||
|
'as' => 'flarum.api.token',
|
||||||
/*
|
'uses' => $action('Flarum\Api\Actions\TokenAction')
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Auth
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Login
|
|
||||||
Route::post('auth/login', [
|
|
||||||
'as' => 'flarum.api.auth.login',
|
|
||||||
'uses' => $action('Flarum\Api\Actions\Auth\Login')
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,31 +25,31 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
|||||||
// List users
|
// List users
|
||||||
Route::get('users', [
|
Route::get('users', [
|
||||||
'as' => 'flarum.api.users.index',
|
'as' => 'flarum.api.users.index',
|
||||||
'uses' => $action('Flarum\Api\Actions\Users\Index')
|
'uses' => $action('Flarum\Api\Actions\Users\IndexAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Register a user
|
// Register a user
|
||||||
Route::post('users', [
|
Route::post('users', [
|
||||||
'as' => 'flarum.api.users.create',
|
'as' => 'flarum.api.users.create',
|
||||||
'uses' => $action('Flarum\Api\Actions\Users\Create')
|
'uses' => $action('Flarum\Api\Actions\Users\CreateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Get a single user
|
// Get a single user
|
||||||
Route::get('users/{id}', [
|
Route::get('users/{id}', [
|
||||||
'as' => 'flarum.api.users.show',
|
'as' => 'flarum.api.users.show',
|
||||||
'uses' => $action('Flarum\Api\Actions\Users\Show')
|
'uses' => $action('Flarum\Api\Actions\Users\ShowAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Edit a user
|
// Edit a user
|
||||||
Route::put('users/{id}', [
|
Route::put('users/{id}', [
|
||||||
'as' => 'flarum.api.users.update',
|
'as' => 'flarum.api.users.update',
|
||||||
'uses' => $action('Flarum\Api\Actions\Users\Update')
|
'uses' => $action('Flarum\Api\Actions\Users\UpdateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Delete a user
|
// Delete a user
|
||||||
Route::delete('users/{id}', [
|
Route::delete('users/{id}', [
|
||||||
'as' => 'flarum.api.users.delete',
|
'as' => 'flarum.api.users.delete',
|
||||||
'uses' => $action('Flarum\Api\Actions\Users\Delete')
|
'uses' => $action('Flarum\Api\Actions\Users\DeleteAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -79,13 +61,13 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
|||||||
// List activity
|
// List activity
|
||||||
Route::get('activity', [
|
Route::get('activity', [
|
||||||
'as' => 'flarum.api.activity.index',
|
'as' => 'flarum.api.activity.index',
|
||||||
'uses' => $action('Flarum\Api\Actions\Activity\Index')
|
'uses' => $action('Flarum\Api\Actions\Activity\IndexAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// List notifications for the current user
|
// List notifications for the current user
|
||||||
Route::get('notifications', [
|
Route::get('notifications', [
|
||||||
'as' => 'flarum.api.notifications.index',
|
'as' => 'flarum.api.notifications.index',
|
||||||
'uses' => $action('Flarum\Api\Actions\Notifications\Index')
|
'uses' => $action('Flarum\Api\Actions\Notifications\IndexAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -97,31 +79,31 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
|||||||
// List discussions
|
// List discussions
|
||||||
Route::get('discussions', [
|
Route::get('discussions', [
|
||||||
'as' => 'flarum.api.discussions.index',
|
'as' => 'flarum.api.discussions.index',
|
||||||
'uses' => $action('Flarum\Api\Actions\Discussions\Index')
|
'uses' => $action('Flarum\Api\Actions\Discussions\IndexAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Create a discussion
|
// Create a discussion
|
||||||
Route::post('discussions', [
|
Route::post('discussions', [
|
||||||
'as' => 'flarum.api.discussions.create',
|
'as' => 'flarum.api.discussions.create',
|
||||||
'uses' => $action('Flarum\Api\Actions\Discussions\Create')
|
'uses' => $action('Flarum\Api\Actions\Discussions\CreateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Show a single discussion
|
// Show a single discussion
|
||||||
Route::get('discussions/{id}', [
|
Route::get('discussions/{id}', [
|
||||||
'as' => 'flarum.api.discussions.show',
|
'as' => 'flarum.api.discussions.show',
|
||||||
'uses' => $action('Flarum\Api\Actions\Discussions\Show')
|
'uses' => $action('Flarum\Api\Actions\Discussions\ShowAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Edit a discussion
|
// Edit a discussion
|
||||||
Route::put('discussions/{id}', [
|
Route::put('discussions/{id}', [
|
||||||
'as' => 'flarum.api.discussions.update',
|
'as' => 'flarum.api.discussions.update',
|
||||||
'uses' => $action('Flarum\Api\Actions\Discussions\Update')
|
'uses' => $action('Flarum\Api\Actions\Discussions\UpdateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Delete a discussion
|
// Delete a discussion
|
||||||
Route::delete('discussions/{id}', [
|
Route::delete('discussions/{id}', [
|
||||||
'as' => 'flarum.api.discussions.delete',
|
'as' => 'flarum.api.discussions.delete',
|
||||||
'uses' => $action('Flarum\Api\Actions\Discussions\Delete')
|
'uses' => $action('Flarum\Api\Actions\Discussions\DeleteAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -133,32 +115,32 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
|||||||
// List posts, usually for a discussion
|
// List posts, usually for a discussion
|
||||||
Route::get('posts', [
|
Route::get('posts', [
|
||||||
'as' => 'flarum.api.posts.index',
|
'as' => 'flarum.api.posts.index',
|
||||||
'uses' => $action('Flarum\Api\Actions\Posts\Index')
|
'uses' => $action('Flarum\Api\Actions\Posts\IndexAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Create a post
|
// Create a post
|
||||||
// @todo consider 'discussions/{id}/links/posts'?
|
// @todo consider 'discussions/{id}/links/posts'?
|
||||||
Route::post('posts', [
|
Route::post('posts', [
|
||||||
'as' => 'flarum.api.posts.create',
|
'as' => 'flarum.api.posts.create',
|
||||||
'uses' => $action('Flarum\Api\Actions\Posts\Create')
|
'uses' => $action('Flarum\Api\Actions\Posts\CreateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Show a single or multiple posts by ID
|
// Show a single or multiple posts by ID
|
||||||
Route::get('posts/{id}', [
|
Route::get('posts/{id}', [
|
||||||
'as' => 'flarum.api.posts.show',
|
'as' => 'flarum.api.posts.show',
|
||||||
'uses' => $action('Flarum\Api\Actions\Posts\Show')
|
'uses' => $action('Flarum\Api\Actions\Posts\ShowAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Edit a post
|
// Edit a post
|
||||||
Route::put('posts/{id}', [
|
Route::put('posts/{id}', [
|
||||||
'as' => 'flarum.api.posts.update',
|
'as' => 'flarum.api.posts.update',
|
||||||
'uses' => $action('Flarum\Api\Actions\Posts\Update')
|
'uses' => $action('Flarum\Api\Actions\Posts\UpdateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Delete a post
|
// Delete a post
|
||||||
Route::delete('posts/{id}', [
|
Route::delete('posts/{id}', [
|
||||||
'as' => 'flarum.api.posts.delete',
|
'as' => 'flarum.api.posts.delete',
|
||||||
'uses' => $action('Flarum\Api\Actions\Posts\Delete')
|
'uses' => $action('Flarum\Api\Actions\Posts\DeleteAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -170,31 +152,31 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
|||||||
// List groups
|
// List groups
|
||||||
Route::get('groups', [
|
Route::get('groups', [
|
||||||
'as' => 'flarum.api.groups.index',
|
'as' => 'flarum.api.groups.index',
|
||||||
'uses' => $action('Flarum\Api\Actions\Groups\Index')
|
'uses' => $action('Flarum\Api\Actions\Groups\IndexAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Create a group
|
// Create a group
|
||||||
Route::post('groups', [
|
Route::post('groups', [
|
||||||
'as' => 'flarum.api.groups.create',
|
'as' => 'flarum.api.groups.create',
|
||||||
'uses' => $action('Flarum\Api\Actions\Groups\Create')
|
'uses' => $action('Flarum\Api\Actions\Groups\CreateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Show a single group
|
// Show a single group
|
||||||
Route::get('groups/{id}', [
|
Route::get('groups/{id}', [
|
||||||
'as' => 'flarum.api.groups.show',
|
'as' => 'flarum.api.groups.show',
|
||||||
'uses' => $action('Flarum\Api\Actions\Groups\Show')
|
'uses' => $action('Flarum\Api\Actions\Groups\ShowAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Edit a group
|
// Edit a group
|
||||||
Route::put('groups/{id}', [
|
Route::put('groups/{id}', [
|
||||||
'as' => 'flarum.api.groups.update',
|
'as' => 'flarum.api.groups.update',
|
||||||
'uses' => $action('Flarum\Api\Actions\Groups\Update')
|
'uses' => $action('Flarum\Api\Actions\Groups\UpdateAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Delete a group
|
// Delete a group
|
||||||
Route::delete('groups/{id}', [
|
Route::delete('groups/{id}', [
|
||||||
'as' => 'flarum.api.groups.delete',
|
'as' => 'flarum.api.groups.delete',
|
||||||
'uses' => $action('Flarum\Api\Actions\Groups\Delete')
|
'uses' => $action('Flarum\Api\Actions\Groups\DeleteAction')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
});
|
});
|
22
src/Console/ConsoleServiceProvider.php
Normal file
22
src/Console/ConsoleServiceProvider.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php namespace Flarum\Console;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class ConsoleServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->commands('Flarum\Console\InstallCommand');
|
||||||
|
$this->commands('Flarum\Console\SeedCommand');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
76
src/Console/InstallCommand.php
Normal file
76
src/Console/InstallCommand.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php namespace Flarum\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
|
||||||
|
class InstallCommand extends Command {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $name = 'flarum:install';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Run Flarum\'s installation migrations and seeds.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Application $app)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->app = $app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function fire()
|
||||||
|
{
|
||||||
|
$path = str_replace($this->laravel['path.base'].'/', '', __DIR__.'/../../migrations');
|
||||||
|
|
||||||
|
$this->call('migrate', ['--path' => $path]);
|
||||||
|
|
||||||
|
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\ConfigTableSeeder']);
|
||||||
|
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\GroupsTableSeeder']);
|
||||||
|
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\PermissionsTableSeeder']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the console command arguments.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getArguments()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// ['example', InputArgument::REQUIRED, 'An example argument.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the console command options.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getOptions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
71
src/Console/SeedCommand.php
Normal file
71
src/Console/SeedCommand.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php namespace Flarum\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
|
||||||
|
class SeedCommand extends Command {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $name = 'flarum:seed';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Seed Flarum\'s database with fake data.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Application $app)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->app = $app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function fire()
|
||||||
|
{
|
||||||
|
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']);
|
||||||
|
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the console command arguments.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getArguments()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// ['example', InputArgument::REQUIRED, 'An example argument.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the console command options.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getOptions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class ConfirmEmailCommand
|
class ConfirmEmailCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class DeleteDiscussionCommand
|
class DeleteDiscussionCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class DeletePostCommand
|
class DeletePostCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class DeleteUserCommand
|
class DeleteUserCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class EditDiscussionCommand
|
class EditDiscussionCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class EditPostCommand
|
class EditPostCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class EditUserCommand
|
class EditUserCommand
|
||||||
{
|
{
|
11
src/Core/Commands/GenerateAccessTokenCommand.php
Normal file
11
src/Core/Commands/GenerateAccessTokenCommand.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
|
class GenerateAccessTokenCommand
|
||||||
|
{
|
||||||
|
public $userId;
|
||||||
|
|
||||||
|
public function __construct($userId)
|
||||||
|
{
|
||||||
|
$this->userId = $userId;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class PostReplyCommand
|
class PostReplyCommand
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class ReadDiscussionCommand
|
class ReadDiscussionCommand
|
||||||
{
|
{
|
@ -1,7 +1,9 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class RegisterUserCommand
|
class RegisterUserCommand
|
||||||
{
|
{
|
||||||
|
public $forum;
|
||||||
|
|
||||||
public $user;
|
public $user;
|
||||||
|
|
||||||
public $username;
|
public $username;
|
||||||
@ -10,11 +12,12 @@ class RegisterUserCommand
|
|||||||
|
|
||||||
public $password;
|
public $password;
|
||||||
|
|
||||||
public function __construct($username, $email, $password, $user)
|
public function __construct($username, $email, $password, $user, $forum)
|
||||||
{
|
{
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
$this->forum = $forum;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Commands;
|
||||||
|
|
||||||
class StartDiscussionCommand
|
class StartDiscussionCommand
|
||||||
{
|
{
|
||||||
@ -8,10 +8,13 @@ class StartDiscussionCommand
|
|||||||
|
|
||||||
public $user;
|
public $user;
|
||||||
|
|
||||||
public function __construct($title, $content, $user)
|
public $forum;
|
||||||
|
|
||||||
|
public function __construct($title, $content, $user, $forum)
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
$this->forum = $forum;
|
||||||
}
|
}
|
||||||
}
|
}
|
179
src/Core/CoreServiceProvider.php
Normal file
179
src/Core/CoreServiceProvider.php
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<?php namespace Flarum\Core;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Dispatcher as Bus;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Flarum\Core\Formatter\FormatterManager;
|
||||||
|
use Flarum\Core\Models\CommentPost;
|
||||||
|
use Flarum\Core\Models\Post;
|
||||||
|
use Flarum\Core\Models\Model;
|
||||||
|
use Flarum\Core\Models\Forum;
|
||||||
|
use Flarum\Core\Models\User;
|
||||||
|
use Flarum\Core\Models\Discussion;
|
||||||
|
use Flarum\Core\Search\GambitManager;
|
||||||
|
|
||||||
|
class CoreServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot(Dispatcher $events, Bus $bus)
|
||||||
|
{
|
||||||
|
$this->loadViewsFrom(__DIR__.'../../views', 'flarum');
|
||||||
|
|
||||||
|
$this->registerEventHandlers($events);
|
||||||
|
$this->registerPostTypes();
|
||||||
|
$this->registerPermissions();
|
||||||
|
$this->registerGambits();
|
||||||
|
$this->setupModels();
|
||||||
|
|
||||||
|
$bus->mapUsing(function ($command) {
|
||||||
|
return Bus::simpleMapping(
|
||||||
|
$command, 'Flarum\Core\Commands', 'Flarum\Core\Handlers\Commands'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
// Register a singleton entity that represents this forum. This entity
|
||||||
|
// will be used to check for global forum permissions (like viewing the
|
||||||
|
// forum, registering, and starting discussions.)
|
||||||
|
$this->app->singleton('flarum.forum', 'Flarum\Core\Models\Forum');
|
||||||
|
|
||||||
|
// Register the extensions manager object. This manages a list of
|
||||||
|
// available extensions, and provides functionality to enable/disable
|
||||||
|
// them.
|
||||||
|
$this->app->singleton('flarum.extensions', 'Flarum\Core\Support\Extensions\Manager');
|
||||||
|
|
||||||
|
$this->app->bind('flarum.discussionFinder', 'Flarum\Core\Discussions\DiscussionFinder');
|
||||||
|
|
||||||
|
$this->app->singleton('flarum.formatter', function () {
|
||||||
|
$formatter = new FormatterManager($this->app);
|
||||||
|
$formatter->add('basic', 'Flarum\Core\Formatter\BasicFormatter');
|
||||||
|
return $formatter;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->bind(
|
||||||
|
'Flarum\Core\Repositories\DiscussionRepositoryInterface',
|
||||||
|
'Flarum\Core\Repositories\EloquentDiscussionRepository'
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'Flarum\Core\Repositories\PostRepositoryInterface',
|
||||||
|
'Flarum\Core\Repositories\EloquentPostRepository'
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'Flarum\Core\Repositories\UserRepositoryInterface',
|
||||||
|
'Flarum\Core\Repositories\EloquentUserRepository'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerGambits()
|
||||||
|
{
|
||||||
|
$this->app->bind('Flarum\Core\Search\GambitManager', function () {
|
||||||
|
$gambits = new GambitManager($this->app);
|
||||||
|
$gambits->add('Flarum\Core\Search\Discussions\Gambits\AuthorGambit');
|
||||||
|
$gambits->add('Flarum\Core\Search\Discussions\Gambits\UnreadGambit');
|
||||||
|
$gambits->setFulltextGambit('Flarum\Core\Search\Discussions\Gambits\FulltextGambit');
|
||||||
|
return $gambits;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerPostTypes()
|
||||||
|
{
|
||||||
|
Post::addType('comment', 'Flarum\Core\Models\CommentPost');
|
||||||
|
Post::addType('renamed', 'Flarum\Core\Models\RenamedPost');
|
||||||
|
|
||||||
|
CommentPost::setFormatter($this->app['flarum.formatter']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerEventHandlers($events)
|
||||||
|
{
|
||||||
|
$events->subscribe('Flarum\Core\Handlers\Events\DiscussionMetadataUpdater');
|
||||||
|
$events->subscribe('Flarum\Core\Handlers\Events\UserMetadataUpdater');
|
||||||
|
$events->subscribe('Flarum\Core\Handlers\Events\RenamedPostCreator');
|
||||||
|
$events->subscribe('Flarum\Core\Handlers\Events\EmailConfirmationMailer');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setupModels()
|
||||||
|
{
|
||||||
|
Model::setForum($this->app['flarum.forum']);
|
||||||
|
Model::setValidator($this->app['validator']);
|
||||||
|
|
||||||
|
User::setHasher($this->app['hash']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerPermissions()
|
||||||
|
{
|
||||||
|
Forum::grantPermission(function ($grant, $user, $permission) {
|
||||||
|
return $user->hasPermission($permission, 'forum');
|
||||||
|
});
|
||||||
|
|
||||||
|
Post::grantPermission(function ($grant, $user, $permission) {
|
||||||
|
return $user->hasPermission($permission, 'post');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Grant view access to a post only if the user can also view the
|
||||||
|
// discussion which the post is in. Also, the if the post is hidden,
|
||||||
|
// the user must have edit permissions too.
|
||||||
|
Post::grantPermission('view', function ($grant) {
|
||||||
|
$grant->whereCan('view', 'discussion');
|
||||||
|
});
|
||||||
|
|
||||||
|
Post::demandPermission('view', function ($demand) {
|
||||||
|
$demand->whereNull('hide_user_id')
|
||||||
|
->orWhereCan('edit');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Allow a user to edit their own post, unless it has been hidden by
|
||||||
|
// someone else.
|
||||||
|
Post::grantPermission('edit', function ($grant, $user) {
|
||||||
|
$grant->whereCan('editOwn')
|
||||||
|
->where('user_id', $user->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
Post::demandPermission('editOwn', function ($demand, $user) {
|
||||||
|
$demand->whereNull('hide_user_id');
|
||||||
|
if ($user) {
|
||||||
|
$demand->orWhere('hide_user_id', $user->id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
User::grantPermission(function ($grant, $user, $permission) {
|
||||||
|
return $user->hasPermission($permission, 'forum');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Grant view access to a user if the user can view the forum.
|
||||||
|
User::grantPermission('view', function ($grant, $user) {
|
||||||
|
$grant->whereCan('view', 'forum');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Allow a user to edit their own account.
|
||||||
|
User::grantPermission('edit', function ($grant, $user) {
|
||||||
|
$grant->where('id', $user->id);
|
||||||
|
});
|
||||||
|
|
||||||
|
Discussion::grantPermission(function ($grant, $user, $permission) {
|
||||||
|
return $user->hasPermission($permission, 'discussion');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Grant view access to a discussion if the user can view the forum.
|
||||||
|
Discussion::grantPermission('view', function ($grant, $user) {
|
||||||
|
$grant->whereCan('view', 'forum');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Allow a user to edit their own discussion.
|
||||||
|
Discussion::grantPermission('edit', function ($grant, $user) {
|
||||||
|
if ($user->hasPermission('editOwn', 'discussion')) {
|
||||||
|
$grant->where('start_user_id', $user->id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
16
src/Core/Events/DiscussionStateWillBeSaved.php
Normal file
16
src/Core/Events/DiscussionStateWillBeSaved.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\DiscussionState;
|
||||||
|
|
||||||
|
class DiscussionStateWillBeSaved
|
||||||
|
{
|
||||||
|
public $state;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(DiscussionState $state, $command)
|
||||||
|
{
|
||||||
|
$this->state = $state;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Discussion;
|
use Flarum\Core\Models\Discussion;
|
||||||
|
|
||||||
class DiscussionWasDeleted
|
class DiscussionWasDeleted
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionState;
|
use Flarum\Core\Models\DiscussionState;
|
||||||
|
|
||||||
class DiscussionWasRead
|
class DiscussionWasRead
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Discussion;
|
use Flarum\Core\Models\Discussion;
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class DiscussionWasRenamed
|
class DiscussionWasRenamed
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Discussion;
|
use Flarum\Core\Models\Discussion;
|
||||||
|
|
||||||
class DiscussionWasStarted
|
class DiscussionWasStarted
|
||||||
{
|
{
|
16
src/Core/Events/DiscussionWillBeDeleted.php
Normal file
16
src/Core/Events/DiscussionWillBeDeleted.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\Discussion;
|
||||||
|
|
||||||
|
class DiscussionWillBeDeleted
|
||||||
|
{
|
||||||
|
public $discussion;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(Discussion $discussion, $command)
|
||||||
|
{
|
||||||
|
$this->discussion = $discussion;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
16
src/Core/Events/DiscussionWillBeSaved.php
Normal file
16
src/Core/Events/DiscussionWillBeSaved.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\Discussion;
|
||||||
|
|
||||||
|
class DiscussionWillBeSaved
|
||||||
|
{
|
||||||
|
public $discussion;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(Discussion $discussion, $command)
|
||||||
|
{
|
||||||
|
$this->discussion = $discussion;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
class PostWasDeleted
|
class PostWasDeleted
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
class PostWasHidden
|
class PostWasHidden
|
||||||
{
|
{
|
@ -1,8 +1,8 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
class ReplyWasPosted
|
class PostWasPosted
|
||||||
{
|
{
|
||||||
public $post;
|
public $post;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
class PostWasRestored
|
class PostWasRestored
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Post;
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
class PostWasRevised
|
class PostWasRevised
|
||||||
{
|
{
|
16
src/Core/Events/PostWillBeDeleted.php
Normal file
16
src/Core/Events/PostWillBeDeleted.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
|
class PostWillBeDeleted
|
||||||
|
{
|
||||||
|
public $post;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(Post $post, $command)
|
||||||
|
{
|
||||||
|
$this->post = $post;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
16
src/Core/Events/PostWillBeSaved.php
Normal file
16
src/Core/Events/PostWillBeSaved.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
|
class PostWillBeSaved
|
||||||
|
{
|
||||||
|
public $post;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(Post $post, $command)
|
||||||
|
{
|
||||||
|
$this->post = $post;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class EmailWasChanged
|
class EmailWasChanged
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class EmailWasConfirmed
|
class EmailWasConfirmed
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class PasswordWasChanged
|
class PasswordWasChanged
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class UserWasActivated
|
class UserWasActivated
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class UserWasDeleted
|
class UserWasDeleted
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class UserWasRegistered
|
class UserWasRegistered
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Events;
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
class UserWasRenamed
|
class UserWasRenamed
|
||||||
{
|
{
|
16
src/Core/Events/UserWillBeDeleted.php
Normal file
16
src/Core/Events/UserWillBeDeleted.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
|
class UserWillBeDeleted
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(User $user, $command)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
16
src/Core/Events/UserWillBeSaved.php
Normal file
16
src/Core/Events/UserWillBeSaved.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php namespace Flarum\Core\Events;
|
||||||
|
|
||||||
|
use Flarum\Core\Models\User;
|
||||||
|
|
||||||
|
class UserWillBeSaved
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public $command;
|
||||||
|
|
||||||
|
public function __construct(User $user, $command)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Flarum\Core\Support\Exceptions;
|
<?php namespace Flarum\Core\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user