Check whether a given request has permission to read post statuses.

@param  WP_REST_Request $request Full details about the request.
@return WP_Error|boolean
436175
public function get_items_permissions_check( $request ) {
		if ( 'edit' === $request['context'] ) {
			$types = get_post_types( array( 'show_in_rest' => true ), 'objects' );
			foreach ( $types as $type ) {
				if ( current_user_can( $type->cap->edit_posts ) ) {
					return true;
				}
			}
			return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
		}
		return true;
	}
410147
public function canShareRequest(ComSharesSharerRequest $request)
    {
        $object = $request->object;

        return $object->access == 'public' && !$this->_session->isReadOnly();
    }
868477
public function get_item( $request ) {
		$posts = get_posts(
			[
				'p' => $request['parent'],
				'post_type' => $this->post_type,
				'post_status' => [ 'web-only', 'publish' ],
			]
		);
		$error = new \WP_Error(
			'rest_post_invalid_id', __( 'Invalid post ID.' ), [
				'status' => 404,
			]
		);
		if ( empty( $posts ) ) {
			return $error;
		}

		$section_meta = $this->buildMetadata(
			get_section_information( $request['parent'] ),
			Book::getBookInformation()
		);

		$response = rest_ensure_response( $section_meta );
		$this->linkCollector['self'] = [
			'href' => rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], 'metadata' ) ),
		];
		$this->linkCollector[ $this->post_type ] = [
			'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->parent_base, $request['parent'] ) ),
		];
		$response->add_links( $this->linkCollector );

		return $response;
	}
524781
public function getPermissionsAction(Request $request)
    {
        $group = $request->attributes->get('group');
        $aclManager = $this->getContainer()->get('security.acl_manager');
        $parentClass = 'BackBee\ClassContent\AbstractClassContent';

        $categories['parent'] = [
            'class' => $parentClass,
            'rights' => $aclManager->getPermissions($parentClass, $group)
        ];

        $allClassContentClassNames = $this->getClassContentManager()->getAllClassContentClassnames();

        foreach ($this->getCategoryManager()->getCategories() as $id => $category) {

            foreach($category->getBlocks() as $key => $block){

                $className = AbstractClassContent::getClassnameByContentType($block->type);
                $block->rights = $aclManager->getPermissions($className, $group);
                $block->type = $className;

                $allClassContentClassNames = array_diff($allClassContentClassNames, [$className]);
            }

            if(false === empty($category->getBlocks())) {

                $categories['objects'][] = array_merge(['id' => $id], $category->jsonSerialize());
            }
        }

        $otherCategory = new Category('Other');

        foreach ($allClassContentClassNames as $class) {

            $content = new $class();

            if(false === $content->isElementContent()){

                if(null === $content->getProperty('name')){

                    $content->setProperty('name', $content->getContentType());
                }

                $otherCategory->addBlock($content);
            }
        }

        $categories['objects'][] = array_merge(['id' => 'other'], $otherCategory->jsonSerialize());

        return $this->createJsonResponse($categories, 200);
    }
778385
public function viewAction(Request $request)
    {
        $token = $this->getHttpRequestVerifier()->verify($request);

        $status = new BinaryMaskStatusRequest($token);

        $this->getPayum()->getPayment($token->getPaymentName())->execute($status);

        return array(
            'status' => $status,
        );
    }
540401
public function get_items( $request ) {
		$data = array();
		$statuses = get_post_stati( array( 'internal' => false ), 'object' );
		$statuses['trash'] = get_post_status_object( 'trash' );
		foreach ( $statuses as $slug => $obj ) {
			$ret = $this->check_read_permission( $obj );
			if ( ! $ret ) {
				continue;
			}
			$status = $this->prepare_item_for_response( $obj, $request );
			$data[ $obj->name ] = $this->prepare_response_for_collection( $status );
		}
		return rest_ensure_response( $data );
	}
984114
def _check_permission(self, request):
        

        if self.access_controller:
            self.access_controller.check_perm(request, self)
340074
public function delete_item_permissions_check( $request ) {

		$id = (int) $request['id'];

		if ( ! current_user_can( 'delete_user', $id ) ) {
			return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
120453
public function create_item_permissions_check( $request ) {
		$ret = parent::create_item_permissions_check( $request );
		if ( ! $ret || is_wp_error( $ret ) ) {
			return $ret;
		}

		if ( ! current_user_can( 'upload_files' ) ) {
			return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) );
		}

		// Attaching media to a post requires ability to edit said post.
		if ( ! empty( $request['post'] ) ) {
			$parent = $this->get_post( (int) $request['post'] );
			$post_parent_type = get_post_type_object( $parent->post_type );
			if ( ! current_user_can( $post_parent_type->cap->edit_post, $request['post'] ) ) {
				return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this resource.' ), array( 'status' => rest_authorization_required_code() ) );
			}
		}

		return true;
	}
487505
private function checkRequest(ServerRequestInterface $request): bool
    {
        if ($request->getParsedBody() && !$this->override) {
            return false;
        }

        if (!in_array($request->getMethod(), $this->methods, true)) {
            return false;
        }

        $contentType = $request->getHeaderLine('Content-Type');

        foreach ($this->contentType as $allowedType) {
            if (stripos($contentType, $allowedType) === 0) {
                return true;
            }
        }

        return false;
    }
1143917
public function postUserRolePermissions(Request $request)
  {
    $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
    $role = Role::with('permissions')->whereName($request->role)->first();
    $role->permissions()->detach();
    foreach ($request->permissions as $permission_name) {
      $permission = Permission::whereName($permission_name)->first();
      $role->assign($permission);
    }
    \Session::flash('flash_message', 'Permission granted!');
    return \Redirect::route('admin.assign-role-permissions',[
    ]);
  }
1084332
public function get_item( $request ) {
		$obj = get_post_type_object( $request['type'] );
		if ( empty( $obj ) ) {
			return new WP_Error( 'rest_type_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );
		}
		if ( empty( $obj->show_in_rest ) ) {
			return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}
		if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) {
			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage this resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}
		$data = $this->prepare_item_for_response( $obj, $request );
		return rest_ensure_response( $data );
	}
399594
public function get_items_permissions_check( $request ) {

		$post_type = get_post_type_object( $this->post_type );

		if ( 'edit' === $request['context'] && ! current_user_can( $post_type->cap->edit_posts ) ) {
			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit these posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
179889
public function get_item( $request ) {
		$obj = get_post_status_object( $request['status'] );
		if ( empty( $obj ) ) {
			return new WP_Error( 'rest_status_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );
		}
		$data = $this->prepare_item_for_response( $obj, $request );
		return rest_ensure_response( $data );
	}
744312
public function store(CreatePermissionRequest $request)
    {
        $input = $request->all();

        $permission = $this->repository->create($input);
        $permission->load($request->getWith());

        return $this->sendResponse($permission, 'Permission saved successfully.');
    }
1299703
public function get_items_permissions_check( $request ) {
		if ( 'edit' === $request['context'] ) {
			if ( ! empty( $request['type'] ) ) {
				$taxonomies = get_object_taxonomies( $request['type'], 'objects' );
			} else {
				$taxonomies = get_taxonomies( '', 'objects' );
			}
			foreach ( $taxonomies as $taxonomy ) {
				if ( ! empty( $taxonomy->show_in_rest ) && current_user_can( $taxonomy->cap->manage_terms ) ) {
					return true;
				}
			}
			return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
		}
		return true;
	}
1321372
private function checkRequest(ServerRequestInterface $request): bool
    {
        $contentType = $request->getHeaderLine('Content-Type');
        foreach ($this->contentType as $allowedType) {
            if (\stripos($contentType, $allowedType) === 0) {
                return true;
            }
        }
        return false;
    }