Check for access to a model

@param  string $modelClass
@param  string|array $privilege
@return boolean
767774
public function isAllowedModel($modelClass, $privilege = null)
    {
        return $this->isAllowed($this->modelResourceGenerator($modelClass), $privilege);
    }
97791
function isAllowed($role, $resource, $privilege)
	{
		if ($this->mode == self::MODE_OPTIMISTIC) {
			$roles = $this->aclModel->getTableSelection()
				->select('role')
				->where('namespace', $this->getNamespaceRepository()->getCurrentNamespace())
				->where('resource', $resource)
				->where('privilege', $privilege)
				->fetchPairs('role', 'role');
			return count($roles) == 0 || array_key_exists($role, $roles);
		} elseif($this->mode == self::MODE_PESSIMISTIC) {
			return (bool) $this->aclModel->getTableSelection()
				->select('id')
				->where('namespace', $this->getNamespaceRepository()->getCurrentNamespace())
				->where('role', $role)
				->where('resource', $resource)
				->where('privilege', $privilege)
				->count();
		}
	}
966783
public function isAllowed($module, $privilege): bool
    {
        if ($privilege) {
            $user = Auth::getIdentity();
            return $user && $user->hasPrivilege($module, $privilege);
        }
        return true;
    }
699459
public static function applicablePropertyModelId($class, $forceRefresh = false)
    {
        //ability to store properties of all model heirs in the one set of tables
        if (true === method_exists($class, 'getApplicableClass')) {
            $modelClass = call_user_func([$class, 'getApplicableClass']);
        } else {
            $modelClass = is_string($class) ? $class : get_class($class);
        }
        self::retrieveApplicablePropertyModels($forceRefresh);

        if (isset(self::$applicablePropertyModels[$modelClass])) {
            return self::$applicablePropertyModels[$modelClass];
        } else {
            throw new Exception('Property group model record not found for class: ' . $modelClass);
        }
    }
329206
public function getTokenModel($modelClass = 'StandardTokenModel')
    {
        if (! isset($this->_tokenModels[$modelClass])) {
            $this->_tokenModels[$modelClass] = $this->_loadClass('Model_' . $modelClass, true);
            $this->_tokenModels[$modelClass]->applyFormatting();
        }

        return $this->_tokenModels[$modelClass];
    }
618339
protected function getVerboseChildrenName($modelClass)
    {
        $info = $this->getInformationRepository()->getByModelClass($modelClass);

        if ( ! $info) {
            return cms_trans('models.list-parents.models');
        }

        return $info->labelPlural();
    }
147009
function checkAccess( $nodeID, $class )
    {
        $parentNodeObj = eZContentObjectTreeNode::fetch( $nodeID );
        $parentObject =  $parentNodeObj->attribute( 'object' );

        if ( $parentNodeObj->checkAccess( 'create',
                                          $class->attribute( 'id' ),
                                          $parentObject->attribute( 'contentclass_id' ) ) != '1' )
        {
            return false;
        }
        return true;
    }
707943
public function getSchemaByType($modelClass)
    {
        if (array_key_exists($modelClass, $this->schemaInstances) === true) {
            return $this->schemaInstances[$modelClass];
        }

        if ($this->hasSchemaForModelClass($modelClass) === false) {
            throw new InvalidArgumentException("Schema was not registered for model '$modelClass'.");
        }

        $schemaClass = $this->model2schemaMap[$modelClass];
        $schema      = new $schemaClass($this->factory, $this);

        $this->schemaInstances[$modelClass] = $schema;

        return $schema;
    }
792250
public function setModel($modelClass) {
		$reflection = new ReflectionClass($modelClass);
		if (! $reflection->implementsInterface('ZExt\Model\ModelInterface')) {
			throw new Exception('Class of a model must implements "ModelInterface"');
		}
		
		$this->_modelClass = $modelClass;
		
		if (! empty($this->_models)) {
			$currentModels = $this->_models;
			$this->_models = [];

			foreach ($currentModels as $key => $model) {
				if ($model instanceof $modelClass) {
					$this->_models[$key] = $model;
				} else {
					$model->uninitialize();
				}
			}
		}
				
		return $this;
	}
781100
public function formClass($resource, $modelClass=null)
    {
        if ($modelClass) {
            return $this->findClass($modelClass.'Form');
        }
        return $this->findClass($this->className($resource).'Form');
    }
833098
protected function dropTableIfExists(string $modelClass): void
    {
        assert(
            $this->getModelSchemas()->hasClass($modelClass),
            "Class `$modelClass` is not found in model Schemas."
        );
        $tableName     = $this->getModelSchemas()->getTable($modelClass);
        $schemaManager = $this->getSchemaManager();

        if ($schemaManager->tablesExist([$tableName]) === true) {
            $schemaManager->dropTable($tableName);
        }
    }
1156969
public function isEnabled(string $resourceClass = null, string $operationName = null, array $context = []): bool
    {
        return $this->getEnabled($context, $resourceClass, $operationName);
    }
247464
protected function findModel($modelClass, $attributes = [])
    {
        $query = $this->buildQuery($modelClass, $attributes);

        return $query->first();
    }
1308722
private function getEnabled(array $context, string $resourceClass = null, string $operationName = null, bool $partial = false): bool
    {
        $enabled = $this->options[$partial ? 'partial' : 'enabled'];
        $clientEnabled = $this->options[$partial ? 'client_partial' : 'client_enabled'];

        if (null !== $resourceClass) {
            $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
            $enabled = $resourceMetadata->getCollectionOperationAttribute($operationName, $partial ? 'pagination_partial' : 'pagination_enabled', $enabled, true);

            $clientEnabled = $resourceMetadata->getCollectionOperationAttribute($operationName, $partial ? 'pagination_client_partial' : 'pagination_client_enabled', $clientEnabled, true);
        }

        if ($clientEnabled) {
            return filter_var($this->getParameterFromContext($context, $this->options[$partial ? 'partial_parameter_name' : 'enabled_parameter_name'], $enabled), FILTER_VALIDATE_BOOLEAN);
        }

        return $enabled;
    }
674103
public function assert(
        Acl $acl,
        RoleInterface $role = null,
        ResourceInterface $resource = null,
        $privilege = null
    ) {
        if (!$role instanceof UserInterface || !$resource instanceof JobInterface || 'edit' != $privilege) {
            return false;
        }

        /* @var $resource \Jobs\Entity\JobInterface */
        return $resource->getPermissions()->isGranted($role->getId(), Permissions::PERMISSION_CHANGE)
               || $this->checkOrganizationPermissions($role, $resource)
               || (null === $resource->getUser() && \Auth\Entity\UserInterface::ROLE_ADMIN == $role->getRole());
    }
1069649
private function getRule($role, $resource, $privilege)
    {
        $role = $this->roles->get($role);

        if (is_scalar($resource)) {
            $resource = new Resource($resource);
        } elseif (!$resource instanceof ResourceInterface) {
            throw new \InvalidArgumentException('$resource is expected to be of type string or Gobline\Acl\ResourceInterface');
        }

        if (is_scalar($privilege)) {
            $privilege = new Privilege($privilege);
        } elseif (!$privilege instanceof Privilege) {
            throw new \InvalidArgumentException('$privilege is expected to be of type string or Gobline\Acl\Privilege');
        }

        foreach ($this->rules as $rule) {
            if (!$rule->getRole()->equals($role)) {
                continue;
            }
            if (!$rule->getPrivilege()->equals($privilege) && !$rule->getPrivilege()->equals('*')) {
                continue;
            }
            if (!$rule->getResource()->matches($resource) && (!$rule->getResource() instanceof Resource || !$rule->getResource()->matches('*'))) {
                continue;
            }

            return $rule;
        }

        foreach ($role->getParents() as $role) {
            $rule = $this->getRule($role, $resource, $privilege);
            if ($rule !== null) {
                return $rule;
            }
        }

        return null;
    }
1177161
public function validateReflectionClassForAccessorNotPrivate(\ReflectionClass $reflectionClass)
    {
        $methods = array_merge(
            $reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED),
            $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC)
        );

        if (empty($methods)) {
            return new CoverFishMessageError(
                CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND, null
            );
        }

        return true;
    }