public function setRight($right) { $tmp = null; if (Tools::isIntegerValid($right)) { $tmp = Right::findById($right); } else { if (Tools::isStringValid($right)) { $tmp = Right::findByName($right); } else { throw new Exception("Invalid right"); } } if ($tmp == null) { throw new Exception("Unknow right"); } $this->right = $tmp; // Retourne l'objet pour le chainage. return $this; }