Style fixes.
This commit is contained in:
parent
a7a59b690a
commit
be4950ff88
43 changed files with 187 additions and 149 deletions
|
|
@ -3,7 +3,7 @@
|
|||
namespace Httpcb;
|
||||
|
||||
use Phalcon\Config,
|
||||
Phalcon\Acl\Enum,
|
||||
Phalcon\Acl\Enum,
|
||||
Phalcon\Acl\Role,
|
||||
Phalcon\Acl\Adapter\Memory as Adapter;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ class Acl
|
|||
$pos = strpos($resource, '/');
|
||||
if ($pos !== false) {
|
||||
// Construct the wildcard resource.
|
||||
$wildcard = substr($resource, 0, $pos+1) . '*';
|
||||
$wildcard = substr($resource, 0, $pos + 1) . '*';
|
||||
|
||||
// If we have this wildcard resource, check against that instead.
|
||||
if ($this->hasResource($wildcard)) {
|
||||
|
|
@ -62,7 +62,7 @@ class Acl
|
|||
public function fromConfig(Config $config)
|
||||
{
|
||||
// Add roles.
|
||||
foreach($config->roles as $name => $def) {
|
||||
foreach ($config->roles as $name => $def) {
|
||||
|
||||
$inherits = null;
|
||||
$description = null;
|
||||
|
|
@ -70,7 +70,6 @@ class Acl
|
|||
if ($def instanceof Config) {
|
||||
$inherits = $def->get('inherits');
|
||||
$description = $def->get('description');
|
||||
|
||||
}
|
||||
|
||||
$role = new Role($name, $description);
|
||||
|
|
@ -78,33 +77,33 @@ class Acl
|
|||
}
|
||||
|
||||
// Zones
|
||||
foreach($config->zones as $name => $resources) {
|
||||
foreach ($config->zones as $name => $resources) {
|
||||
|
||||
if (!($resources instanceof Config)) {
|
||||
$resources = new Config([ $resources ]);
|
||||
$resources = new Config([$resources]);
|
||||
}
|
||||
|
||||
foreach($resources as $resource) {
|
||||
foreach ($resources as $resource) {
|
||||
$this->_adapter->addComponent($resource, 'All');
|
||||
}
|
||||
}
|
||||
|
||||
// Grant access for roles and resources.
|
||||
foreach($config->roles as $name => $def) {
|
||||
foreach ($config->roles as $name => $def) {
|
||||
|
||||
$zones = $def->get('allowed-zones', []);
|
||||
|
||||
if (is_string($zones)) {
|
||||
$zones = [ $zones ];
|
||||
$zones = [$zones];
|
||||
}
|
||||
|
||||
foreach($zones as $zone) {
|
||||
foreach ($zones as $zone) {
|
||||
$resources = $config->zones->get($zone);
|
||||
if (!($resources instanceof Config)) {
|
||||
$resources = new Config([ $resources ]);
|
||||
}
|
||||
foreach($resources as $resource) {
|
||||
$this->_adapter->allow($name, $resource, 'All');
|
||||
if (!($resources instanceof Config)) {
|
||||
$resources = new Config([$resources]);
|
||||
}
|
||||
foreach ($resources as $resource) {
|
||||
$this->_adapter->allow($name, $resource, 'All');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace Httpcb;
|
||||
|
||||
class Debug {
|
||||
class Debug
|
||||
{
|
||||
|
||||
public static function dump($var, $label = null, $echo = true)
|
||||
{
|
||||
// format the label
|
||||
$label = ($label===null) ? '' : rtrim($label) . ' ';
|
||||
$label = ($label === null) ? '' : rtrim($label) . ' ';
|
||||
// var_dump the variable into a buffer and keep the output
|
||||
ob_start();
|
||||
var_dump($var);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Form extends FormBase
|
|||
{
|
||||
$options = [
|
||||
'label-class' => 'col-form-label text-end',
|
||||
'class' => [ 'col-sm-10' ],
|
||||
'class' => ['col-sm-10'],
|
||||
'message' => ''
|
||||
];
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ class Form extends FormBase
|
|||
if ($len === 'full') {
|
||||
$options['class'] = [];
|
||||
} else {
|
||||
$options['class'] = [ 'col-sm-' . $len ];
|
||||
$options['class'] = ['col-sm-' . $len];
|
||||
}
|
||||
|
||||
unset($opt['length']);
|
||||
|
|
@ -42,10 +42,10 @@ class Form extends FormBase
|
|||
|
||||
protected function _render(AbstractElement $ele, $opt)
|
||||
{
|
||||
$classes = ['class' => 'form-control'];
|
||||
if ($ele->hasMessages()) {
|
||||
$classes['class'] .= ' is-invalid';
|
||||
}
|
||||
$classes = ['class' => 'form-control'];
|
||||
if ($ele->hasMessages()) {
|
||||
$classes['class'] .= ' is-invalid';
|
||||
}
|
||||
|
||||
$xhtml = '';
|
||||
|
||||
|
|
@ -53,14 +53,17 @@ 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']) . '">'
|
||||
. $ele->render($classes);
|
||||
|
||||
if ($ele->hasMessages()) {
|
||||
$msg = $ele->getMessages()->current();
|
||||
$msg = $ele->getMessages()->current();
|
||||
$xhtml .= '<span class="invalid-feedback">' . $msg . '</span>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class Menu extends Tag
|
|||
{
|
||||
$xhtml = '';
|
||||
|
||||
foreach($nodes as $node) {
|
||||
foreach ($nodes as $node) {
|
||||
$xhtml .= $this->_renderNode($node, $depth, $max_depth);
|
||||
}
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ class RandomId extends Behavior implements BehaviorInterface
|
|||
*/
|
||||
public function notify($type, \Phalcon\Mvc\ModelInterface $model)
|
||||
{
|
||||
switch($type) {
|
||||
case 'beforeValidationOnCreate' :
|
||||
$this->generateId($model);
|
||||
break;
|
||||
switch ($type) {
|
||||
case 'beforeValidationOnCreate':
|
||||
$this->generateId($model);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class RandomId extends Behavior implements BehaviorInterface
|
|||
if ($model->$field === null) {
|
||||
|
||||
$random = new \Phalcon\Security\Random();
|
||||
for($i = 0; $i < 3; $i++) {
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$id = substr($random->base64Safe(), 0, $len);
|
||||
|
||||
$count = $model->count(array(
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Navigation extends Navigation\Container
|
|||
*/
|
||||
public function __construct($config)
|
||||
{
|
||||
foreach($config as $node) {
|
||||
foreach ($config as $node) {
|
||||
$this->addChild($node);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Container
|
|||
|
||||
$node = new Node();
|
||||
|
||||
foreach($child as $k => $v) {
|
||||
foreach ($child as $k => $v) {
|
||||
|
||||
if ($k == 'children') {
|
||||
continue;
|
||||
|
|
@ -49,7 +49,7 @@ class Container
|
|||
|
||||
if (isset($child['children'])) {
|
||||
|
||||
foreach($child['children'] as $c_data) {
|
||||
foreach ($child['children'] as $c_data) {
|
||||
$node->addChild($c_data);
|
||||
}
|
||||
}
|
||||
|
|
@ -75,10 +75,9 @@ class Container
|
|||
*/
|
||||
public function addChildren($children)
|
||||
{
|
||||
foreach($children as $child) {
|
||||
foreach ($children as $child) {
|
||||
$this->addChild($child);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class Node extends Container
|
|||
}
|
||||
|
||||
// first. Check children.
|
||||
foreach($this->getChildren() as $child) {
|
||||
foreach ($this->getChildren() as $child) {
|
||||
|
||||
if ($child->isActive() == true) {
|
||||
$this->setActive(true);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class League implements AdapterInterface
|
|||
try {
|
||||
$reflection = new \ReflectionClass($this->_provider);
|
||||
return $reflection->getShortName();
|
||||
} catch(\ReflectionException $ex) {
|
||||
} catch (\ReflectionException $ex) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Phalcon\Di\FactoryDefault as DiDefault,
|
|||
Phalcon\Flash\Direct as FlashDirect,
|
||||
Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData,
|
||||
Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData,
|
||||
Phalcon\Mvc\ViewBaseInterface,
|
||||
Phalcon\Mvc\ViewBaseInterface,
|
||||
Phalcon\Cache\Frontend\Data as FrontendDataCache,
|
||||
Phalcon\Cache\Backend\Apc as BackendApcCache,
|
||||
Phalcon\Translate\Adapter\NativeArray as TranslateAdapter,
|
||||
|
|
@ -44,13 +44,12 @@ class Services extends DiDefault
|
|||
$reflection = new \ReflectionObject($this);
|
||||
$methods = $reflection->getMethods(\ReflectionMethod::IS_PROTECTED);
|
||||
|
||||
foreach($methods as $method) {
|
||||
foreach ($methods as $method) {
|
||||
|
||||
if (substr($method->getName(),0, 11) == '_initShared') {
|
||||
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));
|
||||
}
|
||||
|
|
@ -84,7 +83,7 @@ class Services extends DiDefault
|
|||
try {
|
||||
$tmp = new Config($basePath . $file);
|
||||
$config->merge($tmp);
|
||||
} catch(\Phalcon\Config\Exception $e) {
|
||||
} catch (\Phalcon\Config\Exception $e) {
|
||||
// Sometime went wrong. Log here?
|
||||
}
|
||||
}
|
||||
|
|
@ -118,7 +117,7 @@ class Services extends DiDefault
|
|||
|
||||
$eventsManager = new \Phalcon\Events\Manager();
|
||||
|
||||
$eventsManager->attach("dispatch", function($event, $dispatcher) {
|
||||
$eventsManager->attach("dispatch", function ($event, $dispatcher) {
|
||||
$actionName = lcfirst(\Phalcon\Text::camelize($dispatcher->getActionName(), '-_'));
|
||||
$dispatcher->setActionName($actionName);
|
||||
});
|
||||
|
|
@ -194,7 +193,7 @@ class Services extends DiDefault
|
|||
protected function _initSession()
|
||||
{
|
||||
$config = $this->get('config');
|
||||
$session = new \Phalcon\Session\Manager();
|
||||
$session = new \Phalcon\Session\Manager();
|
||||
|
||||
if (isset($config->session)) {
|
||||
$data = $config->session->toArray();
|
||||
|
|
@ -212,7 +211,7 @@ class Services extends DiDefault
|
|||
$adapter = new \Phalcon\Session\Adapter\Stream();
|
||||
}
|
||||
|
||||
$session->setAdapter($adapter);
|
||||
$session->setAdapter($adapter);
|
||||
|
||||
// Start session.
|
||||
$session->start();
|
||||
|
|
@ -228,7 +227,7 @@ class Services extends DiDefault
|
|||
|
||||
$view = new View();
|
||||
|
||||
$view->setViewsDir([ $config->application->viewsDir ]);
|
||||
$view->setViewsDir([$config->application->viewsDir]);
|
||||
$view->setLayoutsDir('_layouts/');
|
||||
$view->setPartialsDir('_partials/');
|
||||
|
||||
|
|
@ -322,7 +321,7 @@ class Services extends DiDefault
|
|||
$router = new Router(false);
|
||||
$router->removeExtraSlashes($config->get('removeExtraSlashes', false));
|
||||
|
||||
foreach($config->routes as $name => $def) {
|
||||
foreach ($config->routes as $name => $def) {
|
||||
|
||||
if (!($def instanceof \Phalcon\Config)) {
|
||||
continue;
|
||||
|
|
@ -366,10 +365,10 @@ class Services extends DiDefault
|
|||
|
||||
protected function _initSharedLogger()
|
||||
{
|
||||
$path = $this->get('config')->application->logDir;
|
||||
return new \Phalcon\Logger('default', [
|
||||
'main' => new \Phalcon\Logger\Adapter\Stream($path . 'app.txt')
|
||||
]);
|
||||
$path = $this->get('config')->application->logDir;
|
||||
return new \Phalcon\Logger('default', [
|
||||
'main' => new \Phalcon\Logger\Adapter\Stream($path . 'app.txt')
|
||||
]);
|
||||
}
|
||||
|
||||
protected function _initTemplate()
|
||||
|
|
@ -379,7 +378,7 @@ class Services extends DiDefault
|
|||
$view = new SimpleView();
|
||||
$view->setViewsDir($config->application->templateDir);
|
||||
$view->registerEngines([
|
||||
'.volt' => function (ViewBaseInterface $view) use ($config) {
|
||||
'.volt' => function (ViewBaseInterface $view) use ($config) {
|
||||
$volt = new VoltEngine($view, $this);
|
||||
|
||||
$volt->setOptions(array(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Alpha extends AbstractValidator
|
|||
* @param string $field
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(\Phalcon\Validation $validation, $field) : bool
|
||||
public function validate(\Phalcon\Validation $validation, $field): bool
|
||||
{
|
||||
$allowSpace = $this->getOption('allowSpace', false);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class Alpha extends AbstractValidator
|
|||
$message = $validation->getDefaultMessage('Alpha');
|
||||
}
|
||||
|
||||
$replace = [ ":field" => $label ];
|
||||
$replace = [":field" => $label];
|
||||
|
||||
$code = $this->getOption("code");
|
||||
if (is_array($code)) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ abstract class AbstractHelper implements InjectionAwareInterface
|
|||
*
|
||||
* @param DiInterface $container
|
||||
*/
|
||||
public function setDI(DiInterface $container) : void
|
||||
public function setDI(DiInterface $container): void
|
||||
{
|
||||
$this->_di = $container;
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ abstract class AbstractHelper implements InjectionAwareInterface
|
|||
*
|
||||
* @return DiInterface
|
||||
*/
|
||||
public function getDI() : DiInterface
|
||||
public function getDI(): DiInterface
|
||||
{
|
||||
return $this->_di;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Icon extends AbstractHelper
|
|||
|
||||
if (is_array($args)) {
|
||||
|
||||
foreach($args as $arg) {
|
||||
foreach ($args as $arg) {
|
||||
$classes[] .= 'fa-' . $arg;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Service implements InjectionAwareInterface
|
|||
*
|
||||
* @param DiInterface $container
|
||||
*/
|
||||
public function setDI(DiInterface $container) : void
|
||||
public function setDI(DiInterface $container): void
|
||||
{
|
||||
$this->_di = $container;
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ class Service implements InjectionAwareInterface
|
|||
*
|
||||
* @return DiInterface
|
||||
*/
|
||||
public function getDI() : DiInterface
|
||||
public function getDI(): DiInterface
|
||||
{
|
||||
return $this->_di;
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue