# BaseBlock

The `BaseBlock.php` file in the `Core` directory of the PHPFast framework defines an abstract class `BaseBlock` to manage blocks in the application. Below is a detailed explanation of the methods in this file.

## `getName()` and `setName()`

```php
<?php
    // Returns the block name, e.g., "HeaderBlock"
    protected function getName(){
        return ucfirst($this->name);
    }
    protected function setName($value){
        $this->name = $value;
    }
```

* The `getName` method returns the block name with the first letter capitalized.&#x20;
* The `setName` method sets the value of the `$name` property.

## `getLabel()` and `setLabel()`

```php
<?php
    protected function getLabel(){
        return $this->label;
    }
    protected function setLabel($value){
        $this->label = $value;
    }
```

* The `getLabel` method returns the value of the `$label` property. &#x20;
* The `setLabel` method sets the value of the `$label` property.

## `setProps()` and `getProps()`

```php
<?php
    public function setProps(array $props) {
        $this->props = array_merge($this->props, $props);
        return $this;
    }
    protected function getProps() {
        return $this->props;
    }
```

* The `setProps` method sets the properties for the block by merging the provided `$props` array with the current `$props` array.&#x20;
* The `getProps` method returns the properties of the block.

## `handleData()`

```php
<?php
    // Handle data and return it in the format required by the layout file
    abstract public function handleData();
```

The abstract method `handleData` is responsible for processing data and returning it in the format required by the layout file. This method will be implemented in the subclasses that extend `BaseBlock`.

## Example

```php
<?php
namespace App\Blocks\Content;

use System\Core\BaseBlock;
use App\Models\UsersModel;

class ContentBlock extends BaseBlock {
    public function __construct() {
        $this->setLabel('Content Block');
        $this->setName('Content');
        $this->setProps([
            // layout name: layout_1.php
            'layout'            => 'layout_1',         // Required
            'other_properties'  => 'Other properties', // Other Properties 
        ]);
        
        $this->usersModel = new UsersModel();
    }
    
    public function handleData() {
        $props = $this->getProps();
        
        $users   = $this->usersModel->getUsers();  
        return [
            'props'    => $props,
            'users'    => $users,
        ];
    }
}
```

Find out how to use [Block](/documents/blocks.md)

{% hint style="success" %}
Summary

The `BaseBlock` class in the `BaseBlock.php` file defines the basic properties and methods to manage blocks in the application. The main methods include:

* **`getName` and `setName`**: Get and set the block's name.
* **`getLabel` and `setLabel`**: Get and set the block's label.
* **`setProps` and `getProps`**: Set and get the block's properties.
* **`handleData`**: An abstract method to process the block's data.
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cmsfullform.com/documents/core/baseblock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
