GlobalParam.php

<?php

namespace Lia\Compo;

class GlobalParam extends \Lia\Compo {

    protected $globalArgs = [];

    public function onReady(){
        $lia = $this->lia;
        $lia->addApi('lia:globalparams.put',[$this,'addParamater']);
        $lia->addApiMethod('lia:globalparams.put', 'addGlobalParamater');

        $lia->addApi('lia:globalparams.getAll',[$this,'getParamaters']);
        $lia->addApiMethod('lia:globalparams.getAll', 'getGlobalParamaters');
    }
    
    /**
     * Add Paramaters to be exposed globally, to all views & public files
     *
     */
    public function addParamater($name, $value){
        //@TODO Consider conflict resolution instead of pure overwriting
        $this->globalArgs[$name] = $value;
    }
    
    /**
     * Get array of global paramaters
     */
    public function getParamaters(){
        return $this->globalArgs;
    }
}