phalconplus Documentation v1.2.0
Class
Class PhalconPlus Auth

# Policy

        namespace PhalconPlus\Auth;
    use PhalconPlus\Contracts\Auth\UserProvider;
    use PhalconPlus\Contracts\Auth\Policy as PolicyContract;
    use Phalcon\Mvc\Model;
    use Phalcon\Di\Injectable;
    use Phalcon\Acl\Adapter\Memory as AclList;
    use PhalconPlus\Facades\Acl;

    class Policy extends Injectable implements PolicyContract
    {
        protected acl;

        public function __construct()
        {
            let this->acl = this->getDI()->get("acl");
        }

        public function list( user,  model) -> bool
        {
            return this->acl->isAllowed(
                user->getRole(),
                get_class(model),
                "list",
                [
                    user,
                    model
                ]
            );
        }

        public function view( user,  model) -> bool
        {
            return this->acl->isAllowed(
                user->getRole(),
                get_class(model),
                "view",
                [
                    user,
                    model
                ]
            );
        }

        public function delete( user,  model) -> bool
        {
            return this->acl->isAllowed(
                user->getRole(),
                get_class(model),
                "delete",
                [
                    user,
                    model
                ]
            );
        }

        public function update( user,  model) -> bool
        {
            return this->acl->isAllowed(
                user->getRole(),
                get_class(model),
                "update",
                [
                    user,
                    model
                ]
            );
        }

        public function create( user,  model) -> bool
        {
            return this->acl->isAllowed(
                user->getRole(),
                get_class(model),
                "create",
                [
                    user,
                    model
                ]
            );
        }
    }