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

Commit

Permalink
PHPCS #22
Browse files Browse the repository at this point in the history
  • Loading branch information
mik-laj committed Jul 21, 2016
1 parent 1aa8dd9 commit 3a1801a
Show file tree
Hide file tree
Showing 28 changed files with 190 additions and 37 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"cakephp/plugin-installer": "*",
"holt59/cakephp3-bootstrap-helpers": "dev-master",
"fzaninotto/Faker": "^1.6",
"cakephp/localized": "dev-master"
"cakephp/localized": "dev-master",
"cakephp/cakephp-codesniffer": "dev-master"
},
"require-dev": {
"psy/psysh": "@stable",
Expand Down
122 changes: 120 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ public function down()
{
}
}

2 changes: 1 addition & 1 deletion config/Migrations/20160709184233_AddUserIdToPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function change()
'null' => true
])
->addIndex(['user_id'], ['name' => 'fk_posts_users_idx'])
->addForeignKey('user_id', 'users', 'id', ['delete'=> 'SET_NULL', 'update'=> 'NO_ACTION'])
->addForeignKey('user_id', 'users', 'id', ['delete' => 'SET_NULL', 'update' => 'NO_ACTION'])
->save();
}
}
1 change: 0 additions & 1 deletion config/Migrations/20160709210604_AddDisplayNameColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ public function down()
->update();
}
}

1 change: 0 additions & 1 deletion config/Migrations/20160709213450_ChangePasswordLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ public function down()
->update();
}
}

2 changes: 1 addition & 1 deletion config/Migrations/20160710160333_AlterContentToText.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AlterContentToText extends AbstractMigration
public function change()
{
$this->table('posts')
->changeColumn('content', 'text',[
->changeColumn('content', 'text', [
'default' => null,
'limit' => 4294967295,
'null' => false
Expand Down
18 changes: 9 additions & 9 deletions config/Migrations/20160714150701_AddStatusColumnInPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class AddStatusColumnInPosts extends AbstractMigration
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->table('posts')
->addColumn('state', 'enum', [
'default' => null,
'values' => ['published', 'pinned', 'draft'],
'null' => false,
])->update();
}
public function change()
{
$this->table('posts')
->addColumn('state', 'enum', [
'default' => null,
'values' => ['published', 'pinned', 'draft'],
'null' => false,
])->update();
}
}
1 change: 0 additions & 1 deletion config/Migrations/20160718160356_AddPostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ public function down()
->update();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ public function down()
->update();
}
}

2 changes: 1 addition & 1 deletion config/Seeds/PostsSeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function run()
$faker = Faker\Factory::create();
$data = [];

for ($i=0; $i < 100; $i++) {
for ($i = 0; $i < 100; $i++) {
$data[] = [
'title' => $faker->sentence(5, true),
'content' => '<p>' . implode('</p><p>', $faker->paragraphs(rand(3, 20), false)) . '</p>',
Expand Down
2 changes: 1 addition & 1 deletion config/Seeds/SignaturesSeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function run()

$data = [];

for ($i=0; $i < 100; $i++) {
for ($i = 0; $i < 100; $i++) {
$data[] = [
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
Expand Down
6 changes: 4 additions & 2 deletions config/Seeds/UsersSeed.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
use Migrations\AbstractSeed;
use Cake\Auth\DefaultPasswordHasher;

/**
* Users seed.
*/
Expand All @@ -19,7 +20,8 @@ class UsersSeed extends AbstractSeed
public function run()
{
$hasher = new DefaultPasswordHasher();
$faker = $faker = Faker\Factory::create();;
$faker = $faker = Faker\Factory::create();
;
$data = [
[
'login' => 'user1',
Expand All @@ -41,7 +43,7 @@ public function run()
]
];

for ($i=0; $i < 20; $i++) {
for ($i = 0; $i < 20; $i++) {
$data[] = [
'login' => $faker->lastName . $faker->numberBetween(1, 5555),
'email' => $faker->safeEmail,
Expand Down
4 changes: 4 additions & 0 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,14 @@
*/
Request::addDetector('mobile', function ($request) {
$detector = new \Detection\MobileDetect();


return $detector->isMobile();
});
Request::addDetector('tablet', function ($request) {
$detector = new \Detection\MobileDetect();


return $detector->isTablet();
});

Expand Down
8 changes: 4 additions & 4 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@

Router::scope('/auth', function (RouteBuilder $routes) {
$routes->connect('/', ['controller' => 'Auth', 'action' => 'login'], ['_name' => 'auth.login']);
$routes->connect('/logout', ['controller' => 'Auth', 'action' => 'logout',], [ '_name' => 'auth.logout']);
$routes->connect('/logout', ['controller' => 'Auth', 'action' => 'logout', ], [ '_name' => 'auth.logout']);
});

Router::scope('/petition', function (RouteBuilder $routes) {
$routes->connect('/', ['controller' => 'Petition', 'action' => 'index'], ['_name' => 'petition.index']);
$routes->connect('/form', ['controller' => 'Petition', 'action' => 'add',], [ '_name' => 'petition.add']);
$routes->connect('/thank-you', ['controller' => 'Petition', 'action' => 'thank',], [ '_name' => 'petition.thank']);
$routes->connect('/form', ['controller' => 'Petition', 'action' => 'add', ], [ '_name' => 'petition.add']);
$routes->connect('/thank-you', ['controller' => 'Petition', 'action' => 'thank', ], [ '_name' => 'petition.thank']);
});


Router::scope('/', function (RouteBuilder $routes){
Router::scope('/', function (RouteBuilder $routes) {
$routes->connect('/', ['controller' => 'Blog', 'action' => 'index']);
$routes->connect('/:id/*', ['controller' => 'Blog', 'action' => 'view'], ['pass' => ['id'], 'id' => '\d+']);

Expand Down
4 changes: 4 additions & 0 deletions src/Console/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,16 @@ public static function setSecuritySalt($dir, $io)

if ($count == 0) {
$io->write('No Security.salt placeholder to replace.');


return;
}

$result = file_put_contents($config, $content);
if ($result) {
$io->write('Updated Security.salt value in config/app.php');


return;
}
$io->write('Unable to update Security.salt value.');
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function initialize()
'controller' => 'Auth',
'action' => 'login'
],
'unauthorizedRedirect'=>$this->referer()
'unauthorizedRedirect' => $this->referer()

]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function login()
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);


return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error(__('Invalid username or password, try again'));
Expand All @@ -43,5 +45,4 @@ public function logout()
{
return $this->redirect($this->Auth->logout());
}

}
8 changes: 4 additions & 4 deletions src/Controller/PetitionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function index()
$this->add();
}

public function listSignature(){
public function listSignature()
{
$signatures = $this->paginate($this->Signatures);

$this->set(compact('signatures'));
Expand All @@ -50,6 +51,8 @@ public function add()
$petition = $this->Signatures->patchEntity($signature, $this->request->data);
if ($this->Signatures->save($signature)) {
$this->Flash->success(__('The signature has been saved.'));


return $this->redirect(['action' => 'thank']);
} else {
$this->Flash->error(__('The signature could not be saved. Please, try again.'));
Expand All @@ -66,8 +69,5 @@ public function add()
*/
public function thank()
{

}


}
Loading

0 comments on commit 3a1801a

Please sign in to comment.