5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
21 public function all() {
36 gravityview()->log->error(
'Field_Collections can only contain objects of type \GV\Field.' );
52 public function get( $field_uid ) {
53 foreach ( $this->all() as
$field ) {
54 if (
$field->UID == $field_uid ) {
75 $search = implode(
'.*', array_map(
'preg_quote', explode(
'*', $position ) ) );
77 foreach ( $this->all() as
$field ) {
78 if ( preg_match(
"#^{$search}$#", $field->position ) ) {
79 $fields->add( $field );
99 foreach ( $this->all() as
$field ) {
100 if (
$field->is_visible( $view ) ) {
133 $fields =
new self();
134 foreach ( $configuration as $position => $_fields ) {
136 if ( empty( $_fields ) || ! is_array( $_fields ) ) {
140 foreach ( $_fields as $uid => $_configuration ) {
141 $field = Field::from_configuration( $_configuration );
143 $field->position = $position;
156 public function as_configuration() {
157 $configuration = array();
162 foreach ( $this->all() as
$field ) {
163 if ( empty( $configuration[ $field->position ] ) ) {
164 $configuration[ $field->position ] = array();
167 $configuration[ $field->position ][ $field->UID ] = $field->as_configuration();
169 return $configuration;
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
all()
Returns all the objects in this collection as an an array.
add( $field)
Add a to this collection.
by_position( $position)
Get a copy of this filtered by position.
by_visible( $view=null)
Get a copy of this filtered by visibility to current user context.
gravityview()
The main GravityView wrapper function.
static from_configuration( $configuration)
Parse a configuration array into a Field_Collection.