Archived
1
0
Fork 0

Fixing proper namespace for app/library

This commit is contained in:
Henrik Hautakoski 2018-04-02 02:28:25 +02:00
parent cb1e40ee0a
commit aa37d10024
22 changed files with 78 additions and 62 deletions

View file

@ -8,14 +8,14 @@ $loader = new \Phalcon\Loader();
$loader->registerDirs(
array(
$config->application->controllersDir,
$config->application->libraryDir,
$config->application->pluginsDir
)
)->register();
$loader->registerNamespaces(array(
'Model' => $config->application->modelsDir,
'Form' => $config->application->formsDir,
'Model' => $config->application->modelsDir,
'Form' => $config->application->formsDir,
'Httpcb' => $config->application->libraryDir,
));
require_once __DIR__ . '/../../vendor/autoload.php';

View file

@ -5,22 +5,29 @@
* @var \Phalcon\Config $config
*/
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Assets\Manager as AssetsManager;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Navigation\Navigation;
use Phalcon\Flash\Direct as FlashDirect;
use Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData;
use Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData;
use Phalcon\Cache\Frontend\Data as FrontendDataCache;
use Phalcon\Cache\Backend\Apc as BackendApcCache;
use Phalcon\Translate\Adapter\NativeArray as TranslateAdapter;
use Phalcon\Logger;
use Phalcon\Logger\Adapter\Firephp as FirephpAdapter;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Mvc\Router;
use Phalcon\Di\FactoryDefault,
Phalcon\Mvc\View,
Phalcon\Assets\Manager as AssetsManager,
Phalcon\Mvc\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\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,
Httpcb\OAuth,
Httpcb\Acl,
Httpcb\Navigation,
Httpcb\Menu;
/**
* The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
@ -33,7 +40,7 @@ $di = new FactoryDefault();
$di->setShared('logger', function() {
//return new Phalcon\Logger\Adapter\Firephp("");
return new Phalcon\Logger\Adapter\File(APP_PATH . "/app/log.txt");
return new FileLogAdapter(APP_PATH . "/app/log.txt");
});
$di->setShared('dispatcher', function() use ($di, $config) {
@ -119,7 +126,7 @@ $di->setShared('router', function() {
return $router;
});
$di->setShared('viewHelper', '\ViewHelper\Service');
$di->setShared('viewHelper', 'Httpcb\ViewHelper\Service');
/**
* Setting up the view component
@ -145,7 +152,7 @@ $di->setShared('view', function () use ($di, $config) {
// Register view helpers
$compiler = $volt->getCompiler();
$compiler->addExtension(new \ViewHelper\Volt\Extension($di));
$compiler->addExtension(new Httpcb\ViewHelper\Volt\Extension($di));
return $volt;
},
@ -274,12 +281,10 @@ $di->set('oauth', function() use ($config) {
});
$di->set('auth', function() use ($config) {
return new Auth\Auth($config);
return new Auth($config);
});
$di->set('acl', function() {
return new Acl\Acl();
});
$di->set('acl', 'Httpcb\Acl');
$di->set('menu', function() use ($di) {
@ -322,9 +327,9 @@ $di->set('menu', function() use ($di) {
$menu = new Menu($navigation);
$menu->setMenuClass(null);
if ($di->get('auth')->hasIdentity()) {
$menu->setAclRole(Acl\Acl::ROLE_USER);
$menu->setAclRole(Acl::ROLE_USER);
} else {
$menu->setAclRole(Acl\Acl::ROLE_GUEST);
$menu->setAclRole(Acl::ROLE_GUEST);
}
return $menu;
});

View file

@ -25,13 +25,13 @@ use Phalcon\Forms\Element\Text,
*/
use Phalcon\Validation\Validator\Callback as CallbackValidator,
Phalcon\Validation\Validator\Uniqueness as UniquenessValidator,
\Validation\Validator\Alpha as AlphaValidator,
Phalcon\Validation\Validator\Alnum as AlnumValidator,
Phalcon\Validation\Validator\PresenceOf as PresenceOfValidator,
Phalcon\Validation\Validator\Email as EmailValidator,
Phalcon\Validation\Validator\Confirmation as ConfirmationValidator,
Phalcon\Validation\Validator\StringLength as StringLengthValidator,
Phalcon\Validation\Validator\Identical as IdenticalValidator;
Phalcon\Validation\Validator\Identical as IdenticalValidator,
Httpcb\Validation\Validator\Alpha as AlphaValidator;
class UserSettings extends FormBase

View file

@ -1,6 +1,6 @@
<?php
namespace Acl;
namespace Httpcb;
use Phalcon\Acl\Role;
use Phalcon\Acl\Adapter\Memory as AclList;

View file

@ -1,6 +1,6 @@
<?php
namespace Auth;
namespace Httpcb;
use Phalcon\Mvc\User\Component;
use Model\Data\User;

View file

@ -1,5 +1,7 @@
<?php
namespace Httpcb;
class Debug {
public static function dump($var, $label = null, $echo = true)

View file

@ -1,8 +1,12 @@
<?php
namespace Httpcb;
use Phalcon\Tag;
use Navigation\Node;
use Navigation\Navigation;
use Httpcb\Acl,
Httpcb\Navigation,
Httpcb\Navigation\Node;
class Menu extends Tag
{

View file

@ -1,6 +1,6 @@
<?php
namespace Mvc\Model\Behavior;
namespace Httpcb\Mvc\Model\Behavior;
use \Phalcon\Mvc\Model\Behavior;
use \Phalcon\Mvc\Model\BehaviorInterface;

View file

@ -1,8 +1,8 @@
<?php
namespace Navigation;
namespace Httpcb;
class Navigation extends Container
class Navigation extends Navigation\Container
{
public function __construct($config)
{

View file

@ -1,6 +1,6 @@
<?php
namespace Navigation;
namespace Httpcb\Navigation;
class Container
{

View file

@ -1,6 +1,6 @@
<?php
namespace Navigation;
namespace Httpcb\Navigation;
class Exception extends \Exception
{

View file

@ -1,6 +1,6 @@
<?php
namespace Navigation;
namespace Httpcb\Navigation;
use \Phalcon\Di;

View file

@ -1,8 +1,11 @@
<?php
//use Opauth;
namespace Httpcb;
use Phalcon\Mvc\User\Component;
use Opauth;
class OAuth extends Component
{
/**

View file

@ -1,6 +1,6 @@
<?php
namespace Validation\Validator;
namespace Httpcb\Validation\Validator;
use Phalcon\Validation\Message;
use Phalcon\Validation\Validator as BaseValidator;

View file

@ -1,6 +1,6 @@
<?php
namespace ViewHelper;
namespace Httpcb\ViewHelper;
use Phalcon\DiInterface;
use Phalcon\Di\InjectionAwareInterface;

View file

@ -1,6 +1,6 @@
<?php
namespace ViewHelper;
namespace Httpcb\ViewHelper;
/**
* Class Icon

View file

@ -1,6 +1,6 @@
<?php
namespace ViewHelper;
namespace Httpcb\ViewHelper;
/**
* Class ServerUrl

View file

@ -1,9 +1,9 @@
<?php
namespace ViewHelper;
namespace Httpcb\ViewHelper;
use Phalcon\DiInterface;
use Phalcon\Di\InjectionAwareInterface;
use Phalcon\DiInterface,
Phalcon\Di\InjectionAwareInterface;
class Service implements InjectionAwareInterface
{
@ -66,7 +66,7 @@ class Service implements InjectionAwareInterface
return $this->_helpers[$name];
}
$class = '\ViewHelper\\' . ucfirst($name);
$class = 'Httpcb\\ViewHelper\\' . ucfirst($name);
if (class_exists($class)) {
$helper = new $class();
$this->set($name, $helper);

View file

@ -1,6 +1,6 @@
<?php
namespace ViewHelper;
namespace Httpcb\ViewHelper;
/**
* Class UrlStyle

View file

@ -1,24 +1,25 @@
<?php
namespace ViewHelper\Volt;
namespace Httpcb\ViewHelper\Volt;
use \Phalcon\Di\InjectionAwareInterface;
use Phalcon\DiInterface,
Phalcon\Di\InjectionAwareInterface;
class Extension implements InjectionAwareInterface
{
protected $_serviceKey = 'viewHelper';
protected $_serviceKey = 'HttpcbViewHelper';
/**
* @var \Phalcon\DiInterface
* @var DiInterface
*/
protected $_di;
public function __construct(\Phalcon\DiInterface $dependencyInjector)
public function __construct(DiInterface $dependencyInjector)
{
$this->_di = $dependencyInjector;
if (!$this->_di->has($this->_serviceKey)) {
$this->_di->set($this->_serviceKey, '\ViewHelper\Service', true);
$this->_di->set($this->_serviceKey, 'Httpcb\ViewHelper\Service', true);
}
}
@ -39,7 +40,7 @@ class Extension implements InjectionAwareInterface
*
* @param mixed $dependencyInjector
*/
public function setDI(\Phalcon\DiInterface $dependencyInjector)
public function setDI(DiInterface $dependencyInjector)
{
$this->_di = $dependencyInjector;
}

View file

@ -2,7 +2,7 @@
namespace Model\Data;
use Mvc\Model\Behavior\RandomId as RandomIdBehavior;
use Httpcb\Mvc\Model\Behavior\RandomId as RandomIdBehavior;
use Phalcon\Mvc\Model;
class Callback extends Model

View file

@ -1,18 +1,19 @@
<?php
use Phalcon\Acl;
use Phalcon\Events\Event;
use Phalcon\Mvc\Dispatcher;
use Httpcb\Acl;
class AclPlugin extends Phalcon\Mvc\User\Plugin
{
public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
{
// We only have two roles for now, authenticated users and guests.
if ($this->auth->hasIdentity()) {
$role = \Acl\Acl::ROLE_USER;
$role = Acl::ROLE_USER;
} else {
$role = \Acl\Acl::ROLE_GUEST;
$role = Acl::ROLE_GUEST;
}
// Support annotations for actions to define custom resources.
@ -32,7 +33,7 @@ class AclPlugin extends Phalcon\Mvc\User\Plugin
// Now, check and redirect user to login page if
// this role does not have access to this resource.
if ($this->acl->isAllowed($role, $resource, 'Read') == Acl::DENY) {
if ($this->acl->isAllowed($role, $resource, 'Read') == \Phalcon\Acl::DENY) {
// Forward to login page.
$dispatcher->forward(array(