Automattic\WooCommerce\Internal\Checkout
DateFormatLimitParser::parse
Parses a literal date limit or a reference to another date.
Метод класса: DateFormatLimitParser{}
Хуков нет.
Возвращает
Keyword|null. The date comparison, if present.
Использование
$DateFormatLimitParser = new DateFormatLimitParser(); $DateFormatLimitParser->parse( $info, $parser, $shared ): ?Keyword;
- $info(SchemaInfo) (обязательный)
- The schema to parse.
- $parser(SchemaParser) (обязательный)
- The Opis schema parser.
- $shared(объект) (обязательный)
- State shared by the keyword parsers.
Список изменений
| С версии 11.2.0 | Введена. |
Код DateFormatLimitParser::parse() DateFormatLimitParser::parse WC 11.2.2
public function parse( SchemaInfo $info, SchemaParser $parser, object $shared ): ?Keyword {
unset( $shared );
if ( ! $this->keywordExists( $info ) ) {
return null;
}
if ( 'date' !== ( $info->data()->format ?? null ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Opis requires the schema object, which is not output.
throw $this->keywordException( '{keyword} requires format: date.', $info );
}
$value = $this->keywordValue( $info );
if ( $this->isDataKeywordAllowed( $parser, $this->keyword ) ) {
$pointer = $this->getDataKeywordPointer( $value );
if ( $pointer ) {
return new DateFormatLimit( $this->keyword, $pointer );
}
}
if ( ! is_string( $value ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Opis requires the schema object, which is not output.
throw $this->keywordException( '{keyword} must contain a string or a valid $data reference.', $info );
}
return new DateFormatLimit( $this->keyword, $value );
}