@param  \WP_REST_Request $request Full details about the request.

@return bool|\WP_Error True if the request has read access, WP_Error object otherwise.
558701
public function get_items_permissions_check( $request ) {

		if ( current_user_can( 'edit_posts' ) ) {
			return true;
		}

		if ( 1 !== absint( get_option( 'blog_public' ) ) ) {
			return false;
		}

		return parent::get_items_permissions_check( $request );
	}
630250
protected function checkRequest($request)
    {
        if ($request['status_code'] === 200 || $request['status_code'] === 201) {
            return true;
        }

        $messages = array(
            204 => 'No content',
            400 => 'Bad Request',
            401 => 'Unauthorized',
            404 => 'Not Found',
            405 => 'Method Not Allowed',
            500 => 'Internal Server Error',
        );

        if (isset($messages[$request['status_code']])) {
            $xml = null;
            if ($request['response']) {
                $xml = $this->parseXML($request['response'], true);
            }

            throw new PrestashopWebServiceRequestException($messages[$request['status_code']], $request['status_code'], $xml);
        } else {
            $exception = 'This call to PrestaShop Web Services returned an unexpected HTTP status of: ';
            $exception.= $request['status_code'];
            throw new PrestashopWebServiceException($exception);
        }
    }
1128570
private function checkFormIdInPost($request)
    {
        if (!isset($request::$post[self::PARAMETER_FORM_ID])) {
            return false;
        }

        if (!$request::$post[self::PARAMETER_FORM_ID] === $this->formId) {
            return false;
        }

        return true;
    }
473915
public function isTrelloWebhook(Request $request)
    {
        if (!$request->getMethod() === 'POST') {
            return false;
        }

        if (!$request->headers->has('X-Trello-Webhook')) {
            return false;
        }

        return true;
    }
934611
public function isValid (Request $request)
		{
			$parsed = $this->parseRouteRequest($request);

			return $this->getBaseUri($request) !== null
				&& preg_match('#^' . preg_quote(rtrim($this->getBaseUri($request), '/'), '#') . '#', rtrim($request->getUri(false), '/'))
				&& $this->getController($request)->respondsTo($parsed['method'], $parsed['arguments']);
		}
1016529
public function get_items_permissions_check( $request ) {
		// Check if roles is specified in GET request and if user can list users.
		if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) {
			return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannot filter by role.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) {
			return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you cannot order by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
242476
protected function isDonateAlreadyAdded(Request $request)
    {
        /** @var \PServerCore\Entity\Repository\DonateLog $donateEntity */
        $donateEntity = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getDonateLog());

        return $donateEntity->isDonateAlreadyAdded($request->getTransactionId(),
            $this->mapPaymentProvider2DonateType($request));
    }
89633
public function get_item( $request ) {

		$parent = $this->get_post( $request['parent'] );
		if ( ! $request['parent'] || ! $parent || $this->parent_post_type !== $parent->post_type ) {
			return new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent id.' ), array( 'status' => 404 ) );
		}

		$revision = $this->get_post( $request['id'] );
		if ( ! $revision || 'revision' !== $revision->post_type ) {
			return new WP_Error( 'rest_post_invalid_id', __( 'Invalid revision id.' ), array( 'status' => 404 ) );
		}

		$response = $this->prepare_item_for_response( $revision, $request );
		return rest_ensure_response( $response );
	}
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;
	}
1200674
public function get_current_item( $request ) {
		$current_user_id = get_current_user_id();
		if ( empty( $current_user_id ) ) {
			return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) );
		}

		$user = wp_get_current_user();
		$response = $this->prepare_item_for_response( $user, $request );
		$response = rest_ensure_response( $response );
		$response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $current_user_id ) ) );
		$response->set_status( 302 );

		return $response;
	}
721347
public function get_items_permissions_check( $request ) {

		if ( ! empty( $request['post'] ) ) {
			foreach ( (array) $request['post'] as $post_id ) {
				$post = $this->get_post( $post_id );
				if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post ) ) {
					return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
				} elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
					return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
				}
			}
		}

		if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view comments with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! current_user_can( 'edit_posts' ) ) {
			$protected_params = array( 'author', 'author_exclude', 'karma', 'author_email', 'type', 'status' );
			$forbidden_params = array();
			foreach ( $protected_params as $param ) {
				if ( 'status' === $param ) {
					if ( 'approve' !== $request[ $param ] ) {
						$forbidden_params[] = $param;
					}
				} elseif ( 'type' === $param ) {
					if ( 'comment' !== $request[ $param ] ) {
						$forbidden_params[] = $param;
					}
				} elseif ( ! empty( $request[ $param ] ) ) {
					$forbidden_params[] = $param;
				}
			}
			if ( ! empty( $forbidden_params ) ) {
				return new WP_Error( 'rest_forbidden_param', sprintf( __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) );
			}
		}

		return true;
	}
25114
public function update_item_permissions_check( $request ) {

		$post = $this->get_post( $request['id'] );
		$post_type = get_post_type_object( $this->post_type );

		if ( $post && ! $this->check_update_permission( $post ) ) {
			return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to update this post.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
			return new WP_Error( 'rest_cannot_edit_others', __( 'You are not allowed to update posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
			return new WP_Error( 'rest_cannot_assign_sticky', __( 'You do not have permission to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
727446
public function check(Request $request)
    {
        $request->validate(['code' => 'required|numeric']);

        if (Hash::check($request->code, $this->getHash())) {
            session(['can_visit' => true]);

            return response([
                'status' => 'success',
            ]);
        }

        $this->incrementLoginAttempts($request);

        if ($this->hasTooManyLoginAttempts($request) && $this->throttleIsActive()) {
            return response([
                'too_many_attempts' => true,
                'seconds_message'  => TransFormer::transform($this->getBlockedSeconds($request), $this->config['seconds_message']),
            ], 401);
        }

        return response([
            'too_many_attempts' => false,
            'attempts_left'    => $this->showAttempts($request),
        ], 401);
    }
1114781
public function isValid(Request $request)
    {
        $arguments = $this->method === "GET" ? $request->get : $request->post;
        $files = $request->files;

        if (!$this->validate($arguments, $files))
            return false;

        $params = ['form' => $this, 'request' => $request, 'valid' => true, 'arguments' => $arguments];
        $params = TypedDictionary::wrap($params);
        $params->setType('errors', Type::ARRAY);
        $result = Hook::execute('Wedeto.HTTP.Forms.Form.isValid', $params);

        if (!$result['valid'])
        {
            foreach ($result['errors'] as $field => $errors)
            {
                if ($errors instanceof Dictionary)
                    $this->errors[$field] = $errors->toArray();
            }
            return false;
        }

        unset($this->form_elements[Nonce::getParameterName()]);
        unset($this->form_elements['_form_name']);

        return true;
    }
693479
public function receiveAction(Request $request): JsonResponse
    {
        if (!$this->enabled) {
            throw new AccessDeniedHttpException(
                'The receive endpoint is not enabled.',
                null,
                Code::UNIMPLEMENTED
            );
        }

        $token = $request->headers->get('x-pbjx-token');
        if (empty($token)) {
            throw new AccessDeniedHttpException(
                'The receive endpoint requires the "x-pbjx-token" header.',
                null,
                Code::PERMISSION_DENIED
            );
        }

        try {
            $this->signer->validate($request->getContent(), $request->getUri(), $token);
        } catch (\Throwable $e) {
            throw new AccessDeniedHttpException($e->getMessage(), $e, Code::PERMISSION_DENIED);
        }

        $handle = $request->getContent(true);
        $data = [
            'lines'   => [
                'total'   => 0,
                'ok'      => 0,
                'failed'  => 0,
                'ignored' => 0,
            ],
            'results' => [],
        ];

        while (($line = fgets($handle)) !== false) {
            ++$data['lines']['total'];

            $line = trim($line);
            if (empty($line)) {
                ++$data['lines']['ignored'];
                $data['results'][] = [
                    'ok'            => false,
                    'code'          => Code::INVALID_ARGUMENT,
                    'error_name'    => 'InvalidArgumentException',
                    'error_message' => 'empty line',
                ];
                continue;
            }

            $message = null;
            $result = [];

            try {
                $envelope = TransportEnvelope::fromString($line);
                $message = $envelope->getMessage();
                $this->receiveMessage($message);

                ++$data['lines']['ok'];
                $result['ok'] = true;
                $result['code'] = Code::OK;
                $result['message_ref'] = $message->generateMessageRef()->toString();
            } catch (\Throwable $e) {
                ++$data['lines']['failed'];
                $this->handleException($result, $e);

                if ($message instanceof Message) {
                    $result['message_ref'] = $message->generateMessageRef()->toString();
                }
            }

            $data['results'][] = $result;
        }

        return JsonResponse::create($data);
    }
83420
public static function canBeUsedForRequest(Request $request)
    {
        return $request->has(self::CHUNK_NUMBER_INDEX) && $request->has(self::TOTAL_CHUNKS_INDEX) &&
            $request->has(self::CHUNK_UUID_INDEX);
    }
710000
public function invoke( $request ) {
		$method_name = 'handle_' . strtolower( $request->get_method() );
		try {
			return call_user_func_array( [ $this, $method_name ], func_get_args() );
		} catch ( \Exception $e ) {
			return new \WP_Error( $e->getCode(), $e->getMessage() );
		}
	}