Merge branch '35-update-to-phalcon-4-0' into dev
This commit is contained in:
commit
43f585640a
26 changed files with 1434 additions and 435 deletions
|
|
@ -12,13 +12,6 @@ use App\Controller\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()
|
||||
{
|
||||
$form = new LoginForm();
|
||||
|
|
@ -74,7 +67,7 @@ class AuthController extends ControllerBase
|
|||
$user->{'set' . $name . 'Id'}($data->getId());
|
||||
$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->response->redirect('/settings');
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ class CallbackController extends ControllerBase
|
|||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
$this->view->page = $paginator->getPaginate();
|
||||
$this->view->page = $paginator->paginate();
|
||||
$this->view->pagination_url = '/callback/list/';
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ class CallbackController extends ControllerBase
|
|||
$paginator = $callback->getRequestPaginator($page, 30);
|
||||
|
||||
$this->view->item = $callback;
|
||||
$this->view->page = $paginator->getPaginate();
|
||||
$this->view->page = $paginator->paginate();
|
||||
$this->view->pagination_url = '/callback/show/' . $id . '/';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,6 @@ use App\Controller\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()
|
||||
{
|
||||
$user = $this->_getAuth()->getUser();
|
||||
|
|
@ -112,7 +105,7 @@ class UserController extends ControllerBase
|
|||
|
||||
$paginator = ActivityLog::getPaginationList($user->getId(), $page);
|
||||
|
||||
$this->view->page = $paginator->getPaginate();
|
||||
$this->view->page = $paginator->pageinate();
|
||||
$this->view->pagination_url = '/user/activity/';
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +149,7 @@ class UserController extends ControllerBase
|
|||
$user->{'set' . $provider . 'Id'}(null);
|
||||
$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>");
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class LogController extends \Phalcon\Mvc\Controller
|
|||
{
|
||||
$paginator = ActivityLog::getAllPaginationList($page);
|
||||
|
||||
$this->view->page = $paginator->getPaginate();
|
||||
$this->view->page = $paginator->paginate();
|
||||
$this->view->pagination_url = '/admin/log/';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ class UserController extends \Phalcon\Mvc\Controller
|
|||
$paginator = User::getPaginationList($page,15);
|
||||
|
||||
$this->view->pagination_url = '/admin/user/list/';
|
||||
$this->view->page = $paginator->getPaginate();
|
||||
$this->view->page = $paginator->paginate();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ use App\Model\Data\User;
|
|||
/**
|
||||
* Phalcon Form
|
||||
*/
|
||||
use Httpcb\Form as FormBase,
|
||||
Phalcon\Forms\Element as FormElement;
|
||||
use Httpcb\Form as FormBase;
|
||||
|
||||
/**
|
||||
* Element types
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use App\Model\Data\User as UserModel;
|
|||
* Phalcon Form
|
||||
*/
|
||||
use Phalcon\Forms\Form as FormBase,
|
||||
Phalcon\Forms\Element as FormElement;
|
||||
Phalcon\Forms\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Element types
|
||||
|
|
@ -210,7 +210,7 @@ class UserSettings extends FormBase
|
|||
return $this->_render($ele, $options);
|
||||
}
|
||||
|
||||
protected function _render(FormElement $ele, $opt)
|
||||
protected function _render(AbstractElement $ele, $opt)
|
||||
{
|
||||
$xhtml = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Httpcb;
|
||||
|
||||
use Phalcon\Config,
|
||||
Phalcon\Acl\Enum,
|
||||
Phalcon\Acl\Role,
|
||||
Phalcon\Acl\Adapter\Memory as Adapter;
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ class Acl
|
|||
$this->_adapter = new Adapter();
|
||||
|
||||
// Deny access to everything by default.
|
||||
$this->_adapter->setDefaultAction(\Phalcon\Acl::DENY);
|
||||
$this->_adapter->setDefaultAction(Enum::DENY);
|
||||
|
||||
$this->fromConfig($config);
|
||||
}
|
||||
|
|
@ -46,7 +47,7 @@ class Acl
|
|||
$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)
|
||||
{
|
||||
return $this->_adapter->isResource($resource);
|
||||
return $this->_adapter->isComponent($resource);
|
||||
}
|
||||
|
||||
public function fromConfig(Config $config)
|
||||
|
|
@ -84,7 +85,7 @@ class Acl
|
|||
}
|
||||
|
||||
foreach($resources as $resource) {
|
||||
$this->_adapter->addResource($resource, 'All');
|
||||
$this->_adapter->addComponent($resource, 'All');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,9 +99,12 @@ class Acl
|
|||
}
|
||||
|
||||
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) {
|
||||
$this->_adapter->allow($name, $resource, 'All');
|
||||
$this->_adapter->allow($name, $resource, 'All');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ namespace Httpcb;
|
|||
use App\Model\Data\User,
|
||||
Httpcb\OAuth\UserData\UserDataInterface,
|
||||
Httpcb\Auth\Result,
|
||||
Phalcon\Mvc\User\Component;
|
||||
Phalcon\Di\Injectable;
|
||||
|
||||
class Auth extends Component
|
||||
class Auth extends Injectable
|
||||
{
|
||||
const SESSION_KEY = 'auth';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Httpcb;
|
|||
|
||||
use Phalcon\Di\FactoryDefault as DiDefault;
|
||||
use Phalcon\Di\Injectable;
|
||||
use Phalcon\DiInterface;
|
||||
use Phalcon\Di\DiInterface;
|
||||
use Phalcon\Mvc\Application;
|
||||
|
||||
class Bootstrap extends Injectable
|
||||
|
|
@ -54,12 +54,16 @@ class Bootstrap extends Injectable
|
|||
|
||||
/**
|
||||
* Runs the application.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function run()
|
||||
public function run($uri)
|
||||
{
|
||||
$this->_app->setDI($this->getDI());
|
||||
return $this->_app->handle()->getContent();
|
||||
|
||||
try {
|
||||
$response = $this->_app->handle($uri);
|
||||
$response->send();
|
||||
} catch(\Exception $ex) {
|
||||
echo $ex->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ class RandomId extends Behavior implements BehaviorInterface
|
|||
*/
|
||||
public function generateId(\Phalcon\Mvc\ModelInterface $model)
|
||||
{
|
||||
$field = $this->_options['field'];
|
||||
$len = $this->_options['length'];
|
||||
$field = $this->options['field'];
|
||||
$len = $this->options['length'];
|
||||
|
||||
if (isset($this->_options['expression'])) {
|
||||
$expr = 'AND ' . $this->_options['expression'];
|
||||
if (isset($this->options['expression'])) {
|
||||
$expr = 'AND ' . $this->options['expression'];
|
||||
} else {
|
||||
$expr = '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,23 +2,21 @@
|
|||
|
||||
namespace Httpcb;
|
||||
|
||||
use Phalcon\DiInterface,
|
||||
Phalcon\Di\FactoryDefault as DiDefault,
|
||||
use Phalcon\Di\FactoryDefault as DiDefault,
|
||||
Phalcon\Config\Adapter\Yaml as Config,
|
||||
Phalcon\Mvc\View,
|
||||
Phalcon\Mvc\View\Simple as SimpleView,
|
||||
Phalcon\Assets\Manager as AssetsManager,
|
||||
Phalcon\Mvc\Url as UrlResolver,
|
||||
Phalcon\Url as UrlResolver,
|
||||
Phalcon\Mvc\View\Engine\Volt as VoltEngine,
|
||||
Phalcon\Flash\Direct as FlashDirect,
|
||||
Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData,
|
||||
Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData,
|
||||
Phalcon\Mvc\ViewBaseInterface,
|
||||
Phalcon\Cache\Frontend\Data as FrontendDataCache,
|
||||
Phalcon\Cache\Backend\Apc as BackendApcCache,
|
||||
Phalcon\Translate\Adapter\NativeArray as TranslateAdapter,
|
||||
Phalcon\Logger,
|
||||
Phalcon\Logger\Adapter\File as FileLogAdapter,
|
||||
Phalcon\Session\Adapter\Files as SessionAdapter,
|
||||
Phalcon\Mvc\Router;
|
||||
|
||||
use Httpcb\Auth,
|
||||
|
|
@ -155,7 +153,7 @@ class Services extends DiDefault
|
|||
$eventsManager->attach('db', function ($event, $connection) use ($logger) {
|
||||
|
||||
if ($event->getType() == 'beforeQuery') {
|
||||
$logger->log($connection->getRealSQLStatement(), Logger::INFO);
|
||||
$logger->info($connection->getRealSQLStatement());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -190,25 +188,23 @@ class Services extends DiDefault
|
|||
protected function _initSession()
|
||||
{
|
||||
$config = $this->get('config');
|
||||
$session = new \Phalcon\Session\Manager();
|
||||
|
||||
if (isset($config->session)) {
|
||||
$data = $config->session->toArray();
|
||||
$adapter = isset($data['adapter']) ? $data['adapter'] : 'Files';
|
||||
$adapter_name = isset($data['adapter']) ? $data['adapter'] : 'Stream';
|
||||
$options = $data['options'];
|
||||
|
||||
// For "Files": Set session path if defined.
|
||||
if ($adapter === 'Files' && isset($options['path'])) {
|
||||
session_save_path($config->application->path);
|
||||
}
|
||||
|
||||
$class = 'Phalcon\Session\Adapter\\' . $adapter;
|
||||
$session = new $class($options);
|
||||
$class = 'Phalcon\Session\Adapter\\' . $adapter_name;
|
||||
$adapter = new $class($options);
|
||||
}
|
||||
// Default to File storage
|
||||
// Default to Stream
|
||||
else {
|
||||
$session = new \Phalcon\Session\Adapter\Files();
|
||||
$adapter = new \Phalcon\Session\Adapter\Stream();
|
||||
}
|
||||
|
||||
$session->setAdapter($adapter);
|
||||
|
||||
// Start session.
|
||||
$session->start();
|
||||
return $session;
|
||||
|
|
@ -228,23 +224,23 @@ class Services extends DiDefault
|
|||
$view->setPartialsDir('_partials/');
|
||||
|
||||
$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(
|
||||
'compiledPath' => $config->application->viewCacheDir,
|
||||
'compiledSeparator' => '_',
|
||||
'compileAlways' => true,
|
||||
'path' => $config->application->viewCacheDir,
|
||||
'separator' => '_',
|
||||
'always' => true,
|
||||
));
|
||||
|
||||
// Register view helpers
|
||||
$compiler = $volt->getCompiler();
|
||||
$compiler->addExtension(new ViewHelperVoltExtension($di));
|
||||
$compiler->addExtension(new ViewHelperVoltExtension($this));
|
||||
|
||||
return $volt;
|
||||
},
|
||||
'.phtml' => 'Phalcon\Mvc\View\Engine\Php'
|
||||
'.phtml' => \Phalcon\Mvc\View\Engine\Php::class
|
||||
));
|
||||
|
||||
// Set default main layout.
|
||||
|
|
@ -347,9 +343,7 @@ class Services extends DiDefault
|
|||
|
||||
protected function _initAuth()
|
||||
{
|
||||
$auth = new Auth($this->get('config'));
|
||||
$auth->setEventsManager($this->get('eventsManager'));
|
||||
return $auth;
|
||||
return new Auth($this->get('config'));
|
||||
}
|
||||
|
||||
protected function _initAcl()
|
||||
|
|
@ -359,8 +353,10 @@ class Services extends DiDefault
|
|||
|
||||
protected function _initSharedLogger()
|
||||
{
|
||||
$path = $this->get('config')->application->logDir;
|
||||
return new FileLogAdapter($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()
|
||||
|
|
@ -370,17 +366,17 @@ class Services extends DiDefault
|
|||
$view = new SimpleView();
|
||||
$view->setViewsDir($config->application->templateDir);
|
||||
$view->registerEngines([
|
||||
'.volt' => function ($view, $di) use ($config) {
|
||||
$volt = new VoltEngine($view, $di);
|
||||
'.volt' => function (ViewBaseInterface $view) use ($config) {
|
||||
$volt = new VoltEngine($view, $this);
|
||||
|
||||
$volt->setOptions(array(
|
||||
'compiledPath' => $config->application->viewCacheDir,
|
||||
'compiledSeparator' => '_',
|
||||
'path' => $config->application->viewCacheDir,
|
||||
'separator' => '_',
|
||||
));
|
||||
|
||||
return $volt;
|
||||
},
|
||||
'.phtml' => 'Phalcon\Mvc\View\Engine\Php'
|
||||
'.phtml' => \Phalcon\Mvc\View\Engine\Php::class,
|
||||
]);
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace Httpcb\Validation\Validator;
|
||||
|
||||
use Phalcon\Validation\Message;
|
||||
use Phalcon\Validation\Validator as BaseValidator;
|
||||
use Phalcon\Validation\AbstractValidator;
|
||||
|
||||
/**
|
||||
* The same as the default Alpha validator shipped with phalcon.
|
||||
|
|
@ -12,16 +12,16 @@ use Phalcon\Validation\Validator as BaseValidator;
|
|||
*
|
||||
* @package Validation\Validator
|
||||
*/
|
||||
class Alpha extends BaseValidator
|
||||
class Alpha extends AbstractValidator
|
||||
{
|
||||
/**
|
||||
* Executes the validation
|
||||
*
|
||||
* @param mixed $validation
|
||||
* @param string $attribute
|
||||
* @param string $field
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(\Phalcon\Validation $validation, $attribute)
|
||||
public function validate(\Phalcon\Validation $validation, $field) : bool
|
||||
{
|
||||
$allowSpace = $this->getOption('allowSpace', false);
|
||||
|
||||
|
|
@ -30,13 +30,13 @@ class Alpha extends BaseValidator
|
|||
$charlist .= '[:space:]';
|
||||
}
|
||||
|
||||
$value = $validation->getValue($attribute);
|
||||
$value = $validation->getValue($field);
|
||||
|
||||
if (preg_match("/[^{$charlist}]/imu", $value)) {
|
||||
|
||||
$label = $this->getOption('label');
|
||||
if (empty($label)) {
|
||||
$label = $validation->getLabel($attribute);
|
||||
$label = $validation->getLabel($field);
|
||||
}
|
||||
|
||||
$message = $this->getOption('message');
|
||||
|
|
@ -48,12 +48,12 @@ class Alpha extends BaseValidator
|
|||
|
||||
$code = $this->getOption("code");
|
||||
if (is_array($code)) {
|
||||
$code = $code[$attribute];
|
||||
$code = $code[$field];
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Httpcb\ViewHelper;
|
||||
|
||||
use Phalcon\DiInterface;
|
||||
use Phalcon\Di\DiInterface;
|
||||
use Phalcon\Di\InjectionAwareInterface;
|
||||
|
||||
abstract class AbstractHelper implements InjectionAwareInterface
|
||||
|
|
@ -12,19 +12,19 @@ abstract class AbstractHelper implements InjectionAwareInterface
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @return \Phalcon\DiInterface
|
||||
* @return DiInterface
|
||||
*/
|
||||
public function getDI()
|
||||
public function getDI() : DiInterface
|
||||
{
|
||||
return $this->_di;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Httpcb\ViewHelper;
|
||||
|
||||
use Phalcon\DiInterface,
|
||||
use Phalcon\Di\DiInterface,
|
||||
Phalcon\Di\InjectionAwareInterface;
|
||||
|
||||
class Service implements InjectionAwareInterface
|
||||
|
|
@ -14,19 +14,19 @@ class Service implements InjectionAwareInterface
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @return \Phalcon\DiInterface
|
||||
* @return DiInterface
|
||||
*/
|
||||
public function getDI()
|
||||
public function getDI() : DiInterface
|
||||
{
|
||||
return $this->_di;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Httpcb\ViewHelper\Volt;
|
||||
|
||||
use Phalcon\DiInterface,
|
||||
use Phalcon\Di\DiInterface,
|
||||
Phalcon\Di\InjectionAwareInterface;
|
||||
|
||||
class Extension implements InjectionAwareInterface
|
||||
|
|
@ -38,19 +38,19 @@ class Extension implements InjectionAwareInterface
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @return \Phalcon\DiInterface
|
||||
* @return DiInterface
|
||||
*/
|
||||
public function getDI()
|
||||
public function getDI() : DiInterface
|
||||
{
|
||||
return $this->_di;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App\Listener;
|
||||
|
||||
use Phalcon\Events\Event,
|
||||
use Phalcon\Di\Injectable,
|
||||
Phalcon\Events\Event,
|
||||
Phalcon\Mvc\Dispatcher,
|
||||
Phalcon\Mvc\User\Plugin,
|
||||
Phalcon\Mvc\Dispatcher\Exception as DispatcherException;
|
||||
|
||||
use Httpcb\Acl;
|
||||
|
||||
class AccessListener extends Plugin
|
||||
class AccessListener extends Injectable
|
||||
{
|
||||
protected $_ignored_resources = [
|
||||
'index',
|
||||
|
|
|
|||
|
|
@ -2,20 +2,15 @@
|
|||
|
||||
namespace App\Listener;
|
||||
|
||||
use Phalcon\Mvc\User\Plugin,
|
||||
use Phalcon\Di\Injectable,
|
||||
Phalcon\Events\Event,
|
||||
App\Model\Data\User,
|
||||
App\Model\Data\ActivityLog as ActivityLogger,
|
||||
Httpcb\OAuth\UserData\UserDataInterface as OAuthUserDataInterface,
|
||||
Httpcb\Auth;
|
||||
|
||||
class ActivityLog extends Plugin
|
||||
class ActivityLog extends Injectable
|
||||
{
|
||||
/**
|
||||
* @var ActivityLogger
|
||||
*/
|
||||
protected $_table = null;
|
||||
|
||||
/**
|
||||
* On login event.
|
||||
*
|
||||
|
|
@ -74,20 +69,10 @@ class ActivityLog extends Plugin
|
|||
{
|
||||
$ip = (new \Phalcon\Http\Request())->getClientAddress();
|
||||
|
||||
$data = [
|
||||
return (new ActivityLogger())->assign([
|
||||
'user_id' => $user->getId(),
|
||||
'ip' => $ip,
|
||||
'message' => $message
|
||||
];
|
||||
|
||||
return $this->_getLogger()->create($data);
|
||||
}
|
||||
|
||||
protected function _getLogger()
|
||||
{
|
||||
if ($this->_table === null) {
|
||||
$this->_table = new ActivityLogger();
|
||||
}
|
||||
return $this->_table;
|
||||
])->create();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace App\Listener;
|
|||
|
||||
use Exception,
|
||||
Phalcon\Events\Event,
|
||||
Phalcon\Mvc\User\Plugin,
|
||||
Phalcon\Di\Injectable,
|
||||
Phalcon\Mvc\Dispatcher,
|
||||
Phalcon\Mvc\Dispatcher\Exception as DispatcherException;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ use Exception,
|
|||
* Plugin for forwarding user to 404 (not found) page
|
||||
* if a request could not be dispatched.
|
||||
*/
|
||||
class DispatchListener extends Plugin
|
||||
class DispatchListener extends Injectable
|
||||
{
|
||||
protected $_route_notfound = array(
|
||||
'controller' => 'error',
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class Base extends Model
|
|||
* @param boolean $allFields
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChanged($fieldName = null, $allFields = false)
|
||||
public function hasChanged($fieldName = null, bool $allFields = false) : bool
|
||||
{
|
||||
return $this->hasSnapshotData() === false
|
||||
|| parent::hasChanged($fieldName, $allFields);
|
||||
|
|
|
|||
|
|
@ -216,6 +216,9 @@ class Callback extends Model
|
|||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// Set table name mapped in the model.
|
||||
$this->setSource('callback');
|
||||
|
||||
$this->useDynamicUpdate(true);
|
||||
|
||||
$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)
|
||||
{
|
||||
return RequestMeta::getPaginator($this, $page, $limit);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Module;
|
||||
|
||||
use Phalcon\Loader,
|
||||
Phalcon\DiInterface,
|
||||
Phalcon\Di\DiInterface,
|
||||
Phalcon\Mvc\Dispatcher,
|
||||
Phalcon\Mvc\ModuleDefinitionInterface;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@
|
|||
|
||||
{% set pagination_slider = 3 %}
|
||||
|
||||
{% if (page.total_pages > 1) %}
|
||||
{% if (page.last > 1) %}
|
||||
|
||||
<ul class="pagination">
|
||||
|
||||
{% if page.current !== page.before %}
|
||||
{% if page.current !== page.previous %}
|
||||
<li>
|
||||
<a href="{{ pagination_url ~ page.before }}">
|
||||
<a href="{{ pagination_url ~ page.previous }}">
|
||||
{{ icon('solid/arrow-left') }} Previous
|
||||
</a>
|
||||
</li>
|
||||
{% 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>
|
||||
<a href="{{ pagination_url ~ 1 }}">1</a>
|
||||
</li>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
</li>
|
||||
{% 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) %}
|
||||
<li class="active">
|
||||
{% else %}
|
||||
|
|
@ -40,12 +40,12 @@
|
|||
</li>
|
||||
{% 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>
|
||||
<li>
|
||||
<a href="{{ pagination_url ~ page.total_pages }}">{{ page.total_pages }}</a>
|
||||
<a href="{{ pagination_url ~ page.last }}">{{ page.last }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
"name" : "pnx/httpcb",
|
||||
"description" : "",
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"ext-phalcon": ">=3.4.0",
|
||||
"php": ">=7.4.0",
|
||||
"ext-phalcon": ">=4.0.0",
|
||||
"ext-psr": "*",
|
||||
"ext-redis": "*",
|
||||
"ext-yaml": "*",
|
||||
"robmorgan/phinx": "^0.10.6",
|
||||
|
|
|
|||
1598
composer.lock
generated
1598
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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/Services.php";
|
||||
|
||||
$serviceContainer = new Httpcb\Services();
|
||||
|
||||
/**
|
||||
* Bootstrap the application.
|
||||
*/
|
||||
echo (new \Httpcb\Bootstrap(new Httpcb\Services()))
|
||||
->prepare()->run();
|
||||
$bootstrap = new \Httpcb\Bootstrap($serviceContainer);
|
||||
|
||||
$bootstrap
|
||||
->prepare()
|
||||
->run($_SERVER["REQUEST_URI"]);
|
||||
|
|
|
|||
Reference in a new issue