Fixing proper namespace for app/library
This commit is contained in:
parent
cb1e40ee0a
commit
aa37d10024
22 changed files with 78 additions and 62 deletions
|
|
@ -8,14 +8,14 @@ $loader = new \Phalcon\Loader();
|
||||||
$loader->registerDirs(
|
$loader->registerDirs(
|
||||||
array(
|
array(
|
||||||
$config->application->controllersDir,
|
$config->application->controllersDir,
|
||||||
$config->application->libraryDir,
|
|
||||||
$config->application->pluginsDir
|
$config->application->pluginsDir
|
||||||
)
|
)
|
||||||
)->register();
|
)->register();
|
||||||
|
|
||||||
$loader->registerNamespaces(array(
|
$loader->registerNamespaces(array(
|
||||||
'Model' => $config->application->modelsDir,
|
'Model' => $config->application->modelsDir,
|
||||||
'Form' => $config->application->formsDir,
|
'Form' => $config->application->formsDir,
|
||||||
|
'Httpcb' => $config->application->libraryDir,
|
||||||
));
|
));
|
||||||
|
|
||||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
|
||||||
|
|
@ -5,22 +5,29 @@
|
||||||
* @var \Phalcon\Config $config
|
* @var \Phalcon\Config $config
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Phalcon\Di\FactoryDefault;
|
|
||||||
use Phalcon\Mvc\View;
|
|
||||||
use Phalcon\Assets\Manager as AssetsManager;
|
use Phalcon\Di\FactoryDefault,
|
||||||
use Phalcon\Mvc\Url as UrlResolver;
|
Phalcon\Mvc\View,
|
||||||
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
|
Phalcon\Assets\Manager as AssetsManager,
|
||||||
use Navigation\Navigation;
|
Phalcon\Mvc\Url as UrlResolver,
|
||||||
use Phalcon\Flash\Direct as FlashDirect;
|
Phalcon\Mvc\View\Engine\Volt as VoltEngine,
|
||||||
use Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData;
|
Phalcon\Flash\Direct as FlashDirect,
|
||||||
use Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData;
|
Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData,
|
||||||
use Phalcon\Cache\Frontend\Data as FrontendDataCache;
|
Phalcon\Mvc\Model\MetaData\Apc as ApcMetaData,
|
||||||
use Phalcon\Cache\Backend\Apc as BackendApcCache;
|
Phalcon\Cache\Frontend\Data as FrontendDataCache,
|
||||||
use Phalcon\Translate\Adapter\NativeArray as TranslateAdapter;
|
Phalcon\Cache\Backend\Apc as BackendApcCache,
|
||||||
use Phalcon\Logger;
|
Phalcon\Translate\Adapter\NativeArray as TranslateAdapter,
|
||||||
use Phalcon\Logger\Adapter\Firephp as FirephpAdapter;
|
Phalcon\Logger,
|
||||||
use Phalcon\Session\Adapter\Files as SessionAdapter;
|
Phalcon\Logger\Adapter\File as FileLogAdapter,
|
||||||
use Phalcon\Mvc\Router;
|
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
|
* 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() {
|
$di->setShared('logger', function() {
|
||||||
|
|
||||||
//return new Phalcon\Logger\Adapter\Firephp("");
|
//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) {
|
$di->setShared('dispatcher', function() use ($di, $config) {
|
||||||
|
|
@ -119,7 +126,7 @@ $di->setShared('router', function() {
|
||||||
return $router;
|
return $router;
|
||||||
});
|
});
|
||||||
|
|
||||||
$di->setShared('viewHelper', '\ViewHelper\Service');
|
$di->setShared('viewHelper', 'Httpcb\ViewHelper\Service');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting up the view component
|
* Setting up the view component
|
||||||
|
|
@ -145,7 +152,7 @@ $di->setShared('view', function () use ($di, $config) {
|
||||||
|
|
||||||
// Register view helpers
|
// Register view helpers
|
||||||
$compiler = $volt->getCompiler();
|
$compiler = $volt->getCompiler();
|
||||||
$compiler->addExtension(new \ViewHelper\Volt\Extension($di));
|
$compiler->addExtension(new Httpcb\ViewHelper\Volt\Extension($di));
|
||||||
|
|
||||||
return $volt;
|
return $volt;
|
||||||
},
|
},
|
||||||
|
|
@ -274,12 +281,10 @@ $di->set('oauth', function() use ($config) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$di->set('auth', function() use ($config) {
|
$di->set('auth', function() use ($config) {
|
||||||
return new Auth\Auth($config);
|
return new Auth($config);
|
||||||
});
|
});
|
||||||
|
|
||||||
$di->set('acl', function() {
|
$di->set('acl', 'Httpcb\Acl');
|
||||||
return new Acl\Acl();
|
|
||||||
});
|
|
||||||
|
|
||||||
$di->set('menu', function() use ($di) {
|
$di->set('menu', function() use ($di) {
|
||||||
|
|
||||||
|
|
@ -322,9 +327,9 @@ $di->set('menu', function() use ($di) {
|
||||||
$menu = new Menu($navigation);
|
$menu = new Menu($navigation);
|
||||||
$menu->setMenuClass(null);
|
$menu->setMenuClass(null);
|
||||||
if ($di->get('auth')->hasIdentity()) {
|
if ($di->get('auth')->hasIdentity()) {
|
||||||
$menu->setAclRole(Acl\Acl::ROLE_USER);
|
$menu->setAclRole(Acl::ROLE_USER);
|
||||||
} else {
|
} else {
|
||||||
$menu->setAclRole(Acl\Acl::ROLE_GUEST);
|
$menu->setAclRole(Acl::ROLE_GUEST);
|
||||||
}
|
}
|
||||||
return $menu;
|
return $menu;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ use Phalcon\Forms\Element\Text,
|
||||||
*/
|
*/
|
||||||
use Phalcon\Validation\Validator\Callback as CallbackValidator,
|
use Phalcon\Validation\Validator\Callback as CallbackValidator,
|
||||||
Phalcon\Validation\Validator\Uniqueness as UniquenessValidator,
|
Phalcon\Validation\Validator\Uniqueness as UniquenessValidator,
|
||||||
\Validation\Validator\Alpha as AlphaValidator,
|
|
||||||
Phalcon\Validation\Validator\Alnum as AlnumValidator,
|
Phalcon\Validation\Validator\Alnum as AlnumValidator,
|
||||||
Phalcon\Validation\Validator\PresenceOf as PresenceOfValidator,
|
Phalcon\Validation\Validator\PresenceOf as PresenceOfValidator,
|
||||||
Phalcon\Validation\Validator\Email as EmailValidator,
|
Phalcon\Validation\Validator\Email as EmailValidator,
|
||||||
Phalcon\Validation\Validator\Confirmation as ConfirmationValidator,
|
Phalcon\Validation\Validator\Confirmation as ConfirmationValidator,
|
||||||
Phalcon\Validation\Validator\StringLength as StringLengthValidator,
|
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
|
class UserSettings extends FormBase
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Acl;
|
namespace Httpcb;
|
||||||
|
|
||||||
use Phalcon\Acl\Role;
|
use Phalcon\Acl\Role;
|
||||||
use Phalcon\Acl\Adapter\Memory as AclList;
|
use Phalcon\Acl\Adapter\Memory as AclList;
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Auth;
|
namespace Httpcb;
|
||||||
|
|
||||||
use Phalcon\Mvc\User\Component;
|
use Phalcon\Mvc\User\Component;
|
||||||
use Model\Data\User;
|
use Model\Data\User;
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Httpcb;
|
||||||
|
|
||||||
class Debug {
|
class Debug {
|
||||||
|
|
||||||
public static function dump($var, $label = null, $echo = true)
|
public static function dump($var, $label = null, $echo = true)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Httpcb;
|
||||||
|
|
||||||
use Phalcon\Tag;
|
use Phalcon\Tag;
|
||||||
use Navigation\Node;
|
|
||||||
use Navigation\Navigation;
|
use Httpcb\Acl,
|
||||||
|
Httpcb\Navigation,
|
||||||
|
Httpcb\Navigation\Node;
|
||||||
|
|
||||||
class Menu extends Tag
|
class Menu extends Tag
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Mvc\Model\Behavior;
|
namespace Httpcb\Mvc\Model\Behavior;
|
||||||
|
|
||||||
use \Phalcon\Mvc\Model\Behavior;
|
use \Phalcon\Mvc\Model\Behavior;
|
||||||
use \Phalcon\Mvc\Model\BehaviorInterface;
|
use \Phalcon\Mvc\Model\BehaviorInterface;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Navigation;
|
namespace Httpcb;
|
||||||
|
|
||||||
class Navigation extends Container
|
class Navigation extends Navigation\Container
|
||||||
{
|
{
|
||||||
public function __construct($config)
|
public function __construct($config)
|
||||||
{
|
{
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Navigation;
|
namespace Httpcb\Navigation;
|
||||||
|
|
||||||
class Container
|
class Container
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Navigation;
|
namespace Httpcb\Navigation;
|
||||||
|
|
||||||
class Exception extends \Exception
|
class Exception extends \Exception
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Navigation;
|
namespace Httpcb\Navigation;
|
||||||
|
|
||||||
use \Phalcon\Di;
|
use \Phalcon\Di;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
//use Opauth;
|
namespace Httpcb;
|
||||||
|
|
||||||
use Phalcon\Mvc\User\Component;
|
use Phalcon\Mvc\User\Component;
|
||||||
|
|
||||||
|
use Opauth;
|
||||||
|
|
||||||
class OAuth extends Component
|
class OAuth extends Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Validation\Validator;
|
namespace Httpcb\Validation\Validator;
|
||||||
|
|
||||||
use Phalcon\Validation\Message;
|
use Phalcon\Validation\Message;
|
||||||
use Phalcon\Validation\Validator as BaseValidator;
|
use Phalcon\Validation\Validator as BaseValidator;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ViewHelper;
|
namespace Httpcb\ViewHelper;
|
||||||
|
|
||||||
use Phalcon\DiInterface;
|
use Phalcon\DiInterface;
|
||||||
use Phalcon\Di\InjectionAwareInterface;
|
use Phalcon\Di\InjectionAwareInterface;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ViewHelper;
|
namespace Httpcb\ViewHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Icon
|
* Class Icon
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ViewHelper;
|
namespace Httpcb\ViewHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ServerUrl
|
* Class ServerUrl
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ViewHelper;
|
namespace Httpcb\ViewHelper;
|
||||||
|
|
||||||
use Phalcon\DiInterface;
|
use Phalcon\DiInterface,
|
||||||
use Phalcon\Di\InjectionAwareInterface;
|
Phalcon\Di\InjectionAwareInterface;
|
||||||
|
|
||||||
class Service implements InjectionAwareInterface
|
class Service implements InjectionAwareInterface
|
||||||
{
|
{
|
||||||
|
|
@ -66,7 +66,7 @@ class Service implements InjectionAwareInterface
|
||||||
return $this->_helpers[$name];
|
return $this->_helpers[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = '\ViewHelper\\' . ucfirst($name);
|
$class = 'Httpcb\\ViewHelper\\' . ucfirst($name);
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$helper = new $class();
|
$helper = new $class();
|
||||||
$this->set($name, $helper);
|
$this->set($name, $helper);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ViewHelper;
|
namespace Httpcb\ViewHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UrlStyle
|
* Class UrlStyle
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ViewHelper\Volt;
|
namespace Httpcb\ViewHelper\Volt;
|
||||||
|
|
||||||
use \Phalcon\Di\InjectionAwareInterface;
|
use Phalcon\DiInterface,
|
||||||
|
Phalcon\Di\InjectionAwareInterface;
|
||||||
|
|
||||||
class Extension implements InjectionAwareInterface
|
class Extension implements InjectionAwareInterface
|
||||||
{
|
{
|
||||||
protected $_serviceKey = 'viewHelper';
|
protected $_serviceKey = 'HttpcbViewHelper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Phalcon\DiInterface
|
* @var DiInterface
|
||||||
*/
|
*/
|
||||||
protected $_di;
|
protected $_di;
|
||||||
|
|
||||||
public function __construct(\Phalcon\DiInterface $dependencyInjector)
|
public function __construct(DiInterface $dependencyInjector)
|
||||||
{
|
{
|
||||||
$this->_di = $dependencyInjector;
|
$this->_di = $dependencyInjector;
|
||||||
|
|
||||||
if (!$this->_di->has($this->_serviceKey)) {
|
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
|
* @param mixed $dependencyInjector
|
||||||
*/
|
*/
|
||||||
public function setDI(\Phalcon\DiInterface $dependencyInjector)
|
public function setDI(DiInterface $dependencyInjector)
|
||||||
{
|
{
|
||||||
$this->_di = $dependencyInjector;
|
$this->_di = $dependencyInjector;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Model\Data;
|
namespace Model\Data;
|
||||||
|
|
||||||
use Mvc\Model\Behavior\RandomId as RandomIdBehavior;
|
use Httpcb\Mvc\Model\Behavior\RandomId as RandomIdBehavior;
|
||||||
use Phalcon\Mvc\Model;
|
use Phalcon\Mvc\Model;
|
||||||
|
|
||||||
class Callback extends Model
|
class Callback extends Model
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Phalcon\Acl;
|
|
||||||
use Phalcon\Events\Event;
|
use Phalcon\Events\Event;
|
||||||
use Phalcon\Mvc\Dispatcher;
|
use Phalcon\Mvc\Dispatcher;
|
||||||
|
|
||||||
|
use Httpcb\Acl;
|
||||||
|
|
||||||
class AclPlugin extends Phalcon\Mvc\User\Plugin
|
class AclPlugin extends Phalcon\Mvc\User\Plugin
|
||||||
{
|
{
|
||||||
public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
|
public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
|
||||||
{
|
{
|
||||||
// We only have two roles for now, authenticated users and guests.
|
// We only have two roles for now, authenticated users and guests.
|
||||||
if ($this->auth->hasIdentity()) {
|
if ($this->auth->hasIdentity()) {
|
||||||
$role = \Acl\Acl::ROLE_USER;
|
$role = Acl::ROLE_USER;
|
||||||
} else {
|
} else {
|
||||||
$role = \Acl\Acl::ROLE_GUEST;
|
$role = Acl::ROLE_GUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support annotations for actions to define custom resources.
|
// 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
|
// Now, check and redirect user to login page if
|
||||||
// this role does not have access to this resource.
|
// 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.
|
// Forward to login page.
|
||||||
$dispatcher->forward(array(
|
$dispatcher->forward(array(
|
||||||
|
|
|
||||||
Reference in a new issue