コード例 #1
0
 /**
  * Create MySQL databases, users and grant permissions.
  */
 public function createDatabases()
 {
     /** @var $dbs MysqlDatabase[] */
     $dbs = $this->_getRepository()->findAll();
     foreach ($dbs as $db) {
         $userModel = new MysqlUserModel();
         $userModel->setUsername($db->getName())->setPassword($this->_cryptservice->decrypt($db->getPassword()));
         $dbModel = new MysqlDatabaseModel();
         $dbModel->setName($db->getName())->setUsers(array($userModel));
         if ($this->_mysqladmin->checkUserExists($userModel)) {
             $this->_mysqladmin->setUserPassword($userModel);
         } else {
             $this->_mysqladmin->createUser($userModel);
         }
         if (!$this->_mysqladmin->checkDatabaseExists($dbModel)) {
             $this->_mysqladmin->createDatabase($dbModel);
             $this->_mysqladmin->grantPermissionsOnDatabase($dbModel);
         }
     }
 }
コード例 #2
0
ファイル: CryptServiceTest.php プロジェクト: jeboehm/lampcp
 /**
  * Expect exception on invalid decrypted data.
  *
  * @expectedException \Jeboehm\Lampcp\CoreBundle\Exception\WrongEncryptionKeyException
  */
 public function testDecryptFailure()
 {
     $this->_cs->decrypt(rand(0, 9999));
 }