コード例 #1
0
 /**
  * Generates a configuration file.
  *
  * @param string $dbConn
  * @param string $email
  *
  * @return bool|string
  */
 public function process($dbConn, $email)
 {
     // extract database
     $dbName = $this->dbNameExctractor->filter($dbConn);
     $config = array('doctrine' => array('connection' => array('odm_default' => array('connectionString' => $dbConn)), 'configuration' => array('odm_default' => array('default_db' => $dbName))), 'core_options' => array('system_message_email' => $email));
     $content = $this->generateConfigContent($config);
     $ok = $this->writeConfigFile($content);
     return $ok ? true : $content;
 }
コード例 #2
0
ファイル: UserCreator.php プロジェクト: webpants/YAWIK
 /**
  * Inserts a minimalistic user document into the database.
  *
  * @param string $dbConn Database connection string
  * @param string $username Login name
  * @param string $password Credential
  * @param string $email Email
  *
  * @return bool
  *
  * @codeCoverageIgnore Untestable due to missing test database
  */
 public function process($dbConn, $username, $password, $email)
 {
     $m = @new \MongoClient($dbConn);
     $dbName = $this->databaseNameExtractor->filter($dbConn);
     $credential = $this->credentialFilter->filter($password);
     $db = $m->selectDB($dbName);
     $collection = $db->selectCollection('users');
     $document = array('isDraft' => false, 'role' => 'admin', 'login' => $username, 'credential' => $credential, 'info' => ['email' => $email]);
     $result = $collection->insert($document);
     return isset($result['ok']) && 1 === $result['ok'];
 }
コード例 #3
0
 public function testReturnsDefaultDbNameUponExtractionIfNoDbNameIsSpecified()
 {
     $target = new DbNameExtractor();
     $actual = $target->filter('mongodb://server');
     $this->assertEquals('YAWIK', $actual);
 }