Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Redirect_Code class #104

Open
GaryJones opened this issue Mar 1, 2021 · 0 comments
Open

Introduce Redirect_Code class #104

GaryJones opened this issue Mar 1, 2021 · 0 comments

Comments

@GaryJones
Copy link
Contributor

Add a class that holds the enum list (class constants) of supported redirect HTTP status codes - like 301 and 302. Note that everything other than 301 is not yet used out of the box, but there is a filter around a 301; adding a constant for 302, for example, would allow someone to use this as well to set a 302 redirect.

Something like:

<?php

declare(strict_types=1);

namespace Automattic\LegacyRedirector\Domain\Redirect;

class Redirect_Code {
	public const MULTIPLE_CHOICES   = 300;
	public const MOVED_PERMANENTLY  = 301;
	public const FOUND              = 302;
	public const SEE_OTHER          = 303;
	public const USE_PROXY          = 305;
	public const TEMPORARY_REDIRECT = 307;
	public const PERMANENT_REDIRECT = 308;

	public static function valid_redirection_codes() {
		return [
			self::MULTIPLE_CHOICES,
			self::MOVED_PERMANENTLY,
			self::FOUND,
			self::SEE_OTHER,
			self::USE_PROXY,
			self::TEMPORARY_REDIRECT,
			self::PERMANENT_REDIRECT,
		];
	}
}
@GaryJones GaryJones added this to the Future Release milestone Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant