fewbricks\bricks\brick::get_setting PHP Method

get_setting() public method

This function makes sure that we have means to get essential settings in the same way as for fields etc.
public get_setting ( string $name, string $default_value = '' ) : string
$name string
$default_value string
return string
    public function get_setting($name, $default_value = '')
    {
        $value = $this->{$name};
        if ($value === null) {
            $value = $default_value;
        }
        return $value;
    }

Usage Example

Example #1
0
 /**
  * Dont add more than one brick to a layout
  * @param \fewbricks\bricks\brick $brick
  * @return $this
  */
 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'));
     }
 }
All Usage Examples Of fewbricks\bricks\brick::get_setting