Contao\Module::__construct PHP Method

__construct() public method

Initialize the object
public __construct ( ModuleModel $objModule, string $strColumn = 'main' )
$objModule ModuleModel
$strColumn string
    public function __construct($objModule, $strColumn = 'main')
    {
        if ($objModule instanceof Model || $objModule instanceof Model\Collection) {
            /** @var ModuleModel $objModel */
            $objModel = $objModule;
            if ($objModel instanceof Model\Collection) {
                $objModel = $objModel->current();
            }
            $this->objModel = $objModel;
        }
        parent::__construct();
        $this->arrData = $objModule->row();
        $this->cssID = \StringUtil::deserialize($objModule->cssID, true);
        if ($this->customTpl != '' && TL_MODE == 'FE') {
            $this->strTemplate = $this->customTpl;
        }
        $arrHeadline = \StringUtil::deserialize($objModule->headline);
        $this->headline = is_array($arrHeadline) ? $arrHeadline['value'] : $arrHeadline;
        $this->hl = is_array($arrHeadline) ? $arrHeadline['unit'] : 'h1';
        $this->strColumn = $strColumn;
    }

Usage Example

 public function __construct($objModule, $strColumn)
 {
     parent::__construct($objModule, $strColumn);
     foreach ($this->getSerializedProperties() as $k => $name) {
         $force = true;
         if (is_bool($name)) {
             $force = $name;
             $name = $k;
         }
         if (array_key_exists($name, $this->arrData)) {
             $this->arrData[$name] = deserialize($this->arrData[$name], $force);
         }
     }
 }