Archived
1
0
Fork 0

change model namespace to App\Model\Data

This commit is contained in:
Henrik Hautakoski 2018-04-02 23:35:49 +02:00
parent 6ed63d591f
commit 6173d56fd4
10 changed files with 23 additions and 21 deletions

View file

@ -5,7 +5,7 @@ $loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'App\Controller' => $config->application->controllersDir,
'App\Listener' => $config->application->listenersDir,
'Model' => $config->application->modelsDir,
'App\Model' => $config->application->modelsDir,
'Form' => $config->application->formsDir,
'Httpcb' => $config->application->libraryDir,
));

View file

@ -4,11 +4,13 @@ namespace App\Controller;
use App\Controller\ControllerBase;
use Form\Login as LoginForm;
class AuthController extends ControllerBase
{
public function indexAction()
{
$form = new Form\Login();
$form = new LoginForm();
if ($this->request->isPost()) {
$data = $this->request->getPost();

View file

@ -4,9 +4,9 @@ namespace App\Controller;
use App\Controller\ControllerBase,
Form\CallbackCreate as CreateCallbackForm,
Model\Data\Callback as CallbackModel,
Model\Data\Request as RequestModel,
Model\Data\RequestMeta as RequestMetaModel;
App\Model\Data\Callback as CallbackModel,
App\Model\Data\Request as RequestModel,
App\Model\Data\RequestMeta as RequestMetaModel;
class CallbackController extends ControllerBase
{
@ -46,7 +46,7 @@ class CallbackController extends ControllerBase
$data = $this->request->getPost();
if ($form->isValid($data)) {
$callback = new Model\Data\Callback();
$callback = new CallbackModel();
$callback->User = $this->_user;
$callback->setName($this->request->getPost());

View file

@ -5,7 +5,7 @@ namespace Form;
/**
* Models
*/
use Model\Data\User as UserModel;
use App\Model\Data\User as UserModel;
/**
* Phalcon Form

View file

@ -3,7 +3,7 @@
namespace Httpcb;
use Phalcon\Mvc\User\Component;
use Model\Data\User;
use App\Model\Data\User;
class Auth extends Component
{
@ -88,7 +88,7 @@ class Auth extends Component
$id = $this->session->get($this->_session_key);
if ($id !== null) {
return \Model\Data\User::findFirst($id);
return User::findFirst($id);
}
return null;
}
@ -102,7 +102,7 @@ class Auth extends Component
$id = $this->session->get($this->_session_key);
return \Model\Data\User::findFirst($id);
return User::findFirst($id);
}
return null;
}

View file

@ -1,6 +1,6 @@
<?php
namespace Model\Data;
namespace App\Model\Data;
use Phalcon\Mvc\Model;

View file

@ -1,6 +1,6 @@
<?php
namespace Model\Data;
namespace App\Model\Data;
use Httpcb\Mvc\Model\Behavior\RandomId as RandomIdBehavior;
use Phalcon\Mvc\Model;
@ -218,8 +218,8 @@ class Callback extends Model
{
$this->useDynamicUpdate(true);
$this->hasMany('id', 'Model\Data\RequestMeta', 'callbackid', array('foreignKey' => true, 'alias' => 'Requests'));
$this->belongsTo('userid', 'Model\Data\User', 'id', array('foreignKey' => true, 'alias' => 'User'));
$this->hasMany('id', RequestMeta::class, 'callbackid', array('foreignKey' => true, 'alias' => 'Requests'));
$this->belongsTo('userid', User::class, 'id', array('foreignKey' => true, 'alias' => 'User'));
$this->addBehavior(new RandomIdBehavior(array(
'field' => 'public_id',
@ -260,7 +260,7 @@ class Callback extends Model
{
$builder = (new self())->getModelsManager()->createBuilder();
$builder->from('Model\Data\Callback')
$builder->from(self::class)
->where('userid = :uid:', array('uid' => $userid))
->orderBy('created_at DESC');

View file

@ -1,6 +1,6 @@
<?php
namespace Model\Data;
namespace App\Model\Data;
use Phalcon\Mvc\Model;

View file

@ -1,6 +1,6 @@
<?php
namespace Model\Data;
namespace App\Model\Data;
use Phalcon\Mvc\Model;
@ -63,8 +63,8 @@ class RequestMeta extends Model
// Relationships
$this->belongsTo('callbackid', 'Model\Data\Callback', 'id', array('alias' => 'Callback'));
$this->hasOne('id', 'Model\Data\Request', 'id', array('alias' => 'RequestObject'));
$this->belongsTo('callbackid', Callback::class, 'id', array('alias' => 'Callback'));
$this->hasOne('id', Request::class, 'id', array('alias' => 'RequestObject'));
}
/**
@ -262,7 +262,7 @@ class RequestMeta extends Model
{
$builder = (new self())->getModelsManager()->createBuilder();
$builder->from('Model\Data\RequestMeta')
$builder->from(self::class)
->where('callbackid = :cid:', array('cid' => $callback->getId()))
->orderBy('timestamp desc');

View file

@ -1,6 +1,6 @@
<?php
namespace Model\Data;
namespace App\Model\Data;
use Phalcon\Mvc\Model;
use InvalidArgumentException;