mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
Fix coding standards to conform to PSR-2
This commit is contained in:
parent
dcd67b9d5c
commit
0ca4e1ab7b
|
@ -4,8 +4,8 @@ use Flarum\Api\JsonApiRequest;
|
|||
|
||||
trait GetsPosts
|
||||
{
|
||||
protected function getPosts(JsonApiRequest $request, array $where)
|
||||
{
|
||||
protected function getPosts(JsonApiRequest $request, array $where)
|
||||
{
|
||||
$user = $request->actor->getUser();
|
||||
|
||||
if (isset($where['discussion_id']) && ($near = $request->get('near')) > 1) {
|
||||
|
@ -22,5 +22,5 @@ trait GetsPosts
|
|||
$request->limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,5 @@ class ConsoleServiceProvider extends ServiceProvider
|
|||
|
||||
public function register()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,41 +5,42 @@ use Illuminate\Foundation\Application;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class InstallCommand extends Command {
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'flarum:install';
|
||||
/**
|
||||
* 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.';
|
||||
/**
|
||||
* 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();
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$path = str_replace($this->laravel['path.base'].'/', '', __DIR__.'/../../migrations');
|
||||
|
||||
$this->call('migrate', ['--path' => $path]);
|
||||
|
@ -50,30 +51,29 @@ class InstallCommand extends Command {
|
|||
|
||||
// Create config file so that we know Flarum is installed
|
||||
copy(base_path('../config.example.php'), base_path('../config.php'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* 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],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,67 +5,67 @@ use Illuminate\Foundation\Application;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class SeedCommand extends Command {
|
||||
class SeedCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'flarum:seed';
|
||||
/**
|
||||
* 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.';
|
||||
/**
|
||||
* 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();
|
||||
/**
|
||||
* 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\DiscussionsTableSeeder']);
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']);
|
||||
}
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']);
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* 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],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class CoreServiceProvider extends ServiceProvider
|
|||
|
||||
$this->app->when('Flarum\Core\Handlers\Commands\UploadAvatarCommandHandler')
|
||||
->needs('League\Flysystem\FilesystemInterface')
|
||||
->give(function(Container $app) {
|
||||
->give(function (Container $app) {
|
||||
return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
class Extension
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
class ExtensionManager
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -4,35 +4,35 @@ use Illuminate\Container\Container;
|
|||
|
||||
class FormatterManager
|
||||
{
|
||||
protected $formatters = [];
|
||||
protected $formatters = [];
|
||||
|
||||
/**
|
||||
* The IoC container instance.
|
||||
*
|
||||
* @var \Illuminate\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
/**
|
||||
* The IoC container instance.
|
||||
*
|
||||
* @var \Illuminate\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Create a new formatter manager instance.
|
||||
*
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container = null)
|
||||
{
|
||||
$this->container = $container ?: new Container;
|
||||
}
|
||||
/**
|
||||
* Create a new formatter manager instance.
|
||||
*
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container = null)
|
||||
{
|
||||
$this->container = $container ?: new Container;
|
||||
}
|
||||
|
||||
public function add($name, $formatter, $priority = 0)
|
||||
{
|
||||
$this->formatters[$name] = [$formatter, $priority];
|
||||
}
|
||||
public function add($name, $formatter, $priority = 0)
|
||||
{
|
||||
$this->formatters[$name] = [$formatter, $priority];
|
||||
}
|
||||
|
||||
public function remove($name)
|
||||
{
|
||||
unset($this->formatters[$name]);
|
||||
}
|
||||
public function remove($name)
|
||||
{
|
||||
unset($this->formatters[$name]);
|
||||
}
|
||||
|
||||
protected function getFormatters()
|
||||
{
|
||||
|
@ -54,14 +54,14 @@ class FormatterManager
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function format($text, $post = null)
|
||||
{
|
||||
foreach ($this->getFormatters() as $formatter) {
|
||||
$text = $this->container->make($formatter)->format($text, $post);
|
||||
}
|
||||
public function format($text, $post = null)
|
||||
{
|
||||
foreach ($this->getFormatters() as $formatter) {
|
||||
$text = $this->container->make($formatter)->format($text, $post);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function strip($text)
|
||||
{
|
||||
|
|
|
@ -11,8 +11,8 @@ class LinkifyFormatter
|
|||
$this->linkify = $linkify;
|
||||
}
|
||||
|
||||
public function format($text)
|
||||
{
|
||||
return $this->linkify->process($text, ['attr' => ['target' => '_blank']]);
|
||||
}
|
||||
public function format($text)
|
||||
{
|
||||
return $this->linkify->process($text, ['attr' => ['target' => '_blank']]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,5 @@ class EmailConfirmationMailer
|
|||
|
||||
public function whenEmailWasChanged(EmailWasChanged $event)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,22 +9,22 @@ class Guest extends User
|
|||
*
|
||||
* @return \Flarum\Core\Models\Group
|
||||
*/
|
||||
public function getGroupsAttribute()
|
||||
{
|
||||
if (! isset($this->attributes['groups'])) {
|
||||
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
|
||||
}
|
||||
public function getGroupsAttribute()
|
||||
{
|
||||
if (! isset($this->attributes['groups'])) {
|
||||
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
|
||||
}
|
||||
|
||||
return $this->attributes['groups'];
|
||||
}
|
||||
return $this->attributes['groups'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not the user is a guest.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function guest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public function guest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class DiscussionSearchResults
|
|||
return $this->discussions;
|
||||
}
|
||||
|
||||
public function getTotal()
|
||||
public function getTotal()
|
||||
{
|
||||
return $this->total;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
abstract class GambitAbstract
|
||||
{
|
||||
protected $pattern;
|
||||
protected $pattern;
|
||||
|
||||
public function apply($bit, SearcherInterface $searcher)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ abstract class GambitAbstract
|
|||
}
|
||||
}
|
||||
|
||||
public function match($bit)
|
||||
public function match($bit)
|
||||
{
|
||||
if (preg_match('/^'.$this->pattern.'$/i', $bit, $matches)) {
|
||||
return $matches;
|
||||
|
|
|
@ -20,14 +20,14 @@ class GambitManager
|
|||
$this->gambits[] = $gambit;
|
||||
}
|
||||
|
||||
public function apply($string, $searcher)
|
||||
{
|
||||
public function apply($string, $searcher)
|
||||
{
|
||||
$string = $this->applyGambits($string, $searcher);
|
||||
|
||||
if ($string) {
|
||||
$this->applyFulltext($string, $searcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setFulltextGambit($gambit)
|
||||
{
|
||||
|
@ -69,5 +69,4 @@ class GambitManager
|
|||
$searcher->addActiveGambit($gambit);
|
||||
$gambit->apply($string, $searcher);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class UserSearchResults
|
|||
return $this->users;
|
||||
}
|
||||
|
||||
public function getTotal()
|
||||
public function getTotal()
|
||||
{
|
||||
return $this->total;
|
||||
}
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
use Illuminate\Database\Seeder;
|
||||
use DB;
|
||||
|
||||
class ConfigTableSeeder extends Seeder {
|
||||
class ConfigTableSeeder extends Seeder
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$config = [
|
||||
'api_url' => 'http://flarum.dev/api',
|
||||
'base_url' => 'http://flarum.dev',
|
||||
|
@ -20,9 +21,8 @@ class ConfigTableSeeder extends Seeder {
|
|||
'welcome_title' => 'Welcome to Flarum Demo Forum'
|
||||
];
|
||||
|
||||
DB::table('config')->insert(array_map(function($key, $value) {
|
||||
DB::table('config')->insert(array_map(function ($key, $value) {
|
||||
return compact('key', 'value');
|
||||
}, array_keys($config), $config));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,6 @@ class DiscussionsTableSeeder extends Seeder
|
|||
'read_time' => $faker->dateTimeBetween($discussion->start_time, 'now')
|
||||
]);
|
||||
} catch (\Illuminate\Database\QueryException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,19 +3,20 @@
|
|||
use Illuminate\Database\Seeder;
|
||||
use Flarum\Core\Models\Group;
|
||||
|
||||
class GroupsTableSeeder extends Seeder {
|
||||
class GroupsTableSeeder extends Seeder
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Group::unguard();
|
||||
Group::truncate();
|
||||
|
||||
$groups = [
|
||||
$groups = [
|
||||
['Admin', 'Admins', '#B72A2A', 'wrench'],
|
||||
['Guest', 'Guests', null, null],
|
||||
['Member', 'Members', null, null],
|
||||
|
@ -29,6 +30,5 @@ class GroupsTableSeeder extends Seeder {
|
|||
'icon' => $group[3]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,19 @@
|
|||
use Illuminate\Database\Seeder;
|
||||
use Flarum\Core\Models\Permission;
|
||||
|
||||
class PermissionsTableSeeder extends Seeder {
|
||||
class PermissionsTableSeeder extends Seeder
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Permission::truncate();
|
||||
|
||||
$permissions = [
|
||||
$permissions = [
|
||||
|
||||
// Guests can view the forum
|
||||
[2, 'forum.view'],
|
||||
|
@ -38,6 +39,5 @@ class PermissionsTableSeeder extends Seeder {
|
|||
];
|
||||
}
|
||||
Permission::insert($permissions);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ use Flarum\Core\Models\User;
|
|||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
User::unguard();
|
||||
|
|
|
@ -4,40 +4,41 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MappedMorphTo extends MorphTo {
|
||||
class MappedMorphTo extends MorphTo
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $map;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $map;
|
||||
|
||||
/**
|
||||
* Create a new morph to relationship instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param \Illuminate\Database\Eloquent\Model $parent
|
||||
* @param string $foreignKey
|
||||
* @param string $otherKey
|
||||
* @param string $type
|
||||
* @param string $relation
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $type, $relation, $map)
|
||||
{
|
||||
$this->map = $map;
|
||||
/**
|
||||
* Create a new morph to relationship instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param \Illuminate\Database\Eloquent\Model $parent
|
||||
* @param string $foreignKey
|
||||
* @param string $otherKey
|
||||
* @param string $type
|
||||
* @param string $relation
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $type, $relation, $map)
|
||||
{
|
||||
$this->map = $map;
|
||||
|
||||
parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relation);
|
||||
}
|
||||
parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new model instance by type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function createModelByType($type)
|
||||
{
|
||||
return new $this->map[$type];
|
||||
}
|
||||
/**
|
||||
* Create a new model instance by type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function createModelByType($type)
|
||||
{
|
||||
return new $this->map[$type];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@ class ExtensionsServiceProvider extends ServiceProvider
|
|||
public function register()
|
||||
{
|
||||
// Extensions will not be registered if Flarum is not installed yet
|
||||
if (!Core::isInstalled()) return;
|
||||
if (!Core::isInstalled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$extensions = json_decode(DB::table('config')->where('key', 'extensions_enabled')->pluck('value'), true);
|
||||
$providers = [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user