public function create($name, $source) { if (!preg_match('/^[A-z0-9\\-\\_]{3,64}$/', $name)) { throw new StatusCode\BadRequestException('Invalid schema name'); } // check whether schema exists $condition = new Condition(); $condition->equals('name', $name); $connection = $this->schemaTable->getOneBy($condition); if (!empty($connection)) { throw new StatusCode\BadRequestException('Connection already exists'); } // create schema $this->schemaTable->create(array('status' => Table\Schema::STATUS_ACTIVE, 'name' => $name, 'source' => $source, 'cache' => $this->schemaParser->parse(json_encode($source)))); }