Ejemplo n.º 1
0
 /**
  * Tests the name of the rule
  */
 public function testName()
 {
     $dir = new Readable();
     $this->assertEquals($dir->getName(), 'rcf_container_readable');
 }
Ejemplo n.º 2
0
    /**
     * (non-PHPdoc)
     * 
     * @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['rcf_username']) || empty($params['rcf_api']) || empty($params['rcf_container'])) {
                return false;
            }
            $client = Rcf::getRemoteClient($params, true);
            if ($client instanceof \OpenCloud\ObjectStore\Resource\Container) {
                $filesystem = new Remote(new Rcf($client, $params['rcf_container']));
                $filesystem->getAdapter()->listContents();
                return true;
            }
        } catch (\Exception $e) {
            return false;
        }
    }
}
$rule = new Readable();
\JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());