Vilma_MailboxDriver::factory PHP 메소드

factory() 공개 정적인 메소드

Creates a new mailbox driver instance.
public static factory ( string $driver = null, array $params = null ) : Vilma_MailboxDriver
$driver string The name of the driver to create an instance of.
$params array Driver-specific parameters.
리턴 Vilma_MailboxDriver The new driver instance.
    public static function factory($driver = null, $params = null)
    {
        if (is_null($driver)) {
            $driver = $GLOBALS['conf']['mailboxes']['driver'];
        }
        $driver = Horde_String::ucfirst(basename($driver));
        if (is_null($params)) {
            $params = $GLOBALS['conf']['mailboxes']['params'];
        }
        $class = 'Vilma_MailboxDriver_' . $driver;
        if (class_exists($class)) {
            return new $class($params);
        }
        throw new Vilma_Exception(sprintf('No such mailbox driver "%s" found', $driver));
    }

Usage Example

예제 #1
0
파일: Sql.php 프로젝트: horde/horde
 /**
  * Deletes a user.
  *
  * @param integer $user_id  The id of the user to delete.
  *
  * @throws Vilma_Exception
  */
 public function deleteUser($user_id)
 {
     $user = $this->getUser($user_id);
     try {
         $this->_db->beginDbTransaction();
         /* Delete all virtual emails for this user. */
         $sql = 'DELETE FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_destination') . ' = ?';
         $values = array($user['user_name']);
         $this->_db->delete($sql, $values);
         /* Delete the actual user. */
         $sql = 'DELETE FROM ' . $this->_params['tables']['users'] . ' WHERE ' . $this->_getTableField('users', 'user_id') . ' = ?';
         $values = array((int) $user_id);
         $this->_db->delete($sql, $values);
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         throw new Vilma_Exception($e);
     }
     Vilma_MailboxDriver::factory()->deleteMailbox(Vilma::stripUser($user['user_name']), Vilma::stripDomain($user['user_name']));
 }
All Usage Examples Of Vilma_MailboxDriver::factory