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
    // 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.

  • The setName method sets the value of the $name property.

getLabel() and setLabel()

<?php
    protected function getLabel(){
        return $this->label;
    }
    protected function setLabel($value){
        $this->label = $value;
    }
  • The getLabel method returns the value of the $label property.

  • The setLabel method sets the value of the $label property.

setProps() and getProps()

  • The setProps method sets the properties for the block by merging the provided $props array with the current $props array.

  • The getProps method returns the properties of the block.

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

Find out how to use Block

circle-check

Last updated

Was this helpful?