| 1 |
<?php |
| 2 |
|
| 3 |
namespace Carbon_Fields; |
| 4 |
|
| 5 |
/** |
| 6 |
* Field proxy factory class. |
| 7 |
* Used for shorter namespace access when creating a field. |
| 8 |
* |
| 9 |
* @method static \Carbon_Fields\Field\Association_Field make_association( string $name, string $label = null ) |
| 10 |
* @method static \Carbon_Fields\Field\Checkbox_Field make_checkbox( string $name, string $label = null ) |
| 11 |
* @method static \Carbon_Fields\Field\Color_Field make_color( string $name, string $label = null ) |
| 12 |
* @method static \Carbon_Fields\Field\Complex_Field make_complex( string $name, string $label = null ) |
| 13 |
* @method static \Carbon_Fields\Field\Date_Field make_date( string $name, string $label = null ) |
| 14 |
* @method static \Carbon_Fields\Field\Date_Time_Field make_date_time( string $name, string $label = null ) |
| 15 |
* @method static \Carbon_Fields\Field\File_Field make_file( string $name, string $label = null ) |
| 16 |
* @method static \Carbon_Fields\Field\Footer_Scripts_Field make_footer_scripts( string $name, string $label = null ) |
| 17 |
* @method static \Carbon_Fields\Field\Gravity_Form_Field make_gravity_form( string $name, string $label = null ) |
| 18 |
* @method static \Carbon_Fields\Field\Header_Scripts_Field make_header_scripts( string $name, string $label = null ) |
| 19 |
* @method static \Carbon_Fields\Field\Hidden_Field make_hidden( string $name, string $label = null ) |
| 20 |
* @method static \Carbon_Fields\Field\Html_Field make_html( string $name, string $label = null ) |
| 21 |
* @method static \Carbon_Fields\Field\Image_Field make_image( string $name, string $label = null ) |
| 22 |
* @method static \Carbon_Fields\Field\Map_Field make_map( string $name, string $label = null ) |
| 23 |
* @method static \Carbon_Fields\Field\Media_Gallery_Field make_media_gallery( string $name, string $label = null ) |
| 24 |
* @method static \Carbon_Fields\Field\Multiselect_Field make_multiselect( string $name, string $label = null ) |
| 25 |
* @method static \Carbon_Fields\Field\OEmbed_Field make_oembed( string $name, string $label = null ) |
| 26 |
* @method static \Carbon_Fields\Field\Radio_Field make_radio( string $name, string $label = null ) |
| 27 |
* @method static \Carbon_Fields\Field\Radio_Image_Field make_radio_image( string $name, string $label = null ) |
| 28 |
* @method static \Carbon_Fields\Field\Rich_Text_Field make_rich_text( string $name, string $label = null ) |
| 29 |
* @method static \Carbon_Fields\Field\Select_Field make_select( string $name, string $label = null ) |
| 30 |
* @method static \Carbon_Fields\Field\Separator_Field make_separator( string $name, string $label = null ) |
| 31 |
* @method static \Carbon_Fields\Field\Set_Field make_set( string $name, string $label = null ) |
| 32 |
* @method static \Carbon_Fields\Field\Sidebar_Field make_sidebar( string $name, string $label = null ) |
| 33 |
* @method static \Carbon_Fields\Field\Text_Field make_text( string $name, string $label = null ) |
| 34 |
* @method static \Carbon_Fields\Field\Textarea_Field make_textarea( string $name, string $label = null ) |
| 35 |
* @method static \Carbon_Fields\Field\Time_Field make_time( string $name, string $label = null ) |
| 36 |
* @method static \Carbon_Fields\Field\Block_Preview_Field make_html( string $name, string $label = null ) |
| 37 |
*/ |
| 38 |
class Field { |
| 39 |
|
| 40 |
/** |
| 41 |
* A proxy for the abstract field factory method. |
| 42 |
* |
| 43 |
* @see \Carbon_Fields\Field\Field::factory() |
| 44 |
* @return \Carbon_Fields\Field\Field |
| 45 |
*/ |
| 46 |
public static function factory() { |
| 47 |
return call_user_func_array( array( '\Carbon_Fields\Field\Field', 'factory' ), func_get_args() ); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* An alias of factory(). |
| 52 |
* |
| 53 |
* @see \Carbon_Fields\Field\Field::factory() |
| 54 |
* @return \Carbon_Fields\Field\Field |
| 55 |
*/ |
| 56 |
public static function make() { |
| 57 |
return call_user_func_array( array( get_class(), 'factory' ), func_get_args() ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* @param string $method |
| 62 |
* @param array $arguments |
| 63 |
* |
| 64 |
* @return mixed |
| 65 |
*/ |
| 66 |
public static function __callStatic( $method, $arguments ) { |
| 67 |
if ( strpos( $method, 'make_' ) === 0 ) { |
| 68 |
$raw_type = substr_replace( $method, '', 0, 5 ); |
| 69 |
array_unshift( $arguments, $raw_type ); |
| 70 |
return call_user_func_array( array( get_class(), 'factory' ), $arguments ); |
| 71 |
} else { |
| 72 |
trigger_error( sprintf( 'Call to undefined function: %s::%s().', get_class(), $method ), E_USER_ERROR ); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|