rebelcode/expression-wp-query-builder

Abstract functionality for building WP_Query args using expressions.

v0.1-alpha1 2018-05-16 10:53 UTC

This package is auto-updated.

Last update: 2024-12-11 00:13:08 UTC


README

Build Status Code Climate Test Coverage Latest Stable Version

Abstract functionality for building WP_Query args using expressions.

Details

This package provides abstract functionality for the most implementation aspects of building WP_Query arguments from expressions. The traits in this package are meant to complement each other, while also remaining agnostic of the each other's implementation details. Most, if not all, traits are designed to provide functionality that depends on abstracted methods. Other traits in the package will offer implementations for those abstracted methods, while also depending on their own abstracted methods.

Traits

BuildWpQueryArgsCapableTrait

👁️ Build Args

Intended to provide the entry point functionality of building an expression into WP_Query args by attempting to build each expression term as either a comparison, meta query relation entry or taxonomy query relation entry.

BuildWpQueryCompareCapableTrait

👁️ Build Comparison

Provides functionality for building top-level comparison key-value pairs.

BuildWpQueryRelationCapableTrait

👁️ Build Relation

Provides functionality for building relation arrays.

BuildWpQueryRelationTermCapableTrait

👁️ Build Relation Term

Provides functionality for building the terms in a relation array, by delegating building mechanism used depending on the current relation context, i.e. meta_query relation or tax_query relation.

BuildWpQueryMetaCompareCapableTrait

👁️ Build Meta Comparison

Provides functionality for building meta comparison arrays.

BuildWpQueryTaxCompareCapableTrait

👁️ Build Taxonomy Comparison

Provides functionality for building taxonomy comparison arrays.

GetWpQueryMetaCompareOperatorCapableTrait

👁️ Get Meta Comparison Operator

Provides functionality for resolving the meta comparison compare type from an expression.

GetWpQueryMetaCompareTypeCapableTrait

👁️ Get Meta Comparison Type

Provides functionality for resolving the meta comparison value cast type from an expression.

GetWpQueryTaxCompareOperatorCapableTrait

👁️ Get Taxonomy Comparison Operator

Provides functionality for resolving the taxonomy comparison operator from an expression.

GetWpQueryRelationOperatorCapableTrait

👁️ Get Relation Operator

Provides functionality for resolving the relation operator ("AND" or "OR") from an expression.

If all of the above traits are brought together, the implementing class is only required to implement the following:

  • _buildWpQueryMetaRelation() - recommended to redirect to buildWpQueryRelation with a "meta" mode.
  • _buildWpQueryTaxRelation() - recommended to redirect to buildWpQueryRelation with a "tax" mode.
  • _getWpQueryCompareKey() - recommended to search the expression for a VariableTermInterface or an EntityFieldInterface and retrieve the field.
  • _getWpQueryCompareValue() - recommended to search the expression for a LiteralTermInterface.
  • _getWpQueryMetaCompareKey() - recommended to search the expression for a VariableTermInterface or an EntityFieldInterface and retrieve the field.
  • _getWpQueryMetaCompareValue() - recommended to search the expression for a LiteralTermInterface.
  • _getWpQueryTaxCompareTaxonomy() - recommended to search the expression for an EntityFieldInterface and retrieve the entity.
  • _getWpQueryTaxCompareField() - recommended to search the expression for an EntityFieldInterface and retrieve the field.
  • _getWpQueryTaxCompareTerms() - recommended to search the expression for a LiteralTermInterface.