/** * Tests the name of the rule */ public function testName() { $dir = new Connect(); $this->assertEquals($dir->getName(), 'dropbox_connect'); }
* * @todo implement if (preg_match('@[\x00-\x1f\x7f]@', $s) === 1) matching on token * @see \mithra62\Validate\RuleInterface::validate() * @ignore * */ public function validate($field, $input, array $params = array()) { try { if ($input == '' || empty($params['0'])) { return false; } $params = $params['0']; if (empty($params['dropbox_access_token']) || empty($params['dropbox_app_secret'])) { return false; } $client = m62Dropbox::getRemoteClient($params['dropbox_access_token'], $params['dropbox_app_secret']); $adapter = new m62Dropbox($client); $filesystem = new Remote($adapter); if (!$filesystem->getAdapter()->listContents()) { return false; } return true; } catch (\Exception $e) { $this->setErrorMessage($e->getMessage()); return false; } } } $rule = new Connect(); \JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());