Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zend Framework zend_acl zend_auth
cykcykacz
post
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


Witam, uczę się Zend Framework z tutoriala, w pewnym momencie napotykam na błąd.

Plik Bootstrap.php
Kod
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoLoad() {

        $modelLoader = new Zend_Application_Module_AutoLoader(array(
                        'namespace' => '',
                        'basePath' => APPLICATION_PATH ));

        $this->_acl = new Model_LibraryAcl;
        $this->_auth = Zend_Auth::getInstance();

        $fc = Zend_Controller_Front::getInstance();
        $fc->registerPlugin(new Plugin_AccessCheck());

        return $modelLoader;
    }



Plik AccessCheck.php
Kod
<?php
class Plugin_AccessCheck extends Zend_Controller_Plugin_Abstract {

     private $_acl = null;
     private $_auth = null;

    public function __construct(Zend_Acl $acl, Zend_Auth $auth) {
        $this->_acl = $acl;
        $this->_acl = $auth;
    }
    public function preDispatch(Zend_Controller_Request_Abstract $request) {
                $resource = $request->getControllerName();
                $action = $request->getActionName();

                $identity = $this->_auth->getSorage()->read();
                $role = $identity->role;

                if(!$this->_acl->isAllowed($role, $resource, $action)){
                                $request->setControllerName('authentication')
                                        ->setActionName('login');
        }
    }
}


Plik LibraryAcl.php
Kod
<?php
class Model_LibraryAcl extends Zend_Acl {
    public function __construct() {
        $this->add(new Zend_Acl_Resource('sala'));
        $this->add(new Zend_Acl_Resource('edit'), 'sala');
        $this->add(new Zend_Acl_Resource('add'), 'sala');

        $this->add(new Zend_Acl_Resource('sale'));
        $this->add(new Zend_Acl_Resource('list'), 'sale');

        $this->addRole(new Zend_Acl_Role('user'));
        $this->addRole(new Zend_Acl_Role('admin'), 'user');

        $this->allow('user', 'sale', 'list');
        $this->allow('admin', 'sala', 'edit');
        $this->allow('admin', 'sala', 'add');
    }
}


Otrzymuję taki komunikat:
Kod
Catchable fatal error: Argument 1 passed to Plugin_AccessCheck::__construct() must be an instance of Zend_Acl, none given, called in C:\xampp\htdocs\sala\application\Bootstrap.php on line 15 and defined in C:\xampp\htdocs\sala\application\plugins\AccessCheck.php on line 7


Proszę o lekarstow:).
Ps: Pewnie wszystko jest ładnie opisane w komunikacie błędu, jednak ja jeszcze tego nie ogarniam.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 2.10.2025 - 23:44