Commit faa1740d authored by Nicolas Widart's avatar Nicolas Widart

Squashed 'Modules/Core/' changes from eec30df..1f638cf

1f638cf Adding a base test case
356dd43 Refacting for DRY code
7eac803 Removing global function
776b509 Removing unused import
b8d865c Adding empty line at EOF
35156ba Adding empty line at EOF
a05523d Removing unused import
9d4951d Removing unused variable
0a70290 Type hinting
9ff4dda Changing permissions
b34eb75 Fixing insight badge
e37f5a0 Add code quality badges

git-subtree-dir: Modules/Core
git-subtree-split: 1f638cf2c75bd0efcb2d9c26df5fe9e994387ec5
parent 38f69193
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -3,7 +3,6 @@
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Hash;
use Modules\User\Repositories\RoleRepository;
use Modules\User\Repositories\UserRepository;
class InstallCommand extends Command
......@@ -27,10 +26,6 @@ class InstallCommand extends Command
*/
private $user;
/**
* @var RoleRepository
*/
private $role;
/**
* @var Filesystem
*/
......@@ -40,15 +35,13 @@ class InstallCommand extends Command
* Create a new command instance.
*
* @param UserRepository $user
* @param RoleRepository $role
* @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand
*/
public function __construct($user, $role, Filesystem $finder)
public function __construct($user, Filesystem $finder)
{
parent::__construct();
$this->user = $user;
$this->role = $role;
$this->finder = $finder;
}
......
<?php namespace Modules\Core\Http\Filters;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Laracasts\Flash\Flash;
class PermissionFilter
{
public function filter($route, $request)
public function filter(Route $route, Request $request)
{
$action = $route->getActionName();
$actionMethod = substr($action, strpos($action, "@") + 1);
......@@ -28,7 +30,7 @@ class PermissionFilter
* @param $request
* @return mixed
*/
private function getSegmentPosition($request)
private function getSegmentPosition(Request $request)
{
$segmentPosition = 2;
......
......@@ -11,16 +11,21 @@ class Helper
* @param $model
* @param $data
*/
public static function saveTranslated($model, $data)
public static function updateTranslated($model, $data)
{
foreach ($data as $lang => $value) {
if (is_array($value)) {
foreach ($value as $key => $input) {
$model->translate($lang)->$key = $input;
self::saveTranslatedProperties($model, $data);
}
}
}
$model->save();
/**
* Create the given model and save its translated attributes
* @param $model
* @param $data
*/
public static function createTranslatedFields($model, $data)
{
$model = new $model;
self::saveTranslatedProperties($model, $data);
}
/**
......@@ -44,20 +49,20 @@ class Helper
}
/**
* Create the given model and save its translated attributes
* Save the given properties for the model
* @param $model
* @param $data
*/
public static function createTranslatedFields($model, $data)
private static function saveTranslatedProperties($model, $data)
{
$model = new $model;
foreach ($data as $key => $value) {
foreach ($data as $lang => $value) {
if (is_array($value)) {
foreach ($value as $lang => $input) {
foreach ($value as $key => $input) {
$model->translate($lang)->$key = $input;
}
}
}
$model->save();
}
}
......@@ -3,7 +3,6 @@
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Modules\Core\Console\InstallCommand;
use Modules\User\Events\RegisterSidebarMenuItemEvent;
class CoreServiceProvider extends ServiceProvider
{
......@@ -106,7 +105,6 @@ class CoreServiceProvider extends ServiceProvider
$this->app->bindShared('command.platform.install', function($app) {
return new InstallCommand(
$app['Modules\User\Repositories\UserRepository'],
$app['Modules\User\Repositories\RoleRepository'],
$app['files']
);
});
......
......@@ -9,17 +9,17 @@
</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="{{{ core_asset('css/vendor/bootstrap.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/bootstrap.min.css') }}}" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="{{{ core_asset('css/vendor/font-awesome.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/font-awesome.min.css') }}}" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="{{{ core_asset('css/vendor/ionicons.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ core_asset('css/vendor/alertify/alertify.core.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ core_asset('css/vendor/alertify/alertify.default.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ core_asset('css/vendor/datatables/dataTables.bootstrap.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/ionicons.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/alertify/alertify.core.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/alertify/alertify.default.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/datatables/dataTables.bootstrap.css') }}}" rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="{{{ core_asset('css/AdminLTE.css') }}}" rel="stylesheet" type="text/css" />
<script src="{{{ core_asset('js/vendor/jquery.min.js') }}}"></script>
<link href="{{{ Module::asset('core', 'css/AdminLTE.css') }}}" rel="stylesheet" type="text/css" />
<script src="{{{ Module::asset('core', 'js/vendor/jquery.min.js') }}}"></script>
@section('styles')
@show
......@@ -55,12 +55,12 @@
</aside><!-- /.right-side -->
</div><!-- ./wrapper -->
<script src="{{{ core_asset('js/vendor/bootstrap.min.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/vendor/alertify/alertify.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/vendor/iCheck/icheck.min.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/vendor/datatables/jquery.dataTables.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/vendor/datatables/dataTables.bootstrap.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/app.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/bootstrap.min.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/alertify/alertify.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/iCheck/icheck.min.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/datatables/jquery.dataTables.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/datatables/dataTables.bootstrap.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/app.js') }}}" type="text/javascript"></script>
@section('scripts')
@show
</body>
......
<?php namespace Modules\Core\Tests;
use TestCase;
abstract class BaseTestCase extends TestCase
{
protected function checkResponseIsOkAndContains($request, $filter)
{
$crawler = $this->client->request($request[0], $request[1]);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter($filter));
}
}
<?php
if (!function_exists('core_asset')) {
function core_asset($url, array $attributes = [], $secure = false)
{
return Module::asset('core', $url, $attributes, $secure);
}
}
\ No newline at end of file
# Core Module
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/57e26b38-6275-4608-96e2-44047aaed5c2/mini.png)](https://insight.sensiolabs.com/projects/57e26b38-6275-4608-96e2-44047aaed5c2)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nWidart-Modules/Core/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nWidart-Modules/Core/?branch=master)
......@@ -27,4 +27,3 @@ Config::addNamespace('core', __DIR__ . '/Config/');
require __DIR__ . '/Http/routes.php';
require __DIR__ . '/composers.php';
require __DIR__ . '/helpers.php';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment