This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Core\Acl; | |
use Zend\ServiceManager\ServiceManager; | |
use Zend\ServiceManager\ServiceManagerAwareInterface; | |
use Zend\ServiceManager\Exception\ServiceNotFoundException; | |
use Zend\Permissions\Acl\Acl; | |
use Zend\Permissions\Acl\Role\GenericRole as Role; | |
use Zend\Permissions\Acl\Resource\GenericResource as Resource; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Verifica se precisa fazer a autorização do acesso | |
* @param MvcEvent $event Evento | |
* @return boolean | |
*/ | |
public function mvcPreDispatch($event) | |
{ | |
$di = $event->getTarget()->getServiceLocator(); | |
$routeMatch = $event->getRouteMatch(); | |
$moduleName = $routeMatch->getParam('module'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Faz a autorização do usuário para acessar o recurso | |
* @param string $moduleName Nome do módulo sendo acessado | |
* @param string $controllerName Nome do controller | |
* @param string $actionName Nome da ação | |
* @return boolean | |
*/ | |
public function authorize($moduleName, $controllerName, $actionName) | |
{ | |
$auth = new AuthenticationService(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Core\View\Helper; | |
use Zend\View\Helper\AbstractHelper; | |
use Zend\ServiceManager\ServiceLocatorAwareInterface; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
/** | |
* Helper que inclui a sessão nas views |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'service_manager' => array( | |
'factories' => array( | |
'Session' => function($sm) { | |
return new Zend\Session\Container('ZF2napratica'); | |
}, | |
'Admin\Service\Auth' => function($sm) { | |
$dbAdapter = $sm->get('DbAdapter'); | |
return new Admin\Service\Auth($dbAdapter); | |
}, | |
'Cache' => function($sm) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'service_manager' => array( | |
'factories' => array( | |
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory', | |
), | |
), | |
'translator' => array( | |
'locale' => 'pt_BR', | |
'translation_file_patterns' => array( | |
array( | |
'type' => 'phparray', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retorna os comentários de um post | |
* @return Zend\Http\Response | |
*/ | |
public function commentsAction() | |
{ | |
$id = (int) $this->params()->fromRoute('id', 0); | |
$where = array('post_id' => $id); | |
$comments = $this->getTable('Application\Model\Comment') | |
->fetchAll(null, $where) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retorna os comentários de um post | |
* @return Zend\Http\Response | |
*/ | |
public function commentsAction() | |
{ | |
$id = (int) $this->params()->fromRoute('id', 0); | |
$where = array('post_id' => $id); | |
$comments = $this->getTable('Application\Model\Comment') | |
->fetchAll(null, $where) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//no Module.php | |
/** | |
* Retorna a configuração do service manager do módulo | |
* @return array | |
*/ | |
public function getServiceConfig() | |
{ | |
return array( | |
'factories' => array( | |
'Admin\Service\Auth' => function($sm) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "zendframework/skeleton-application", | |
"description": "Skeleton Application for ZF2", | |
"license": "BSD-3-Clause", | |
"keywords": [ | |
"framework", | |
"zf2" | |
], | |
"homepage": "http://framework.zend.com/", | |
"minimum-stability": "dev", |