mirror of
https://github.com/flarum/core.git
synced 2025-10-24 21:26:11 +02:00
Fix coding standards to conform to PSR-2
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user