3ev Core Wordpress library API
  • Namespace
  • Class

Namespaces

  • Tev
    • Application
      • Bootstrap
    • Author
      • Model
    • Contracts
    • Database
      • CustomTables
    • Field
      • Model
      • Util
    • Plugin
      • Action
      • Shortcode
    • Post
      • Model
      • Repository
    • Taxonomy
      • Model
      • Repository
    • Term
      • Model
      • Repository
    • Util
    • View
      • Exception
  • None

Classes

  • Factory

Class Factory

Post entity factory.

Allows for easy instantiation of post entity objects. Classes can be instantiated based on their post type. 'post' and 'page' are registered by default.

Namespace: Tev\Post
Located at Tev/Post/Factory.php

Methods summary

public
# __construct( Tev\Author\Factory $authorFactory, Tev\Taxonomy\Factory $taxonomyFactory, Tev\Field\Factory $fieldFactory )

Constructor.

Constructor.

Inject dependencies.

Parameters

$authorFactory
Author object factory
$taxonomyFactory
Taxonomy entity factory
$fieldFactory
Field entity factory
public Tev\Post\Factory
# register( string $postType, string $className )

Register a new post type to class name mapping.

Register a new post type to class name mapping.

Parameters

$postType
Post type identifier
$className

Class name to instantiate for $postType. Class must inherit from \Tev\Post\Model\AbstractPost

Returns

Tev\Post\Factory
This, for chaining

Throws

Exception
If class name does not inherit from \Tev\Post\Model\AbstractPost
public string|null
# registered( string $postType )

Get the registered class name for the given post type.

Get the registered class name for the given post type.

Parameters

$postType
Post type identifier

Returns

string|null
Class name or null if no registration
public Tev\Post\Model\AbstractPost
# create( WP_Post $base = null, string $className = null )

Instantiate a post entity from a given post object.

Instantiate a post entity from a given post object.

Parameters

$base

Optional. Base post object. If not supplied will attempt to get the current post from The Loop

$className

Optional. Class name to instantiate. Will use registered default if not supplied

Returns

Tev\Post\Model\AbstractPost
Post entity

Throws

Exception
If $base is not given and not in the The Loop
public Tev\Post\Model\AbstractPost
# current( string $className = null )

Instantiate a post entity from the current post object.

Instantiate a post entity from the current post object.

Only works within The Loop.

Parameters

$className

Optional. Class name to instantiate. Will use registered default if not supplied

Returns

Tev\Post\Model\AbstractPost
Post entity

Throws

Exception
If not in the The Loop
3ev Core Wordpress library API API documentation generated by ApiGen