Archived
1
0
Fork 0

Style fixes.

This commit is contained in:
Henrik Hautakoski 2023-04-30 16:52:38 +02:00
parent a7a59b690a
commit be4950ff88
43 changed files with 187 additions and 149 deletions

View file

@ -118,8 +118,11 @@ class AuthController extends ControllerBase
}
$user = new User();
$user->assign($data->toArray(), null,
[ 'email', 'username', 'firstname', 'lastname' ]);
$user->assign(
$data->toArray(),
null,
['email', 'username', 'firstname', 'lastname']
);
$form = new RegistrationForm($user);

View file

@ -55,7 +55,8 @@ class CallbackController extends ControllerBase
return $this->response->redirect(array(
'for' => 'cb-created',
'id' => $callback->getPublicId()));
'id' => $callback->getPublicId()
));
} else {
foreach ($callback->getMessages() as $msg) {
$this->flash->error($msg);
@ -71,8 +72,6 @@ class CallbackController extends ControllerBase
$msg .= '</ul>';
$this->flash->message('error', $msg);
}
}
$this->view->form = $form;
@ -85,7 +84,6 @@ class CallbackController extends ControllerBase
{
$row = CallbackModel::get($id);
if (!$row) {
}
$this->view->id = $id;
}

View file

@ -15,4 +15,3 @@ class IndexController extends ControllerBase
{
}
}

View file

@ -44,8 +44,11 @@ class UserController extends ControllerBase
]);
// Send the email.
$this->di->getMail()->send('Httpcb password activation',
$user->getEmail(), $content);
$this->di->getMail()->send(
'Httpcb password activation',
$user->getEmail(),
$content
);
$msg = "For security reasons. Before a password can be created "
. "a email has been sent to <strong>{$user->getEmail()}</strong> with "

View file

@ -7,12 +7,14 @@ use Phalcon\Forms\Form;
/**
* Element types
*/
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Submit;
/**
* Validators
*/
use Phalcon\Validation\Validator\StringLength;
class CallbackCreate extends Form

View file

@ -7,6 +7,7 @@ use Phalcon\Forms\Form;
/**
* Element types
*/
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Password;
use Phalcon\Forms\Element\Submit;
@ -14,6 +15,7 @@ use Phalcon\Forms\Element\Submit;
/**
* Validators
*/
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email as EmailValidator;
use Phalcon\Validation\Validator\StringLength;

View file

@ -5,16 +5,19 @@ namespace App\Form;
/**
* Models
*/
use App\Model\Data\User;
/**
* Phalcon Form
*/
use Httpcb\Form as FormBase;
/**
* Element types
*/
use Phalcon\Forms\Element\Text,
Phalcon\Forms\Element\Password,
Phalcon\Forms\Element\Submit;
@ -22,6 +25,7 @@ use Phalcon\Forms\Element\Text,
/**
* Validators
*/
use Phalcon\Validation,
Phalcon\Validation\Validator\Callback as CallbackValidator,
Phalcon\Validation\Validator\Alnum as AlnumValidator,
@ -54,7 +58,9 @@ class Registration extends FormBase
'messageMinimum' => 'Username must be at least :min characters long.',
]),
new CallbackValidator([
'callback' => function($data) { return User::findFirstByUsername($data['username']) === false; },
'callback' => function ($data) {
return User::findFirstByUsername($data['username']) === false;
},
'message' => 'The username already exists.',
'attribute' => 'username',
])
@ -87,7 +93,9 @@ class Registration extends FormBase
$email->addValidators([
new CallbackValidator([
'callback' => function($data) { return User::findFirstByEmail($data['email']) === false; },
'callback' => function ($data) {
return User::findFirstByEmail($data['email']) === false;
},
'message' => 'This email already exist.',
])
]);

View file

@ -5,16 +5,19 @@ namespace App\Form;
/**
* Models
*/
use App\Model\Data\User as UserModel;
/**
* Form
*/
use Httpcb\Form as FormBase;
/**
* Element types
*/
use Phalcon\Forms\Element\Text,
Phalcon\Forms\Element\Password,
Phalcon\Forms\Element\Submit;
@ -22,6 +25,7 @@ use Phalcon\Forms\Element\Text,
/**
* Validators
*/
use Phalcon\Validation\Validator\Callback as CallbackValidator,
Phalcon\Validation\Validator\Uniqueness as UniquenessValidator,
Phalcon\Validation\Validator\Alnum as AlnumValidator,

View file

@ -70,7 +70,6 @@ class Acl
if ($def instanceof Config) {
$inherits = $def->get('inherits');
$description = $def->get('description');
}
$role = new Role($name, $description);

View file

@ -63,8 +63,11 @@ class Auth extends Injectable
$this->setIdentity($user->getId());
$this->eventsManager->fire('auth:onLogin', $this,
"OAuth {$data->getProvider()}");
$this->eventsManager->fire(
'auth:onLogin',
$this,
"OAuth {$data->getProvider()}"
);
return new Result(Result::SUCCESS);

View file

@ -2,7 +2,8 @@
namespace Httpcb;
class Debug {
class Debug
{
public static function dump($var, $label = null, $echo = true)
{

View file

@ -53,7 +53,10 @@ class Form extends FormBase
$xhtml .= sprintf(
'<label class="%s" for="%s">%s</label>',
$opt['label-class'], $ele->getName(), $ele->getLabel());
$opt['label-class'],
$ele->getName(),
$ele->getLabel()
);
}
$xhtml .= '<div class="' . implode(' ', $opt['class']) . '">'

View file

@ -126,15 +126,22 @@ class Menu extends Tag
return $xhtml;
}
$xhtml = self::tagHtml('li', $node->isActive()
$xhtml = self::tagHtml(
'li',
$node->isActive()
? array('class' => $this->_activeClass) : null,
false, false, true);
false,
false,
true
);
// Generate the link.
$xhtml .= self::linkTo($node->getHref(), $node->getCaption());
if ($node->isActive() && $node->hasChildren()
&& ($max_depth === null || $depth < $max_depth)) {
if (
$node->isActive() && $node->hasChildren()
&& ($max_depth === null || $depth < $max_depth)
) {
$xhtml .= $this->_renderMenu($node->getChildren(), $depth + 1, $max_depth);
}

View file

@ -81,4 +81,3 @@ class Container
return $this;
}
}

View file

@ -49,8 +49,7 @@ class Services extends DiDefault
if (substr($method->getName(), 0, 11) == '_initShared') {
$service = lcfirst(substr($method->getName(), 11));
$this->setShared($service, $method->getClosure($this));
}
else if (substr($method->getName(),0, 5) == '_init') {
} else if (substr($method->getName(), 0, 5) == '_init') {
$service = lcfirst(substr($method->getName(), 5));
$this->set($service, $method->getClosure($this));
}

View file

@ -33,7 +33,8 @@ class ServerUrl extends AbstractHelper
// remove port if it's the default port.
if (($scheme == 'http' && $port == 80)
|| ($scheme == 'https' && $port == 443)) {
|| ($scheme == 'https' && $port == 443)
) {
$port = null;
}

View file

@ -10,8 +10,12 @@ class CreateRequestMetaTable extends AbstractMigration
$table = $this->table('request_meta');
$table->addColumn('callbackid', 'integer');
$table->addForeignKey('callbackid', 'callback', [ 'id' ],
[ 'constraint' => 'FK_callback' ]);
$table->addForeignKey(
'callbackid',
'callback',
['id'],
['constraint' => 'FK_callback']
);
$table->addColumn('source_ip', 'string', [
'limit' => 50,

View file

@ -9,8 +9,12 @@ class CreateRequestObjectTable extends AbstractMigration
{
$table = $this->table('request_object');
$table->addForeignKey('id', 'request_meta', ['id'],
[ 'constraint' => 'FK_request_meta' ]);
$table->addForeignKey(
'id',
'request_meta',
['id'],
['constraint' => 'FK_request_meta']
);
$table->addColumn('headers', 'blob', [
'null' => true,

View file

@ -44,4 +44,3 @@ abstract class Base implements ModuleDefinitionInterface
));
}
}