fewbricks\bricks\brick::get_settings PHP Method

get_settings() public method

Get settings of a field.
public get_settings ( fewbricks\acf\field-group | layout | repeater | flexible_content | brick $object_to_get_for ) : array
$object_to_get_for fewbricks\acf\field-group | fewbricks\acf\layout | fewbricks\acf\fields\repeater | fewbricks\acf\fields\flexible_content | brick
return array
    public function get_settings($object_to_get_for)
    {
        $this->prepare_settings($object_to_get_for);
        /** @noinspection PhpUndefinedMethodInspection */
        $this->set_fields();
        /** @noinspection PhpUndefinedMethodInspection */
        $this->set_project_fields();
        $this->remove_fields();
        if (is_a($object_to_get_for, 'fewbricks\\acf\\layout')) {
            $this->set_is_layout(true);
            // We need a hidden field to tell us what class we are dealing with when looping layouts in the frontend.
            $this->add_field((new acf\fields\fewbricks_hidden('Brick class', 'brick_class', '7001010000a'))->set_setting('default_value', \fewbricks\helpers\get_real_class_name($this)));
        } elseif (is_a($object_to_get_for, 'fewbricks\\acf\\fields\\repeater')) {
            $this->set_is_sub_field(true);
        }
        return ['name' => $this->name, 'key' => $this->key, 'is_layout' => $this->is_layout, 'is_sub_field' => $this->is_sub_field, 'is_option' => $this->is_option, 'fields' => $this->fields, 'field_label_prefix' => $this->field_label_prefix, 'field_label_suffix' => $this->field_label_suffix];
    }

Usage Example

Esempio n. 1
0
 /**
  * @param \fewbricks\bricks\brick $brick
  * @return $this
  */
 public function add_brick($brick)
 {
     $brick->set_is_sub_field(true);
     $brick_settings = $brick->get_settings($this);
     foreach ($brick_settings['fields'] as $brick_field) {
         $this->settings['sub_fields'][] = $brick_field;
     }
     return $this;
 }
All Usage Examples Of fewbricks\bricks\brick::get_settings