get_called_class example

/** * Magic static caller * * @param string $name * @param array $args * * @throws \Enlight_Exception */
    public static function __callStatic($name$args = null)
    {
        throw new Enlight_Exception(
            'Method "' . \get_called_class() . '::' . $name . '" not found failure',
            Enlight_Exception::METHOD_NOT_FOUND
        );
    }

    /** * Magic getter * * @param string $name * * @throws \Enlight_Exception */
    

    public function checkPrivilege($privilege$resource = null)
    {
        if (!$this->getRole() || !$this->getAcl()) {
            throw new ApiException\PrivilegeException('Unable to get role or acl');
        }

        if (!$resource) {
            $calledClass = \get_called_class();
            $calledClass = explode('\\', $calledClass);
            $resource = strtolower(end($calledClass));
        }

        if (!$this->getAcl()->has($resource)) {
            throw new ApiException\PrivilegeException(sprintf('No resource "%s" found', $resource));
        }

        $role = $this->getRole();

        if (!$this->getAcl()->isAllowed($role$resource$privilege)) {
            
Home | Imprint | This part of the site doesn't use cookies.