<?php
/**
* iF.SVNAdmin
* Copyright (c) 2010 by Manuel Freiholz
* http://www.insanefactory.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
*/
namespace svnadmin\providers
{
class RepositoryEditProvider implements \svnadmin\core\interfaces\IRepositoryEditProvider
{
// Public members.
// The directory where all the repositories takes place.
public $svnParentPath = NULL;
// Private members.
private $m_svnadmin = NULL;
private $m_init_done = false;
private static $m_instance = NULL;
/**
* Gets the singelton instance of this object.
*
* @return \svnadmin\providers\RepositoryEditProvider
*/
public static function getInstance()
{
if( self::$m_instance == NULL )
{
self::$m_instance = new RepositoryEditProvider();
}
return self::$m_instance;
}
////////////////////////////////////////////////////////////////////////////
// IInit implementations
////////////////////////////////////////////////////////////////////////////
public function init()
{
if( !$this->m_init_done )
{
global $appEngine;
$this->svnParentPath = $appEngine->getConfig()->getValue("Repositories:svnclient", "SVNParentPath");
$this->m_init_done = true;
$this->m_svnadmin = new \IF_SVNAdminC();
if (!$this->m_svnadmin->init($appEngine->getConfig()->getValue("Repositories:svnclient", "SvnAdminExecutable")))
{
return false;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////
// IEditProvider
////////////////////////////////////////////////////////////////////////////
public function save()
{ // Nothing to do here...
return true;
}
////////////////////////////////////////////////////////////////////////////
// IRepositoryEditProvider
////////////////////////////////////////////////////////////////////////////
public function create( $oRepository, $type = "fsfs" )
{
if (!file_exists($this->svnParentPath))
throw new \Exception("The repository parent path doesn't exists: " . $this->svnParentPath);
// Create absolute path.
$path = $this->svnParentPath."/".$oRepository->name;
return $this->m_svnadmin->create( $path, $type );
}
public function delete( $oRepository )
{
// Create absolute path.
$path = $this->svnParentPath."/".$oRepository->name;
return $this->m_svnadmin->delete( $path );
return false;
}
} // class end
} // namespace end
?>