Hi there, I just want to run a simple query inside my class. Lets say something like:
$query = "SELECT blah FROM test WHERE 1=1"; $result = execute($query); Now I have a database.local.php with settings in my config/autoload/ folder And this class... <?php /** * File for Acl Class * * @category Account * @package Account_Acl * @author Marco Neumann <webcoder_at_binware_dot_org> * @copyright Copyright (c) 2011, Marco Neumann * @license http://binware.org/license/index/type:new-bsd New BSD License */ /** * @namespace */ namespace PermissionsAcl\Controller\Plugin; /** * @uses Zend\Permissions\Acl\Acl * @uses Zend\Permissions\Acl\Role\GenericRole * @uses Zend\Permissions\Acl\Resource\GenericResource */ use Zend\Mvc\Controller\Plugin\AbstractPlugin, Zend\Session\Container as SessionContainer, Zend\Permissions\Acl\Acl, Zend\Permissions\Acl\Role\GenericRole as Role, Zend\Permissions\Acl\Resource\GenericResource as Resource, Zend\Cache\StorageFactory as StorageFactory, Pixiebox\Resources\Whitelist\ListAcl as Whitelist; /** * Class to handle Acl * * This class is for loading ACL defined in a config * * @category Account * @package Account_Acl * @copyright Copyright (c) 2011, Marco Neumann * @license http://binware.org/license/index/type:new-bsd New BSD License */ class PermissionsAcl extends AbstractPlugin { protected $sesscontainer ; private function getSessContainer() { if (!$this->sesscontainer) { $this->sesscontainer = new SessionContainer('zftutorial'); } return $this->sesscontainer; } public function doAuthorization($e) { $Listacl = new Whitelist(); $test = $Listacl->getWhitelist(); $cache = StorageFactory::factory(array( 'adapter' => array( 'name' => 'Filesystem', 'options' => array( 'cacheDir' => 'data/cache',//__DIR__ . '/../../../../../../ ), ), 'plugins' => array('serializer'), )); $cache->setItem('testing-array', array('hello' => 'test')); $array = $cache->getItem('testing-array'); print_r($array); //setting ACL... $acl = new Acl(); //add role .. $acl->addRole(new Role('anonymous')); $acl->addRole(new Role('user'), 'anonymous'); $acl->addRole(new Role('admin'), 'user'); $acl->addResource(new Resource('Application')); // $acl->addResource(new Resource('Login')); $acl->allow('anonymous', 'Application', 'view'); // $acl->allow('anonymous', 'Login', 'view'); $acl->allow('anonymous', array('Application'), array('view') ); $routeMatch = $e->getRouteMatch(); $namespaceController = $routeMatch->getParam('controller'); $namespace = str_replace('\Controller\\' . ucfirst($routeMatch->getParam('action')),'',$namespaceController); $role = (! $this->getSessContainer()->role ) ? 'anonymous' : $this->getSessContainer()->role; if ( ! $acl->isAllowed($role, $namespace, 'view')){ $router = $e->getRouter(); //$url = $router->assemble(array(), array('name' => 'Login/auth')); $response = $e->getResponse(); $response->setStatusCode(302); //redirect to login route... // $response->getHeaders()->addHeaderLine('Location', $url); } } } -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZF2-query-something-tp4656840.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com