Baikal\Model\Calendar::set PHP Méthode

set() public méthode

public set ( $sPropName, $sValue )
    function set($sPropName, $sValue)
    {
        if ($sPropName === "todos") {
            if (($sComponents = $this->get("components")) !== "") {
                $aComponents = explode(",", $sComponents);
            } else {
                $aComponents = [];
            }
            if ($sValue === true) {
                if (!in_array("VTODO", $aComponents)) {
                    $aComponents[] = "VTODO";
                }
            } else {
                if (in_array("VTODO", $aComponents)) {
                    unset($aComponents[array_search("VTODO", $aComponents)]);
                }
            }
            return parent::set("components", implode(",", $aComponents));
        }
        if ($sPropName === "notes") {
            if (($sComponents = $this->get("components")) !== "") {
                $aComponents = explode(",", $sComponents);
            } else {
                $aComponents = [];
            }
            if ($sValue === true) {
                if (!in_array("VJOURNAL", $aComponents)) {
                    $aComponents[] = "VJOURNAL";
                }
            } else {
                if (in_array("VJOURNAL", $aComponents)) {
                    unset($aComponents[array_search("VJOURNAL", $aComponents)]);
                }
            }
            return parent::set("components", implode(",", $aComponents));
        }
        return parent::set($sPropName, $sValue);
    }