Skip to content

Commit

Permalink
#76 - Add namespaces for each .php file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Nov 23, 2019
1 parent 713f237 commit 87f4395
Show file tree
Hide file tree
Showing 26 changed files with 103 additions and 34 deletions.
16 changes: 10 additions & 6 deletions app/Services.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php
declare(strict_types=1);

use Phalcon\Mvc\View;
use Phalcon\DI\FactoryDefault;
namespace Invo;

use Invo\Plugins\NotFoundPlugin;
use Invo\Plugins\SecurityPlugin;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Flash\Session as FlashSession;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Phalcon\Mvc\Model\Metadata\Memory as MetaData;
use Phalcon\Url as UrlProvider;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Flash\Session as FlashSession;
use Phalcon\Events\Manager as EventsManager;

class Services extends \Base\Services
{
Expand Down
1 change: 0 additions & 1 deletion app/config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ pluginsDir = app/plugins/
formsDir = app/forms/
libraryDir = app/library/
baseUri = /

3 changes: 3 additions & 0 deletions app/controllers/AboutController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

class AboutController extends ControllerBase
{
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/CompaniesController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

use Phalcon\Mvc\Model\Criteria;
use Phalcon\Paginator\Adapter\Model as Paginator;
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/ContactController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

/**
* ContactController
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/ControllerBase.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

use Phalcon\Mvc\Controller;

Expand All @@ -7,7 +10,6 @@ class ControllerBase extends Controller
protected function initialize()
{
$this->tag->prependTitle('INVO | ');

$this->view->setTemplateAfter('main');
}
}
3 changes: 3 additions & 0 deletions app/controllers/ErrorsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

/**
* ErrorsController
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/IndexController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

class IndexController extends ControllerBase
{
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/InvoicesController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

use Phalcon\Flash;
use Phalcon\Session;
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/ProductsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

use Phalcon\Mvc\Model\Criteria;
use Phalcon\Paginator\Adapter\Model as Paginator;
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/ProducttypesController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

use Phalcon\Mvc\Model\Criteria;
use Phalcon\Paginator\Adapter\Model as Paginator;
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/RegisterController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

/**
* SessionController
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/SessionController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

/**
* SessionController
Expand Down
8 changes: 5 additions & 3 deletions app/forms/CompaniesForm.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php
declare(strict_types=1);

namespace Invo\Forms;

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Form;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;

class CompaniesForm extends Form
{
Expand Down
7 changes: 5 additions & 2 deletions app/forms/ContactForm.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php
declare(strict_types=1);

namespace Invo\Forms;

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\TextArea;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Forms\Form;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\PresenceOf;

class ContactForm extends Form
{
Expand Down
3 changes: 3 additions & 0 deletions app/forms/ProductTypesForm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Forms;

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
Expand Down
10 changes: 6 additions & 4 deletions app/forms/ProductsForm.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);

namespace Invo\Controllers;

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Forms\Element\Select;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Form;
use Phalcon\Validation\Validator\Numericality;
use Phalcon\Validation\Validator\PresenceOf;

class ProductsForm extends Form
{
Expand Down
9 changes: 6 additions & 3 deletions app/forms/RegisterForm.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php
declare(strict_types=1);

namespace Invo\Forms;

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Password;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Form;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\PresenceOf;

class RegisterForm extends Form
{
Expand Down
1 change: 1 addition & 0 deletions app/library/Base/Services.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace Base;

Expand Down
3 changes: 3 additions & 0 deletions app/models/Companies.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Models;

use Phalcon\Mvc\Model;

Expand Down
5 changes: 4 additions & 1 deletion app/models/Contact.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
declare(strict_types=1);

namespace Invo\Models;

use Phalcon\Mvc\Model;
use Phalcon\Db\RawValue;
use Phalcon\Mvc\Model;

class Contact extends Model
{
Expand Down
3 changes: 3 additions & 0 deletions app/models/ProductTypes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Models;

use Phalcon\Mvc\Model;

Expand Down
3 changes: 3 additions & 0 deletions app/models/Products.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Models;

use Phalcon\Mvc\Model;

Expand Down
3 changes: 3 additions & 0 deletions app/models/Users.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
declare(strict_types=1);

namespace Invo\Models;

use Phalcon\Mvc\Model;
use Phalcon\Validation;
Expand Down
19 changes: 11 additions & 8 deletions app/plugins/NotFoundPlugin.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
<?php
declare(strict_types=1);

namespace Invo\Plugins;

use Exception;
use Phalcon\Di\Injectable;
use Phalcon\Events\Event;
use Phalcon\Mvc\User\Plugin;
use Phalcon\Dispatcher;
use Phalcon\Mvc\Dispatcher\Exception as DispatcherException;
use Phalcon\Mvc\Dispatcher as MvcDispatcher;
use Phalcon\Mvc\Dispatcher\Exception as DispatcherException;

/**
* NotFoundPlugin
*
* Handles not-found controller/actions
*/
class NotFoundPlugin extends Plugin
class NotFoundPlugin extends Injectable
{
/**
* This action is executed before perform any action in the application
*
* @param Event $event
* @param MvcDispatcher $dispatcher
* @param \Exception $exception
* @param Exception $exception
* @return boolean
*/
public function beforeException(Event $event, MvcDispatcher $dispatcher, \Exception $exception)
public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)
{
error_log(
$exception->getMessage() . PHP_EOL . $exception->getTraceAsString()
);

if ($exception instanceof DispatcherException) {
switch ($exception->getCode()) {
case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
case MvcDispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case MvcDispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(
[
'controller' => 'errors',
Expand Down
12 changes: 7 additions & 5 deletions app/plugins/SecurityPlugin.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php
declare(strict_types=1);

use Phalcon\Acl;
use Phalcon\Acl\Role;
namespace Invo\Plugins;

use Phalcon\Acl\Adapter\Memory as AclList;
use Phalcon\Acl\Resource;
use Phalcon\Acl\Role;
use Phalcon\Di\Injectable;
use Phalcon\Events\Event;
use Phalcon\Mvc\User\Plugin;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Acl\Adapter\Memory as AclList;

/**
* SecurityPlugin
*
* This is the security plugin which controls that users only have access to the modules they're assigned to
*/
class SecurityPlugin extends Plugin
class SecurityPlugin extends Injectable
{
/**
* Returns an existing or new access control list
Expand Down

2 comments on commit 87f4395

@orbex
Copy link

@orbex orbex commented on 87f4395 Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In file app/plugins/SecurityPlugin.php line 3 was removed ( use Phalcon\Acl; ) but it is referenced on line 30 ( $acl->setDefaultAction(Acl::DENY); )

@Jeckerson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I added to my open PR to fix it
#81 (comment)

Please sign in to comment.