Ejemplo n.º 1
0
     * 
     * @var string
     */
    protected $error_message = 'Can\'t connect to {field}';
    /**
     * (non-PHPdoc)
     * 
     * @ignore
     *
     * @see \mithra62\Validate\RuleInterface::validate()
     */
    public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['gcs_access_key']) || empty($params['gcs_secret_key'])) {
                return false;
            }
            $client = m62Gcs::getRemoteClient($params['gcs_access_key'], $params['gcs_secret_key']);
            $client->listBuckets();
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
}
$rule = new Connect();
\JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());
Ejemplo n.º 2
0
 /**
  * Tests the name of the rule
  */
 public function testName()
 {
     $dir = new Connect();
     $this->assertEquals($dir->getName(), 'gcs_connect');
 }