fewbricks\acf\layout::add_brick PHP Method

add_brick() public method

Dont add more than one brick to a layout
public add_brick ( brick $brick )
$brick fewbricks\bricks\brick
    public function add_brick($brick)
    {
        $brick->set_is_layout(true);
        $brick_fields = $brick->get_settings($this)['fields'];
        foreach ($brick_fields as $brick_field) {
            $this->settings['sub_fields'][] = $brick_field;
        }
        // Set name and label of layout to that of the brick
        $this->set_setting('name', $brick->get_setting('name'));
        if ($this->get_setting('label') === '') {
            $this->set_setting('label', $brick->get_setting('label'));
        }
    }

Usage Example

 /**
  *
  */
 public function set_fields()
 {
     $fc = new acf_fields\flexible_content('Modules', 'modules', '1509111554i');
     $l = new layout('', 'l1', '1509111555a');
     $l->add_brick(new demo_video('video', '1509111556x'));
     $fc->add_layout($l);
     $l = new layout('', 'l2', '1509111557u');
     $l->add_brick(new demo_button('button', '1509111556s'));
     $fc->add_layout($l);
     $this->add_flexible_content($fc);
 }
All Usage Examples Of fewbricks\acf\layout::add_brick