Commit 7a946a05 authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Properly DI the servercontainer

parent f076bfac
......@@ -568,7 +568,7 @@ class Server extends ServerContainer implements IServerContainer {
$config = $c->getConfig();
$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
/** @var \OC\Share20\IProviderFactory $factory */
$factory = new $factoryClass();
$factory = new $factoryClass($this);
$manager = new \OC\Share20\Manager(
$c->getLogger(),
......
......@@ -21,6 +21,7 @@
namespace OC\Share20;
use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer;
/**
* Interface IProviderFactory
......@@ -30,6 +31,12 @@ use OC\Share20\Exception\ProviderException;
*/
interface IProviderFactory {
/**
* IProviderFactory constructor.
* @param IServerContainer $serverContainer
*/
public function __construct(IServerContainer $serverContainer);
/**
* @param string $id
* @return IShareProvider
......
......@@ -21,6 +21,7 @@
namespace OC\Share20;
use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer;
/**
* Class ProviderFactory
......@@ -29,9 +30,19 @@ use OC\Share20\Exception\ProviderException;
*/
class ProviderFactory implements IProviderFactory {
/** @var IServerContainer */
private $serverContainer;
/** @var DefaultShareProvider */
private $defaultProvider = null;
/**
* IProviderFactory constructor.
* @param IServerContainer $serverContainer
*/
public function __construct(IServerContainer $serverContainer) {
$this->serverContainer = $serverContainer;
}
/**
* Create the default share provider.
*
......@@ -40,10 +51,10 @@ class ProviderFactory implements IProviderFactory {
protected function defaultShareProvider() {
if ($this->defaultProvider === null) {
$this->defaultProvider = new DefaultShareProvider(
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager(),
\OC::$server->getGroupManager(),
\OC::$server->getRootFolder()
$this->serverContainer->getDatabaseConnection(),
$this->serverContainer->getUserManager(),
$this->serverContainer->getGroupManager(),
$this->serverContainer->getRootFolder()
);
}
......
......@@ -86,7 +86,7 @@ class ManagerTest extends \Test\TestCase {
return vsprintf($text, $parameters);
}));
$this->factory = new DummyFactory();
$this->factory = new DummyFactory(\OC::$server);
$this->manager = new Manager(
$this->logger,
......@@ -1499,6 +1499,10 @@ class DummyFactory implements IProviderFactory {
/** @var IShareProvider */
private $provider;
public function __construct(\OCP\IServerContainer $serverContainer) {
}
/**
* @param IShareProvider $provider
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment