Archived
1
0
Fork 0

Merge branch '35-update-to-phalcon-4-0' into dev

This commit is contained in:
Henrik Hautakoski 2022-07-28 15:14:08 +02:00
commit 43f585640a
26 changed files with 1434 additions and 435 deletions

View file

@ -12,13 +12,6 @@ use App\Controller\ControllerBase,
class AuthController extends ControllerBase class AuthController extends ControllerBase
{ {
public function initialize()
{
// We need event manager here from DI.
$eventManager = $this->di->get('eventsManager');
$this->setEventsManager($eventManager);
}
public function indexAction() public function indexAction()
{ {
$form = new LoginForm(); $form = new LoginForm();
@ -74,7 +67,7 @@ class AuthController extends ControllerBase
$user->{'set' . $name . 'Id'}($data->getId()); $user->{'set' . $name . 'Id'}($data->getId());
$user->save(); $user->save();
$this->getEventsManager()->fire('user:onOAuthConnected', $user, $data); $this->eventsManager->fire('user:onOAuthConnected', $user, $data);
$this->flash->message('success', sprintf("OAuth provider <strong>%s</strong> was connected!", $name)); $this->flash->message('success', sprintf("OAuth provider <strong>%s</strong> was connected!", $name));
$this->response->redirect('/settings'); $this->response->redirect('/settings');

View file

@ -25,11 +25,11 @@ class CallbackController extends ControllerBase
{ {
$paginator = CallbackModel::getPaginationList($this->_user->getId(), $page, 10); $paginator = CallbackModel::getPaginationList($this->_user->getId(), $page, 10);
if ($paginator->getPaginate()->current > $paginator->getPaginate()->total_pages) { if ($paginator->paginate()->current > $paginator->paginate()->last) {
$paginator->setCurrentPage(1); $paginator->setCurrentPage(1);
} }
$this->view->page = $paginator->getPaginate(); $this->view->page = $paginator->paginate();
$this->view->pagination_url = '/callback/list/'; $this->view->pagination_url = '/callback/list/';
} }
@ -111,7 +111,7 @@ class CallbackController extends ControllerBase
$paginator = $callback->getRequestPaginator($page, 30); $paginator = $callback->getRequestPaginator($page, 30);
$this->view->item = $callback; $this->view->item = $callback;
$this->view->page = $paginator->getPaginate(); $this->view->page = $paginator->paginate();
$this->view->pagination_url = '/callback/show/' . $id . '/'; $this->view->pagination_url = '/callback/show/' . $id . '/';
} }
} }

View file

@ -10,13 +10,6 @@ use App\Controller\ControllerBase,
class UserController extends ControllerBase class UserController extends ControllerBase
{ {
public function initialize()
{
// We need event manager here from DI.
$eventManager = $this->di->get('eventsManager');
$this->setEventsManager($eventManager);
}
public function settingsAction() public function settingsAction()
{ {
$user = $this->_getAuth()->getUser(); $user = $this->_getAuth()->getUser();
@ -112,7 +105,7 @@ class UserController extends ControllerBase
$paginator = ActivityLog::getPaginationList($user->getId(), $page); $paginator = ActivityLog::getPaginationList($user->getId(), $page);
$this->view->page = $paginator->getPaginate(); $this->view->page = $paginator->pageinate();
$this->view->pagination_url = '/user/activity/'; $this->view->pagination_url = '/user/activity/';
} }
@ -156,7 +149,7 @@ class UserController extends ControllerBase
$user->{'set' . $provider . 'Id'}(null); $user->{'set' . $provider . 'Id'}(null);
$user->save(); $user->save();
$this->getEventsManager()->fire('user:onOAuthDisconnect', $user, $provider); $this->eventsManager->fire('user:onOAuthDisconnect', $user, $provider);
$this->flash->message('success', "<p><strong>{$provider}</strong> was disconnected</p>"); $this->flash->message('success', "<p><strong>{$provider}</strong> was disconnected</p>");

View file

@ -15,7 +15,7 @@ class LogController extends \Phalcon\Mvc\Controller
{ {
$paginator = ActivityLog::getAllPaginationList($page); $paginator = ActivityLog::getAllPaginationList($page);
$this->view->page = $paginator->getPaginate(); $this->view->page = $paginator->paginate();
$this->view->pagination_url = '/admin/log/'; $this->view->pagination_url = '/admin/log/';
} }
} }

View file

@ -19,6 +19,6 @@ class UserController extends \Phalcon\Mvc\Controller
$paginator = User::getPaginationList($page,15); $paginator = User::getPaginationList($page,15);
$this->view->pagination_url = '/admin/user/list/'; $this->view->pagination_url = '/admin/user/list/';
$this->view->page = $paginator->getPaginate(); $this->view->page = $paginator->paginate();
} }
} }

View file

@ -10,8 +10,7 @@ use App\Model\Data\User;
/** /**
* Phalcon Form * Phalcon Form
*/ */
use Httpcb\Form as FormBase, use Httpcb\Form as FormBase;
Phalcon\Forms\Element as FormElement;
/** /**
* Element types * Element types

View file

@ -11,7 +11,7 @@ use App\Model\Data\User as UserModel;
* Phalcon Form * Phalcon Form
*/ */
use Phalcon\Forms\Form as FormBase, use Phalcon\Forms\Form as FormBase,
Phalcon\Forms\Element as FormElement; Phalcon\Forms\Element\AbstractElement;
/** /**
* Element types * Element types
@ -210,7 +210,7 @@ class UserSettings extends FormBase
return $this->_render($ele, $options); return $this->_render($ele, $options);
} }
protected function _render(FormElement $ele, $opt) protected function _render(AbstractElement $ele, $opt)
{ {
$xhtml = ''; $xhtml = '';

View file

@ -3,6 +3,7 @@
namespace Httpcb; namespace Httpcb;
use Phalcon\Config, use Phalcon\Config,
Phalcon\Acl\Enum,
Phalcon\Acl\Role, Phalcon\Acl\Role,
Phalcon\Acl\Adapter\Memory as Adapter; Phalcon\Acl\Adapter\Memory as Adapter;
@ -21,7 +22,7 @@ class Acl
$this->_adapter = new Adapter(); $this->_adapter = new Adapter();
// Deny access to everything by default. // Deny access to everything by default.
$this->_adapter->setDefaultAction(\Phalcon\Acl::DENY); $this->_adapter->setDefaultAction(Enum::DENY);
$this->fromConfig($config); $this->fromConfig($config);
} }
@ -46,7 +47,7 @@ class Acl
$resource = $wildcard; $resource = $wildcard;
} }
} }
return $this->_adapter->isAllowed($role, $resource, 'All') == \Phalcon\Acl::ALLOW; return $this->_adapter->isAllowed($role, $resource, 'All') == Enum::ALLOW;
} }
/** /**
@ -55,7 +56,7 @@ class Acl
*/ */
public function hasResource($resource) public function hasResource($resource)
{ {
return $this->_adapter->isResource($resource); return $this->_adapter->isComponent($resource);
} }
public function fromConfig(Config $config) public function fromConfig(Config $config)
@ -84,7 +85,7 @@ class Acl
} }
foreach($resources as $resource) { foreach($resources as $resource) {
$this->_adapter->addResource($resource, 'All'); $this->_adapter->addComponent($resource, 'All');
} }
} }
@ -98,7 +99,10 @@ class Acl
} }
foreach($zones as $zone) { foreach($zones as $zone) {
$resources = (array) $config->zones->get($zone); $resources = $config->zones->get($zone);
if (!($resources instanceof Config)) {
$resources = new Config([ $resources ]);
}
foreach($resources as $resource) { foreach($resources as $resource) {
$this->_adapter->allow($name, $resource, 'All'); $this->_adapter->allow($name, $resource, 'All');
} }

View file

@ -5,9 +5,9 @@ namespace Httpcb;
use App\Model\Data\User, use App\Model\Data\User,
Httpcb\OAuth\UserData\UserDataInterface, Httpcb\OAuth\UserData\UserDataInterface,
Httpcb\Auth\Result, Httpcb\Auth\Result,
Phalcon\Mvc\User\Component; Phalcon\Di\Injectable;
class Auth extends Component class Auth extends Injectable
{ {
const SESSION_KEY = 'auth'; const SESSION_KEY = 'auth';

View file

@ -4,7 +4,7 @@ namespace Httpcb;
use Phalcon\Di\FactoryDefault as DiDefault; use Phalcon\Di\FactoryDefault as DiDefault;
use Phalcon\Di\Injectable; use Phalcon\Di\Injectable;
use Phalcon\DiInterface; use Phalcon\Di\DiInterface;
use Phalcon\Mvc\Application; use Phalcon\Mvc\Application;
class Bootstrap extends Injectable class Bootstrap extends Injectable
@ -54,12 +54,16 @@ class Bootstrap extends Injectable
/** /**
* Runs the application. * Runs the application.
*
* @return string
*/ */
public function run() public function run($uri)
{ {
$this->_app->setDI($this->getDI()); $this->_app->setDI($this->getDI());
return $this->_app->handle()->getContent();
try {
$response = $this->_app->handle($uri);
$response->send();
} catch(\Exception $ex) {
echo $ex->getMessage();
}
} }
} }

View file

@ -57,11 +57,11 @@ class RandomId extends Behavior implements BehaviorInterface
*/ */
public function generateId(\Phalcon\Mvc\ModelInterface $model) public function generateId(\Phalcon\Mvc\ModelInterface $model)
{ {
$field = $this->_options['field']; $field = $this->options['field'];
$len = $this->_options['length']; $len = $this->options['length'];
if (isset($this->_options['expression'])) { if (isset($this->options['expression'])) {
$expr = 'AND ' . $this->_options['expression']; $expr = 'AND ' . $this->options['expression'];
} else { } else {
$expr = ''; $expr = '';
} }

View file

@ -2,23 +2,21 @@
namespace Httpcb; namespace Httpcb;
use Phalcon\DiInterface, use Phalcon\Di\FactoryDefault as DiDefault,
Phalcon\Di\FactoryDefault as DiDefault,
Phalcon\Config\Adapter\Yaml as Config, Phalcon\Config\Adapter\Yaml as Config,
Phalcon\Mvc\View, Phalcon\Mvc\View,
Phalcon\Mvc\View\Simple as SimpleView, Phalcon\Mvc\View\Simple as SimpleView,
Phalcon\Assets\Manager as AssetsManager, Phalcon\Assets\Manager as AssetsManager,
Phalcon\Mvc\Url as UrlResolver, Phalcon\Url as UrlResolver,
Phalcon\Mvc\View\Engine\Volt as VoltEngine, Phalcon\Mvc\View\Engine\Volt as VoltEngine,
Phalcon\Flash\Direct as FlashDirect, Phalcon\Flash\Direct as FlashDirect,
Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData, Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData,
Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData, Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData,
Phalcon\Mvc\ViewBaseInterface,
Phalcon\Cache\Frontend\Data as FrontendDataCache, Phalcon\Cache\Frontend\Data as FrontendDataCache,
Phalcon\Cache\Backend\Apc as BackendApcCache, Phalcon\Cache\Backend\Apc as BackendApcCache,
Phalcon\Translate\Adapter\NativeArray as TranslateAdapter, Phalcon\Translate\Adapter\NativeArray as TranslateAdapter,
Phalcon\Logger, Phalcon\Logger,
Phalcon\Logger\Adapter\File as FileLogAdapter,
Phalcon\Session\Adapter\Files as SessionAdapter,
Phalcon\Mvc\Router; Phalcon\Mvc\Router;
use Httpcb\Auth, use Httpcb\Auth,
@ -155,7 +153,7 @@ class Services extends DiDefault
$eventsManager->attach('db', function ($event, $connection) use ($logger) { $eventsManager->attach('db', function ($event, $connection) use ($logger) {
if ($event->getType() == 'beforeQuery') { if ($event->getType() == 'beforeQuery') {
$logger->log($connection->getRealSQLStatement(), Logger::INFO); $logger->info($connection->getRealSQLStatement());
} }
}); });
@ -190,24 +188,22 @@ class Services extends DiDefault
protected function _initSession() protected function _initSession()
{ {
$config = $this->get('config'); $config = $this->get('config');
$session = new \Phalcon\Session\Manager();
if (isset($config->session)) { if (isset($config->session)) {
$data = $config->session->toArray(); $data = $config->session->toArray();
$adapter = isset($data['adapter']) ? $data['adapter'] : 'Files'; $adapter_name = isset($data['adapter']) ? $data['adapter'] : 'Stream';
$options = $data['options']; $options = $data['options'];
// For "Files": Set session path if defined. $class = 'Phalcon\Session\Adapter\\' . $adapter_name;
if ($adapter === 'Files' && isset($options['path'])) { $adapter = new $class($options);
session_save_path($config->application->path); }
// Default to Stream
else {
$adapter = new \Phalcon\Session\Adapter\Stream();
} }
$class = 'Phalcon\Session\Adapter\\' . $adapter; $session->setAdapter($adapter);
$session = new $class($options);
}
// Default to File storage
else {
$session = new \Phalcon\Session\Adapter\Files();
}
// Start session. // Start session.
$session->start(); $session->start();
@ -228,23 +224,23 @@ class Services extends DiDefault
$view->setPartialsDir('_partials/'); $view->setPartialsDir('_partials/');
$view->registerEngines(array( $view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) { '.volt' => function (ViewBaseInterface $view) use ($config) {
$volt = new VoltEngine($view, $di); $volt = new VoltEngine($view, $this);
$volt->setOptions(array( $volt->setOptions(array(
'compiledPath' => $config->application->viewCacheDir, 'path' => $config->application->viewCacheDir,
'compiledSeparator' => '_', 'separator' => '_',
'compileAlways' => true, 'always' => true,
)); ));
// Register view helpers // Register view helpers
$compiler = $volt->getCompiler(); $compiler = $volt->getCompiler();
$compiler->addExtension(new ViewHelperVoltExtension($di)); $compiler->addExtension(new ViewHelperVoltExtension($this));
return $volt; return $volt;
}, },
'.phtml' => 'Phalcon\Mvc\View\Engine\Php' '.phtml' => \Phalcon\Mvc\View\Engine\Php::class
)); ));
// Set default main layout. // Set default main layout.
@ -347,9 +343,7 @@ class Services extends DiDefault
protected function _initAuth() protected function _initAuth()
{ {
$auth = new Auth($this->get('config')); return new Auth($this->get('config'));
$auth->setEventsManager($this->get('eventsManager'));
return $auth;
} }
protected function _initAcl() protected function _initAcl()
@ -360,7 +354,9 @@ class Services extends DiDefault
protected function _initSharedLogger() protected function _initSharedLogger()
{ {
$path = $this->get('config')->application->logDir; $path = $this->get('config')->application->logDir;
return new FileLogAdapter($path . "app.txt"); return new \Phalcon\Logger('default', [
'main' => new \Phalcon\Logger\Adapter\Stream($path . 'app.txt')
]);
} }
protected function _initTemplate() protected function _initTemplate()
@ -370,17 +366,17 @@ class Services extends DiDefault
$view = new SimpleView(); $view = new SimpleView();
$view->setViewsDir($config->application->templateDir); $view->setViewsDir($config->application->templateDir);
$view->registerEngines([ $view->registerEngines([
'.volt' => function ($view, $di) use ($config) { '.volt' => function (ViewBaseInterface $view) use ($config) {
$volt = new VoltEngine($view, $di); $volt = new VoltEngine($view, $this);
$volt->setOptions(array( $volt->setOptions(array(
'compiledPath' => $config->application->viewCacheDir, 'path' => $config->application->viewCacheDir,
'compiledSeparator' => '_', 'separator' => '_',
)); ));
return $volt; return $volt;
}, },
'.phtml' => 'Phalcon\Mvc\View\Engine\Php' '.phtml' => \Phalcon\Mvc\View\Engine\Php::class,
]); ]);
return $view; return $view;
} }

View file

@ -3,7 +3,7 @@
namespace Httpcb\Validation\Validator; namespace Httpcb\Validation\Validator;
use Phalcon\Validation\Message; use Phalcon\Validation\Message;
use Phalcon\Validation\Validator as BaseValidator; use Phalcon\Validation\AbstractValidator;
/** /**
* The same as the default Alpha validator shipped with phalcon. * The same as the default Alpha validator shipped with phalcon.
@ -12,16 +12,16 @@ use Phalcon\Validation\Validator as BaseValidator;
* *
* @package Validation\Validator * @package Validation\Validator
*/ */
class Alpha extends BaseValidator class Alpha extends AbstractValidator
{ {
/** /**
* Executes the validation * Executes the validation
* *
* @param mixed $validation * @param mixed $validation
* @param string $attribute * @param string $field
* @return bool * @return bool
*/ */
public function validate(\Phalcon\Validation $validation, $attribute) public function validate(\Phalcon\Validation $validation, $field) : bool
{ {
$allowSpace = $this->getOption('allowSpace', false); $allowSpace = $this->getOption('allowSpace', false);
@ -30,13 +30,13 @@ class Alpha extends BaseValidator
$charlist .= '[:space:]'; $charlist .= '[:space:]';
} }
$value = $validation->getValue($attribute); $value = $validation->getValue($field);
if (preg_match("/[^{$charlist}]/imu", $value)) { if (preg_match("/[^{$charlist}]/imu", $value)) {
$label = $this->getOption('label'); $label = $this->getOption('label');
if (empty($label)) { if (empty($label)) {
$label = $validation->getLabel($attribute); $label = $validation->getLabel($field);
} }
$message = $this->getOption('message'); $message = $this->getOption('message');
@ -48,12 +48,12 @@ class Alpha extends BaseValidator
$code = $this->getOption("code"); $code = $this->getOption("code");
if (is_array($code)) { if (is_array($code)) {
$code = $code[$attribute]; $code = $code[$field];
} }
$message = str_replace(array_keys($replace), $replace, $message); $message = str_replace(array_keys($replace), $replace, $message);
$msg = new Message($message, $attribute, "Alpha", $code); $msg = new Message($message, $field, "Alpha", $code);
$validation->appendMessage($msg); $validation->appendMessage($msg);
return false; return false;

View file

@ -2,7 +2,7 @@
namespace Httpcb\ViewHelper; namespace Httpcb\ViewHelper;
use Phalcon\DiInterface; use Phalcon\Di\DiInterface;
use Phalcon\Di\InjectionAwareInterface; use Phalcon\Di\InjectionAwareInterface;
abstract class AbstractHelper implements InjectionAwareInterface abstract class AbstractHelper implements InjectionAwareInterface
@ -12,19 +12,19 @@ abstract class AbstractHelper implements InjectionAwareInterface
/** /**
* Sets the dependency injector * Sets the dependency injector
* *
* @param mixed $dependencyInjector * @param DiInterface $container
*/ */
public function setDI(DiInterface $dependencyInjector) public function setDI(DiInterface $container) : void
{ {
$this->_di = $dependencyInjector; $this->_di = $container;
} }
/** /**
* Returns the internal dependency injector * Returns the internal dependency injector
* *
* @return \Phalcon\DiInterface * @return DiInterface
*/ */
public function getDI() public function getDI() : DiInterface
{ {
return $this->_di; return $this->_di;
} }

View file

@ -2,7 +2,7 @@
namespace Httpcb\ViewHelper; namespace Httpcb\ViewHelper;
use Phalcon\DiInterface, use Phalcon\Di\DiInterface,
Phalcon\Di\InjectionAwareInterface; Phalcon\Di\InjectionAwareInterface;
class Service implements InjectionAwareInterface class Service implements InjectionAwareInterface
@ -14,19 +14,19 @@ class Service implements InjectionAwareInterface
/** /**
* Sets the dependency injector * Sets the dependency injector
* *
* @param mixed $dependencyInjector * @param DiInterface $container
*/ */
public function setDI(DiInterface $dependencyInjector) public function setDI(DiInterface $container) : void
{ {
$this->_di = $dependencyInjector; $this->_di = $container;
} }
/** /**
* Returns the internal dependency injector * Returns the internal dependency injector
* *
* @return \Phalcon\DiInterface * @return DiInterface
*/ */
public function getDI() public function getDI() : DiInterface
{ {
return $this->_di; return $this->_di;
} }

View file

@ -2,7 +2,7 @@
namespace Httpcb\ViewHelper\Volt; namespace Httpcb\ViewHelper\Volt;
use Phalcon\DiInterface, use Phalcon\Di\DiInterface,
Phalcon\Di\InjectionAwareInterface; Phalcon\Di\InjectionAwareInterface;
class Extension implements InjectionAwareInterface class Extension implements InjectionAwareInterface
@ -38,19 +38,19 @@ class Extension implements InjectionAwareInterface
/** /**
* Sets the dependency injector * Sets the dependency injector
* *
* @param mixed $dependencyInjector * @param DiInterface $container
*/ */
public function setDI(DiInterface $dependencyInjector) public function setDI(DiInterface $container) : void
{ {
$this->_di = $dependencyInjector; $this->_di = $container;
} }
/** /**
* Returns the internal dependency injector * Returns the internal dependency injector
* *
* @return \Phalcon\DiInterface * @return DiInterface
*/ */
public function getDI() public function getDI() : DiInterface
{ {
return $this->_di; return $this->_di;
} }

View file

@ -2,14 +2,14 @@
namespace App\Listener; namespace App\Listener;
use Phalcon\Events\Event, use Phalcon\Di\Injectable,
Phalcon\Events\Event,
Phalcon\Mvc\Dispatcher, Phalcon\Mvc\Dispatcher,
Phalcon\Mvc\User\Plugin,
Phalcon\Mvc\Dispatcher\Exception as DispatcherException; Phalcon\Mvc\Dispatcher\Exception as DispatcherException;
use Httpcb\Acl; use Httpcb\Acl;
class AccessListener extends Plugin class AccessListener extends Injectable
{ {
protected $_ignored_resources = [ protected $_ignored_resources = [
'index', 'index',

View file

@ -2,20 +2,15 @@
namespace App\Listener; namespace App\Listener;
use Phalcon\Mvc\User\Plugin, use Phalcon\Di\Injectable,
Phalcon\Events\Event, Phalcon\Events\Event,
App\Model\Data\User, App\Model\Data\User,
App\Model\Data\ActivityLog as ActivityLogger, App\Model\Data\ActivityLog as ActivityLogger,
Httpcb\OAuth\UserData\UserDataInterface as OAuthUserDataInterface, Httpcb\OAuth\UserData\UserDataInterface as OAuthUserDataInterface,
Httpcb\Auth; Httpcb\Auth;
class ActivityLog extends Plugin class ActivityLog extends Injectable
{ {
/**
* @var ActivityLogger
*/
protected $_table = null;
/** /**
* On login event. * On login event.
* *
@ -74,20 +69,10 @@ class ActivityLog extends Plugin
{ {
$ip = (new \Phalcon\Http\Request())->getClientAddress(); $ip = (new \Phalcon\Http\Request())->getClientAddress();
$data = [ return (new ActivityLogger())->assign([
'user_id' => $user->getId(), 'user_id' => $user->getId(),
'ip' => $ip, 'ip' => $ip,
'message' => $message 'message' => $message
]; ])->create();
return $this->_getLogger()->create($data);
}
protected function _getLogger()
{
if ($this->_table === null) {
$this->_table = new ActivityLogger();
}
return $this->_table;
} }
} }

View file

@ -4,7 +4,7 @@ namespace App\Listener;
use Exception, use Exception,
Phalcon\Events\Event, Phalcon\Events\Event,
Phalcon\Mvc\User\Plugin, Phalcon\Di\Injectable,
Phalcon\Mvc\Dispatcher, Phalcon\Mvc\Dispatcher,
Phalcon\Mvc\Dispatcher\Exception as DispatcherException; Phalcon\Mvc\Dispatcher\Exception as DispatcherException;
@ -14,7 +14,7 @@ use Exception,
* Plugin for forwarding user to 404 (not found) page * Plugin for forwarding user to 404 (not found) page
* if a request could not be dispatched. * if a request could not be dispatched.
*/ */
class DispatchListener extends Plugin class DispatchListener extends Injectable
{ {
protected $_route_notfound = array( protected $_route_notfound = array(
'controller' => 'error', 'controller' => 'error',

View file

@ -18,7 +18,7 @@ class Base extends Model
* @param boolean $allFields * @param boolean $allFields
* @return bool * @return bool
*/ */
public function hasChanged($fieldName = null, $allFields = false) public function hasChanged($fieldName = null, bool $allFields = false) : bool
{ {
return $this->hasSnapshotData() === false return $this->hasSnapshotData() === false
|| parent::hasChanged($fieldName, $allFields); || parent::hasChanged($fieldName, $allFields);

View file

@ -216,6 +216,9 @@ class Callback extends Model
*/ */
public function initialize() public function initialize()
{ {
// Set table name mapped in the model.
$this->setSource('callback');
$this->useDynamicUpdate(true); $this->useDynamicUpdate(true);
$this->hasMany('id', RequestMeta::class, 'callbackid', array('foreignKey' => true, 'alias' => 'Requests')); $this->hasMany('id', RequestMeta::class, 'callbackid', array('foreignKey' => true, 'alias' => 'Requests'));
@ -227,16 +230,6 @@ class Callback extends Model
))); )));
} }
/**
* Returns table name mapped in the model.
*
* @return string
*/
public function getSource()
{
return 'callback';
}
public function getRequestPaginator($page = 1, $limit = 30) public function getRequestPaginator($page = 1, $limit = 30)
{ {
return RequestMeta::getPaginator($this, $page, $limit); return RequestMeta::getPaginator($this, $page, $limit);

View file

@ -3,7 +3,7 @@
namespace App\Module; namespace App\Module;
use Phalcon\Loader, use Phalcon\Loader,
Phalcon\DiInterface, Phalcon\Di\DiInterface,
Phalcon\Mvc\Dispatcher, Phalcon\Mvc\Dispatcher,
Phalcon\Mvc\ModuleDefinitionInterface; Phalcon\Mvc\ModuleDefinitionInterface;

View file

@ -9,19 +9,19 @@
{% set pagination_slider = 3 %} {% set pagination_slider = 3 %}
{% if (page.total_pages > 1) %} {% if (page.last > 1) %}
<ul class="pagination"> <ul class="pagination">
{% if page.current !== page.before %} {% if page.current !== page.previous %}
<li> <li>
<a href="{{ pagination_url ~ page.before }}"> <a href="{{ pagination_url ~ page.previous }}">
{{ icon('solid/arrow-left') }} Previous {{ icon('solid/arrow-left') }} Previous
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% if page.total_pages > pagination_slider and page.current > (pagination_slider + 1) %} {% if page.last > pagination_slider and page.current > (pagination_slider + 1) %}
<li> <li>
<a href="{{ pagination_url ~ 1 }}">1</a> <a href="{{ pagination_url ~ 1 }}">1</a>
</li> </li>
@ -30,7 +30,7 @@
</li> </li>
{% endif %} {% endif %}
{% for n in max(page.current - pagination_slider, 1)..min(page.current + pagination_slider, page.total_pages) %} {% for n in max(page.current - pagination_slider, 1)..min(page.current + pagination_slider, page.last) %}
{% if (n == page.current) %} {% if (n == page.current) %}
<li class="active"> <li class="active">
{% else %} {% else %}
@ -40,12 +40,12 @@
</li> </li>
{% endfor %} {% endfor %}
{% if page.total_pages > pagination_slider and page.current < page.total_pages - pagination_slider %} {% if page.last > pagination_slider and page.current < page.last - pagination_slider %}
<li class="middle"> <li class="middle">
... ...
</li> </li>
<li> <li>
<a href="{{ pagination_url ~ page.total_pages }}">{{ page.total_pages }}</a> <a href="{{ pagination_url ~ page.last }}">{{ page.last }}</a>
</li> </li>
{% endif %} {% endif %}

View file

@ -2,8 +2,9 @@
"name" : "pnx/httpcb", "name" : "pnx/httpcb",
"description" : "", "description" : "",
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.4.0",
"ext-phalcon": ">=3.4.0", "ext-phalcon": ">=4.0.0",
"ext-psr": "*",
"ext-redis": "*", "ext-redis": "*",
"ext-yaml": "*", "ext-yaml": "*",
"robmorgan/phinx": "^0.10.6", "robmorgan/phinx": "^0.10.6",

1598
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,13 @@ defined('APP_PATH') || define('APP_PATH', realpath('..'));
require_once APP_PATH . "/app/library/Bootstrap.php"; require_once APP_PATH . "/app/library/Bootstrap.php";
require_once APP_PATH . "/app/library/Services.php"; require_once APP_PATH . "/app/library/Services.php";
$serviceContainer = new Httpcb\Services();
/** /**
* Bootstrap the application. * Bootstrap the application.
*/ */
echo (new \Httpcb\Bootstrap(new Httpcb\Services())) $bootstrap = new \Httpcb\Bootstrap($serviceContainer);
->prepare()->run();
$bootstrap
->prepare()
->run($_SERVER["REQUEST_URI"]);