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
...@@ -10,4 +10,4 @@ class SidebarViewCreator ...@@ -10,4 +10,4 @@ class SidebarViewCreator
$view->prefix = Config::get('core::core.admin-prefix'); $view->prefix = Config::get('core::core.admin-prefix');
$view->items = new Collection; $view->items = new Collection;
} }
} }
\ No newline at end of file
...@@ -12,4 +12,4 @@ return [ ...@@ -12,4 +12,4 @@ return [
'User', 'User',
'Workshop' 'Workshop'
] ]
]; ];
\ No newline at end of file
...@@ -7,4 +7,4 @@ return [ ...@@ -7,4 +7,4 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
*/ */
'admin-prefix' => 'backend' 'admin-prefix' => 'backend'
]; ];
\ No newline at end of file
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Modules\User\Repositories\RoleRepository;
use Modules\User\Repositories\UserRepository; use Modules\User\Repositories\UserRepository;
class InstallCommand extends Command class InstallCommand extends Command
...@@ -27,10 +26,6 @@ class InstallCommand extends Command ...@@ -27,10 +26,6 @@ class InstallCommand extends Command
*/ */
private $user; private $user;
/**
* @var RoleRepository
*/
private $role;
/** /**
* @var Filesystem * @var Filesystem
*/ */
...@@ -40,15 +35,13 @@ class InstallCommand extends Command ...@@ -40,15 +35,13 @@ class InstallCommand extends Command
* Create a new command instance. * Create a new command instance.
* *
* @param UserRepository $user * @param UserRepository $user
* @param RoleRepository $role
* @param Filesystem $finder * @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand * @return \Modules\Core\Console\InstallCommand
*/ */
public function __construct($user, $role, Filesystem $finder) public function __construct($user, Filesystem $finder)
{ {
parent::__construct(); parent::__construct();
$this->user = $user; $this->user = $user;
$this->role = $role;
$this->finder = $finder; $this->finder = $finder;
} }
......
...@@ -13,8 +13,8 @@ class CoreDatabaseSeeder extends Seeder { ...@@ -13,8 +13,8 @@ class CoreDatabaseSeeder extends Seeder {
public function run() public function run()
{ {
Model::unguard(); Model::unguard();
// $this->call("OthersTableSeeder"); // $this->call("OthersTableSeeder");
} }
} }
\ No newline at end of file
...@@ -8,4 +8,4 @@ class AdminBaseController ...@@ -8,4 +8,4 @@ class AdminBaseController
public function __construct() public function __construct()
{ {
} }
} }
\ No newline at end of file
...@@ -26,4 +26,4 @@ class AdminFilter ...@@ -26,4 +26,4 @@ class AdminFilter
return App::abort(403); return App::abort(403);
} }
} }
} }
\ No newline at end of file
<?php namespace Modules\Core\Http\Filters; <?php namespace Modules\Core\Http\Filters;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel; use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\Redirect;
use Laracasts\Flash\Flash; use Laracasts\Flash\Flash;
class PermissionFilter class PermissionFilter
{ {
public function filter($route, $request) public function filter(Route $route, Request $request)
{ {
$action = $route->getActionName(); $action = $route->getActionName();
$actionMethod = substr($action, strpos($action, "@") + 1); $actionMethod = substr($action, strpos($action, "@") + 1);
...@@ -28,7 +30,7 @@ class PermissionFilter ...@@ -28,7 +30,7 @@ class PermissionFilter
* @param $request * @param $request
* @return mixed * @return mixed
*/ */
private function getSegmentPosition($request) private function getSegmentPosition(Request $request)
{ {
$segmentPosition = 2; $segmentPosition = 2;
...@@ -38,4 +40,4 @@ class PermissionFilter ...@@ -38,4 +40,4 @@ class PermissionFilter
return $segmentPosition; return $segmentPosition;
} }
} }
\ No newline at end of file
...@@ -11,4 +11,4 @@ if (App::environment() == 'testing') { ...@@ -11,4 +11,4 @@ if (App::environment() == 'testing') {
$lang = 'fr'; $lang = 'fr';
} }
App::setLocale($lang); App::setLocale($lang);
\ No newline at end of file
...@@ -11,16 +11,21 @@ class Helper ...@@ -11,16 +11,21 @@ class Helper
* @param $model * @param $model
* @param $data * @param $data
*/ */
public static function saveTranslated($model, $data) public static function updateTranslated($model, $data)
{ {
foreach ($data as $lang => $value) { self::saveTranslatedProperties($model, $data);
if (is_array($value)) { }
foreach ($value as $key => $input) {
$model->translate($lang)->$key = $input; /**
} * Create the given model and save its translated attributes
} * @param $model
} * @param $data
$model->save(); */
public static function createTranslatedFields($model, $data)
{
$model = new $model;
self::saveTranslatedProperties($model, $data);
} }
/** /**
...@@ -44,20 +49,20 @@ class Helper ...@@ -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 $model
* @param $data * @param $data
*/ */
public static function createTranslatedFields($model, $data) private static function saveTranslatedProperties($model, $data)
{ {
$model = new $model; foreach ($data as $lang => $value) {
foreach ($data as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
foreach ($value as $lang => $input) { foreach ($value as $key => $input) {
$model->translate($lang)->$key = $input; $model->translate($lang)->$key = $input;
} }
} }
} }
$model->save(); $model->save();
} }
}
\ No newline at end of file }
...@@ -30,4 +30,4 @@ class NavigationOrdener ...@@ -30,4 +30,4 @@ class NavigationOrdener
{ {
return isset($item['weight']) ? $item : $item->first(); return isset($item['weight']) ? $item : $item->first();
} }
} }
\ No newline at end of file
...@@ -50,4 +50,4 @@ class PermissionManager ...@@ -50,4 +50,4 @@ class PermissionManager
} }
return $cleanedPermissions; return $cleanedPermissions;
} }
} }
\ No newline at end of file
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
use Illuminate\Routing\Router; use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Core\Console\InstallCommand; use Modules\Core\Console\InstallCommand;
use Modules\User\Events\RegisterSidebarMenuItemEvent;
class CoreServiceProvider extends ServiceProvider class CoreServiceProvider extends ServiceProvider
{ {
...@@ -106,7 +105,6 @@ class CoreServiceProvider extends ServiceProvider ...@@ -106,7 +105,6 @@ class CoreServiceProvider extends ServiceProvider
$this->app->bindShared('command.platform.install', function($app) { $this->app->bindShared('command.platform.install', function($app) {
return new InstallCommand( return new InstallCommand(
$app['Modules\User\Repositories\UserRepository'], $app['Modules\User\Repositories\UserRepository'],
$app['Modules\User\Repositories\RoleRepository'],
$app['files'] $app['files']
); );
}); });
......
...@@ -22,4 +22,4 @@ return [ ...@@ -22,4 +22,4 @@ return [
'breadcrumb' => [ 'breadcrumb' => [
'home' => 'Home' 'home' => 'Home'
] ]
]; ];
\ No newline at end of file
...@@ -22,4 +22,4 @@ return [ ...@@ -22,4 +22,4 @@ return [
'english' => 'Anglais', 'english' => 'Anglais',
'french' => 'Français', 'french' => 'Français',
] ]
]; ];
\ No newline at end of file
...@@ -9,17 +9,17 @@ ...@@ -9,17 +9,17 @@
</title> </title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- bootstrap 3.0.2 --> <!-- 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 --> <!-- 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 --> <!-- Ionicons -->
<link href="{{{ core_asset('css/vendor/ionicons.min.css') }}}" rel="stylesheet" type="text/css" /> <link href="{{{ Module::asset('core', '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="{{{ Module::asset('core', '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="{{{ Module::asset('core', '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/datatables/dataTables.bootstrap.css') }}}" rel="stylesheet" type="text/css" />
<!-- Theme style --> <!-- Theme style -->
<link href="{{{ core_asset('css/AdminLTE.css') }}}" rel="stylesheet" type="text/css" /> <link href="{{{ Module::asset('core', 'css/AdminLTE.css') }}}" rel="stylesheet" type="text/css" />
<script src="{{{ core_asset('js/vendor/jquery.min.js') }}}"></script> <script src="{{{ Module::asset('core', 'js/vendor/jquery.min.js') }}}"></script>
@section('styles') @section('styles')
@show @show
...@@ -55,13 +55,13 @@ ...@@ -55,13 +55,13 @@
</aside><!-- /.right-side --> </aside><!-- /.right-side -->
</div><!-- ./wrapper --> </div><!-- ./wrapper -->
<script src="{{{ core_asset('js/vendor/bootstrap.min.js') }}}" type="text/javascript"></script> <script src="{{{ Module::asset('core', 'js/vendor/bootstrap.min.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/vendor/alertify/alertify.js') }}}" type="text/javascript"></script> <script src="{{{ Module::asset('core', '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="{{{ Module::asset('core', '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="{{{ Module::asset('core', '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="{{{ Module::asset('core', '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/app.js') }}}" type="text/javascript"></script>
@section('scripts') @section('scripts')
@show @show
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -48,4 +48,4 @@ ...@@ -48,4 +48,4 @@
</ul> </ul>
</section> </section>
<!-- /.sidebar --> <!-- /.sidebar -->
</aside> </aside>
\ No newline at end of file
...@@ -66,4 +66,4 @@ ...@@ -66,4 +66,4 @@
</li> </li>
</ul> </ul>
</div> </div>
</nav> </nav>
\ No newline at end of file
<?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/'); ...@@ -27,4 +27,3 @@ Config::addNamespace('core', __DIR__ . '/Config/');
require __DIR__ . '/Http/routes.php'; require __DIR__ . '/Http/routes.php';
require __DIR__ . '/composers.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