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

Custom field factory.

Used for creating custom field entities.

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

Methods summary

public
# __construct( Tev\Application\Application $app )

Constructor.

Constructor.

Parameters

$app
Application instance
public Tev\Field\Factory
# register( string $type, string|Closure $factory )

Register a new factory function with the factory.

Register a new factory function with the factory.

Can either be field class name or factory callback function. If class name, the field data array will be passed to the constructor. If callback, the field data array will be passed as the first parameter and the application instance will be passed as the second.

For example:

// Class name

$factory->register('text', 'Tev\Field\Model\BasicField');

// Callback

$factory->register('text', function ($data, $app) { return new \Tev\Field\Model\BasicField($data); });

Parameters

$type
Field type string
$factory
Class name or factory function

Returns

Tev\Field\Factory
This, for chaining
public boolean
# registered( string $type )

Check if the given type is registered.

Check if the given type is registered.

Parameters

$type
Field type string

Returns

boolean
True if registered false if not
public Tev\Field\Model\AbstractField
# create( string $field, Tev\Post\Model\AbstractPost $post )

Create a new custom field object.

Create a new custom field object.

If the field is not registered, a \Tev\Field\Model\NullField will be returned.

Parameters

$field
Field name or ID
$post
Post object field is for

Returns

Tev\Field\Model\AbstractField
Field object

Throws

Exception
If field type is not registered
public Tev\Field\Model\AbstractField
# createFromField( array $field, mixed $value = null )

Create a new custom field object from an existing set of field data.

Create a new custom field object from an existing set of field data.

If the field is not registered, a \Tev\Field\Model\NullField will be returned.

Parameters

$field
Field data array
$value
If supplied, will be set as the fields value

Returns

Tev\Field\Model\AbstractField
Field object

Throws

Exception
If field type is not registered
public Tev\Field\Model\AbstractField
# createEmpty( string $field )

Creata new custom field object that's not in the context of a post and doesn't have a loaded value.

Creata new custom field object that's not in the context of a post and doesn't have a loaded value.

Parameters

$field
Field name or ID

Returns

Tev\Field\Model\AbstractField
Field object

Throws

Exception
If field type is not registered
protected Tev\Field\Model\AbstractField
# resolve( string $type, array $data )

Resolve a field object using its type, from the registered factory functions.

Resolve a field object using its type, from the registered factory functions.

Parameters

$type
Field type
$data
Field data

Returns

Tev\Field\Model\AbstractField
Field object

Throws

Exception
If field type is not registered
3ev Core Wordpress library API API documentation generated by ApiGen