Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
Applied fixes from StyleCI (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Davis authored Oct 23, 2016
1 parent f7fe8ca commit 1308eea
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 303 deletions.
3 changes: 2 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
/*
* This file is part of davis/flarum-ext-socialprofile
*
* (c) Connor Davis <[email protected]>
* © Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/


namespace Davis\SocialProfile;

use Illuminate\Contracts\Events\Dispatcher;
Expand Down
3 changes: 2 additions & 1 deletion migrations/2016_01_14_000000_create_socialbuttons_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
/*
* This file is part of davis/flarum-ext-socialprofile
*
* (c) Connor Davis <[email protected]>
* © Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/


use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down
31 changes: 16 additions & 15 deletions migrations/2016_10_20_000000_create_socialbuttons_column.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* (c) Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/

use Flarum\Database\Migration;

return Migration::addColumns('users', [
'social_buttons' => ['longText', 'nullable' => true],
]);
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* © Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/


use Flarum\Database\Migration;

return Migration::addColumns('users', [
'social_buttons' => ['longText', 'nullable' => true],
]);
61 changes: 31 additions & 30 deletions migrations/2016_10_21_000000_migrate_data_to_user_column.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* (c) Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/

use Illuminate\Database\ConnectionInterface;

return [
'up' => function (ConnectionInterface $db) {
$results = $db->table('socialbuttons')->get();
foreach ($results as $result) {
$db->table('users')
->where('id', $result->user_id)
->update(['social_buttons' => $result->buttons]);
}
},
'down' => function (ConnectionInterface $db) {
$results = $db->table('users')->select('social_buttons')->get();
foreach ($results as $result) {
$db->table('socialbuttons')->insert(
['user_id' => $result->id, 'buttons' => $result->social_buttons]
);
}
},
];
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* © Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/


use Illuminate\Database\ConnectionInterface;

return [
'up' => function (ConnectionInterface $db) {
$results = $db->table('socialbuttons')->get();
foreach ($results as $result) {
$db->table('users')
->where('id', $result->user_id)
->update(['social_buttons' => $result->buttons]);
}
},
'down' => function (ConnectionInterface $db) {
$results = $db->table('users')->select('social_buttons')->get();
foreach ($results as $result) {
$db->table('socialbuttons')->insert(
['user_id' => $result->id, 'buttons' => $result->social_buttons]
);
}
},
];
51 changes: 26 additions & 25 deletions migrations/2016_10_22_000000_drop_socialbuttons_table.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* (c) Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
$schema->drop('socialbuttons');
},
'down' => function (Builder $schema) {
$schema->create('socialbuttons', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->longText('buttons');
});
},
];
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* © Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/


use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
$schema->drop('socialbuttons');
},
'down' => function (Builder $schema) {
$schema->create('socialbuttons', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->longText('buttons');
});
},
];
73 changes: 37 additions & 36 deletions src/Events/UserButtonsWereChanged.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* (c) Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/

namespace Davis\SocialProfile\Events;

use Flarum\Core\User;

class UserButtonsWereChanged
{
/**
* @var User
*/
public $user;

/**
* @var User
*/
public $actor;

/**
* @param User $user
* @param User $actor
*/
public function __construct(User $user, User $actor = null)
{
$this->user = $user;
$this->actor = $actor;
}
}
<?php

/*
* This file is part of davis/flarum-ext-socialprofile
*
* © Connor Davis <[email protected]>
*
* For the full copyright and license information, please view the MIT license
*/


namespace Davis\SocialProfile\Events;

use Flarum\Core\User;

class UserButtonsWereChanged
{
/**
* @var User
*/
public $user;

/**
* @var User
*/
public $actor;

/**
* @param User $user
* @param User $actor
*/
public function __construct(User $user, User $actor = null)
{
$this->user = $user;
$this->actor = $actor;
}
}
10 changes: 5 additions & 5 deletions src/Listeners/AddClientAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ public function addAssets(ConfigureClientView $event)
{
if ($event->isForum()) {
$event->addAssets([
__DIR__ . '/../../js/forum/dist/extension.js',
__DIR__ . '/../../less/forum/extension.less',
__DIR__.'/../../js/forum/dist/extension.js',
__DIR__.'/../../less/forum/extension.less',
]);
$event->addBootstrapper('Davis/SocialProfile/main');
}

if ($event->isAdmin()) {
$event->addAssets([
__DIR__ . '/../../js/admin/dist/extension.js',
__DIR__.'/../../js/admin/dist/extension.js',
]);
$event->addBootstrapper('Davis/SocialProfile/main');
}
}

public function addLocales(ConfigureLocales $event)
{
foreach (new DirectoryIterator(__DIR__ . '/../../locale') as $file) {
foreach (new DirectoryIterator(__DIR__.'/../../locale') as $file) {
if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) {
$event->locales->addTranslations($file->getBasename('.' . $file->getExtension()), $file->getPathname());
$event->locales->addTranslations($file->getBasename('.'.$file->getExtension()), $file->getPathname());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/LoadSettingsFromDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function prepareApiAttributes(PrepareApiAttributes $event)
{
if ($event->isSerializer(ForumSerializer::class)) {
foreach ($this->fieldsToGet as $field) {
$event->attributes[$this->packagePrefix . $field] = $this->settings->get($this->packagePrefix . $field);
$event->attributes[$this->packagePrefix.$field] = $this->settings->get($this->packagePrefix.$field);
}
}
}
Expand Down
Loading

0 comments on commit 1308eea

Please sign in to comment.