-
Notifications
You must be signed in to change notification settings - Fork 385
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
Refactor generated spec data to facilitate looking up by spec name #3817
Conversation
This is the best possible right now: /**
* Get tag by spec name.
*
* @since 1.5
*
* @param string $spec_name Spec name.
* @return array|null Allowed tag spec, or null if the tag does not exist.
*/
public static function find_tag_spec( $spec_name ) {
foreach ( self::$allowed_tags as $tag_name => $allowed_tag ) {
foreach ( $allowed_tag as $rule_spec ) {
if (
( ! isset( $rule_spec['tag_spec']['spec_name'] ) && $tag_name === $spec_name )
||
( isset( $rule_spec['tag_spec']['spec_name'] ) && $rule_spec['tag_spec']['spec_name'] === $spec_name )
) {
return array_merge( compact( 'tag_name' ), $rule_spec );
}
}
}
return null;
} We can eliminate looping over Only way I can think of to prevent this is having a separate index of |
d03b803
to
5e56cce
Compare
2ac3dd4
to
df10dfe
Compare
Linking to the relevant docs page on amp.dev for each violated tag spec depends on each tag spec having a |
df10dfe
to
e56b2c3
Compare
e56b2c3
to
5933df3
Compare
Closing in favor of the work that @schlessera is doing in #4566. |
Summary
Fixes #4597.
Todo
Checklist