コード例 #1
0
ファイル: Variable.php プロジェクト: yzalis/crontab
 /**
  * Parse a variable line
  * 
  * @param string $varLine
  * @return Variable
  */
 public static function parse($varLine)
 {
     $parts = explode('=', $varLine, 2);
     if (!$parts || count($parts) !== 2) {
         throw new \InvalidArgumentException("Line does not appear to contain a variable");
     }
     $variable = new Variable();
     $variable->setName(trim(array_shift($parts)))->setValue(trim(array_shift($parts)));
     return $variable;
 }
コード例 #2
0
 public function setVariable()
 {
     try {
         if (fRequest::get('remove', 'boolean')) {
             $variable = new Variable(fRequest::get('name'));
             $variable->delete();
             fMessaging::create('success', 'Variable removed successfully.');
         } else {
             try {
                 $variable = new Variable(fRequest::get('name'));
             } catch (fNotFoundException $e) {
                 $variable = new Variable();
                 $variable->setName(fRequest::get('name'));
             }
             $variable->setValue(fRequest::get('value'));
             $variable->store();
             fMessaging::create('success', 'Variable set successfully.');
         }
     } catch (fException $e) {
         fMessaging::create('error', $e->getMessage());
     }
     fURL::redirect(Util::getReferer());
 }