Skip to content

Commit

Permalink
Merge pull request #345 from spira/analysis-z3LkY8
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
zakhenry committed Jan 5, 2016
2 parents 6b2fe15 + 8189b0c commit 64e9898
Show file tree
Hide file tree
Showing 35 changed files with 75 additions and 71 deletions.
6 changes: 3 additions & 3 deletions api/app/Console/Commands/ApiaryValidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function handle()

exec("$validator $fileLocation", $output, $exitCode);

if ($exitCode == 0){
$this->info("Apiary Documentation validation passed");
if ($exitCode == 0) {
$this->info('Apiary Documentation validation passed');
} else {
$this->error("Apiary Documentation validation failed");
$this->error('Apiary Documentation validation failed');
}

return $exitCode;
Expand Down
4 changes: 2 additions & 2 deletions api/app/Console/Commands/ForumCleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class ForumCleanupCommand extends Command
*/
public function handle()
{
$dir = realpath(base_path() . '/../forum');
exec('composer run-script post-install-cmd --working-dir "' . $dir . '"', $output, $exitCode);
$dir = realpath(base_path().'/../forum');
exec('composer run-script post-install-cmd --working-dir "'.$dir.'"', $output, $exitCode);

return $exitCode;
}
Expand Down
1 change: 0 additions & 1 deletion api/app/Http/Controllers/AbstractTagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ protected function getPivotValidationRules()
'_pivot.tag_group_parent_id' => 'required|uuid',
];
}

}
1 change: 0 additions & 1 deletion api/app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public function loginAsUser(Request $request, User $userModel, $userId)
return $this->getResponse()
->transformer($this->getTransformer())
->item($this->auth->generateToken($user));

}

/**
Expand Down
2 changes: 0 additions & 2 deletions api/app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,3 @@
$app->get('images/{id}', ['as' => \App\Models\Image::class, 'uses' => 'ImageController@getOne']);

});


6 changes: 3 additions & 3 deletions api/app/Models/AbstractPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class AbstractPost extends IndexedModel implements LocalizableModelInterface, Co
'status',
'users_can_comment',
'public_access',
'short_title'
'short_title',
];

protected $hidden = ['permalinks'];
Expand Down Expand Up @@ -204,7 +204,7 @@ public static function boot()

static::saved(function (AbstractPost $model) {
if ($model->getOriginal('permalink') !== $model->permalink && ! is_null($model->permalink)) {
$permalink = call_user_func_array(static::$permalinkModel . '::findOrFail', [$model->permalink]);
$permalink = call_user_func_array(static::$permalinkModel.'::findOrFail', [$model->permalink]);
$model->permalinks()->save($permalink);
}

Expand Down Expand Up @@ -252,7 +252,7 @@ public function findByIdentifier($id)
} catch (ModelNotFoundException $e) { //id or permalink not found, try permalink history
$name = class_basename($this);

return call_user_func_array(static::$permalinkModel . '::findOrFail', [$id])->{$name};
return call_user_func_array(static::$permalinkModel.'::findOrFail', [$id])->{$name};
}
}

Expand Down
1 change: 0 additions & 1 deletion api/app/Models/PostComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ public static function find($id, $columns = ['*'])
{
return;
}

}
1 change: 0 additions & 1 deletion api/app/Models/PostDiscussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace App\Models;

use App;
use App\Models\Traits\CommentableInterface;
use App\Services\Api\Vanilla\Client as VanillaClient;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Spira\Core\Model\Collection\Collection;
Expand Down
1 change: 0 additions & 1 deletion api/app/Models/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,4 @@ public static function getContentTypes()
{
return array_keys(self::$contentTypeMap);
}

}
3 changes: 1 addition & 2 deletions api/app/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Tag extends IndexedModel
protected $mappingProperties = [
'tag_id' => [
'type' => 'string',
'index' => 'no'
'index' => 'no',
],
'tag' => [
'type' => 'string',
Expand All @@ -55,7 +55,6 @@ public function articles()
return $this->getBelongsRelation(Article::class, 'post_tag', null, 'post_id');
}


/**
* @param mixed $id
* @return BaseModel
Expand Down
8 changes: 8 additions & 0 deletions api/app/Models/Traits/CommentableInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?php

/*
* This file is part of the Spira framework.
*
* @link https://github.com/spira/spira
*
* For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/

namespace App\Models\Traits;

/**
Expand Down
8 changes: 8 additions & 0 deletions api/app/Models/Traits/CommentableTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?php

/*
* This file is part of the Spira framework.
*
* @link https://github.com/spira/spira
*
* For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/

namespace App\Models\Traits;

use App\Models\PostDiscussion;
Expand Down
26 changes: 10 additions & 16 deletions api/app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace App\Models;

use Rhumsaa\Uuid\Uuid;
use Illuminate\Support\Facades\DB;
use Illuminate\Auth\Authenticatable;
use Illuminate\Support\Facades\Cache;
use Spira\Core\Model\Model\IndexedModel;
Expand All @@ -22,7 +21,6 @@
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;

/**
Expand All @@ -33,7 +31,6 @@
*
* * scopes
* @method static Builder hasRoles(array $roleKeys) modifies query to return only users who has particular role
*
*/
class User extends IndexedModel implements AuthenticatableContract, SocialiteAuthenticatable
{
Expand Down Expand Up @@ -115,36 +112,36 @@ public static function getValidationRules($entityId = null, array $requestEntity
protected $mappingProperties = [
'user_id' => [
'type' => 'string',
'index' => 'no'
'index' => 'no',
],
'timezone_identifier' => [
'type' => 'string',
'index' => 'no'
'index' => 'no',
],
'avatar_img_url' => [
'type' => 'string',
'index' => 'no'
'index' => 'no',
],
'username' => [
'type' => 'string',
'index_analyzer' => 'autocomplete',
'search_analyzer' => 'standard'
'search_analyzer' => 'standard',
],
'email' => [
'type' => 'string',
'index_analyzer' => 'autocomplete',
'search_analyzer' => 'standard'
'search_analyzer' => 'standard',
],
'first_name' => [
'type' => 'string',
'index_analyzer' => 'autocomplete',
'search_analyzer' => 'standard'
'search_analyzer' => 'standard',
],
'last_name' => [
'type' => 'string',
'index_analyzer' => 'autocomplete',
'search_analyzer' => 'standard'
]
'search_analyzer' => 'standard',
],
];

/**
Expand Down Expand Up @@ -202,15 +199,13 @@ public function ratedArticles()
*/
public function getTimeZone()
{
if ($this->timezone_identifier){
if ($this->timezone_identifier) {
return new \DateTimeZone($this->timezone_identifier);
}

return null;
return;
}



/**
* Get the user's uploaded avatar image if they have one.
*
Expand Down Expand Up @@ -420,7 +415,6 @@ public function getCurrentAuthMethod()
}

/**
*
* @param Builder|\Illuminate\Database\Query\Builder $query
* @param array $roleKeys
* @return Builder
Expand Down
4 changes: 2 additions & 2 deletions api/app/Services/Api/Vanilla/Api/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
class Discussion extends ApiAbstract
{
/**
* Toggle spam check for comments
* Toggle spam check for comments.
*
* @param $enable
*/
public function toggleSpamCheck($enable)
{
return $this->put('discussions/spamcheck', ['Enable' => (int)$enable]);
return $this->put('discussions/spamcheck', ['Enable' => (int) $enable]);
}

/**
Expand Down
11 changes: 10 additions & 1 deletion api/config/cors.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php

/*
* This file is part of the Spira framework.
*
* @link https://github.com/spira/spira
*
* For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/

return [
/*
|--------------------------------------------------------------------------
Expand All @@ -16,4 +25,4 @@
'exposedHeaders' => [],
'maxAge' => 0,
'hosts' => [],
];
];
2 changes: 1 addition & 1 deletion api/config/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
$resultArray = Arr::merge($resultArray, $array);
}

return $resultArray;
return $resultArray;
9 changes: 4 additions & 5 deletions api/config/permissions/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@
'type' => 'permission',
'description' => 'Put section localization',
],



ArticleUserRatingsController::class.'@putOne' => [
'type' => 'permission',
'description' => 'Rate article or change rating value',
Expand All @@ -142,7 +141,7 @@
ArticleBookmarksController::class.'@deleteOne',
],
],

// Roles

Role::ADMIN_ROLE => [
Expand All @@ -160,7 +159,7 @@
ArticleSectionController::class.'@postMany',
ArticleSectionController::class.'@deleteMany',
ArticleSectionController::class.'@deleteOne',
ArticleSectionController::class.'@putOneChildLocalization'
ArticleSectionController::class.'@putOneChildLocalization',

],
],
Expand All @@ -176,7 +175,7 @@
ArticleCommentController::class.'@postOne',
ArticleTagController::class.'@getAll',
ArticleSectionController::class.'@getAll',
ArticleController::class.'@getAllTagCategories'
ArticleController::class.'@getAllTagCategories',
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class CreateTagsTable extends Migration
{

/**
* Run the migrations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function up()
->references('tag_id')->on(Tag::getTableName())
->onDelete('cascade');
});

}

/**
Expand Down
15 changes: 11 additions & 4 deletions api/database/migrations/2015_10_21_051428_seed_tags.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<?php

/*
* This file is part of the Spira framework.
*
* @link https://github.com/spira/spira
*
* For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/

use App\Models\Tag;
use Faker\Factory as Faker;
use Illuminate\Database\Migrations\Migration;

class SeedTags extends Migration
{

/** @var \Faker\Generator */
private $faker;

Expand Down Expand Up @@ -49,8 +56,8 @@ class SeedTags extends Migration
],
];

public static function getSeedTags(){

public static function getSeedTags()
{
return self::$tagHierarchy;
}

Expand Down Expand Up @@ -150,7 +157,7 @@ public function up()
*/
public function down()
{
if(!Schema::hasTable(Tag::getTableName())){
if (! Schema::hasTable(Tag::getTableName())) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion api/database/seeds/AbstractPostSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function (PostComment $comment) use ($post, $users) {
}
);
} catch (HttpException $e) {
echo 'Caught exception "' . get_class($e) . '": ' . $e->getMessage() . "\n";
echo 'Caught exception "'.get_class($e).'": '.$e->getMessage()."\n";
} finally {
$discussionsApi->toggleSpamCheck(true);
}
Expand Down
1 change: 0 additions & 1 deletion api/database/seeds/ArticleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ protected function getGroupTagPivots($tags)
{
return Tag::getGroupedTagPivots($tags, SeedTags::articleGroupTagName);
}

}
1 change: 0 additions & 1 deletion api/database/seeds/BaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public function randomElements(Collection $collection, $count = null)
return $collection->random($count);
}
}

}
2 changes: 1 addition & 1 deletion api/tests/ElasticSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function testGetIndexedModels()
$this->assertInstanceOf(IndexedModel::class, new $className);
}
}

public function testRebuildIndex()
{
$elasticSearchService = Mockery::mock(ElasticSearch::class)->makePartial();
Expand Down
Loading

0 comments on commit 64e9898

Please sign in to comment.