PostField

Class. It extends Field.

use Saij\WpAppFramework\Query\Field\PostField;

A field of a meta class that refers to a post of a post class (?Venue), stored as its ID; no post is stored as 0 or not at all.

Constructor

new PostField(string $class, string $field, string $postClass)
ParameterTypeDefaultDescription
classclass-stringrequiredThe class the field belongs to: the meta class (#[PostMeta]).
fieldstringrequiredThe name of the constructor parameter.
postClassclass-string<P>requiredThe post class of the field.

Methods

equals()

equals(AbstractPost|int $post): Condition

Matches posts whose field refers to $post. Throws an InvalidArgumentException for a post of another post class or a post that has not been saved yet.

ParameterTypeDefaultDescription
postP|intrequiredA post of the post class of the field or its ID.

Returns Condition

getClass()

getClass(): string

The class the field belongs to.

Returns class-string

getField()

getField(): string

The name of the field: the name of the constructor parameter.

Returns string

in()

in(AbstractPost|int ...$posts): Condition

Matches posts whose field refers to one of $posts. Throws an InvalidArgumentException for a post of another post class or a post that has not been saved yet, or if no post is given.

ParameterTypeDefaultDescription
...postsP|intPosts of the post class of the field or their IDs.

Returns Condition

isNotNull()

isNotNull(): Condition

Posts with a post in the field.

Returns Condition

isNull()

isNull(): Condition

Posts without a post in the field.

Returns Condition

notIn()

notIn(AbstractPost|int ...$posts): Condition

Matches posts whose field refers to none of $posts, including posts without a post in the field. Throws an InvalidArgumentException for a post of another post class or a post that has not been saved yet, or if no post is given.

ParameterTypeDefaultDescription
...postsP|intPosts of the post class of the field or their IDs.

Returns Condition