fix: change namespaces

This commit is contained in:
2018-11-25 18:41:20 -06:00
parent 98b67855ca
commit 4d96cc4e8c
6 changed files with 36 additions and 76 deletions

View File

@@ -3,13 +3,15 @@
namespace Aerex\TaskwarriorPlugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Document;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use Sabre\Xml\ParseException;
use Sabre\DAV\ServerPlugin;
use Sabre\DAV\Server;
use Aerex\TaskwarriorPlugin\CalendarProcessor;
use Aerex\TaskwarriorPlugin\Taskwarrior\Taskwarrior;
use Aerex\TaskwarriorPlugin\Taskwarrior\TaskwarriorManager;
use Aerex\TaskwarriorPlugin\Config;
/**
@@ -26,30 +28,24 @@ class Plugin extends ServerPlugin {
protected $server;
/**
* Reference to TaskwarriorConfig object
* @var TaskwarriorConfig
*
*/
protected $twConfig;
/**
* Reference to TaskwarriorCalenderEvent object
* @var TaskwarriorCalendarEvent
* @var TaskwarriorManager
*/
protected $TWCalManager;
/**
* Creates the Taskwarrior plugin
*
* @param TaskwarriorConfig $TWCalManager
* @param CalendarProcessor $TWCalManager
*
*/
function __construct(iCalEventProcessor $TWCalManager = null){
if(!is_null($TWCalManager)){
$this->twCalManager = $TWCalManager;
function __construct(Taskwarrior $taskwarrior = null){
if(!is_null($taskwarrior)){
$this->twCalManager = new CalendarProcessor(new TaskwarriorManager($taskwarrior));
} else {
$this->twCalManager = new CalendarProcessor();
$this->twCalManager = new CalendarProcessor(new TaskwarriorManager());
}
}
@@ -75,9 +71,10 @@ class Plugin extends ServerPlugin {
$server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90);
$server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200);
$server->on('propFind', [$this, 'propFind']);
$server->on('propFind', [$this, 'propFindNode'], 120);
$server->on('propFind', [$this, 'propFindLate'], 200);
$server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
//$server->on('propFind', [$this, 'propFind']);
//$server->on('propFind', [$this, 'propFindNode'], 120);
//$server->on('propFind', [$this, 'propFindLate'], 200);
}
@@ -100,7 +97,7 @@ class Plugin extends ServerPlugin {
*
* @param VCalendar $vCal parsed calendar object
*/
function processCalendarEventForTaskwarrior(VCalendar $vCal){
function processCalendarEventForTaskwarrior(Document $vCal){
try {
$this->twCalManager->importTask($vCal->VTODO);
} catch(BadRequest $e){
@@ -123,9 +120,6 @@ class Plugin extends ServerPlugin {
* */
function calendarObjectChange(RequestInterface $request, ResponseInterface $response, Document $vCal, $calendarPath, &$modified, $isNew) {
$calendarNode = $this->server->tree->getNodeForPath($calendarPath);
$addresses = $this->getAddressesForPrincipal(
$calendarNode->getOwner()
);
if ($isNew) {
try {
$this->processCalendarEventForTaskwarrior($vCal);
@@ -747,48 +741,6 @@ class Plugin extends ServerPlugin {
*/
function propFind(PropFind $propFind, INode $node) {
$propFind->handle('{DAV:}getlastmodified', function() use ($node) {
$lm = $node->getLastModified();
if ($lm) {
return new Xml\Property\GetLastModified($lm);
}
});
if ($node instanceof IFile) {
$propFind->handle('{DAV:}getcontentlength', [$node, 'getSize']);
$propFind->handle('{DAV:}getetag', [$node, 'getETag']);
$propFind->handle('{DAV:}getcontenttype', [$node, 'getContentType']);
}
if ($node instanceof IQuota) {
$quotaInfo = null;
$propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) {
$quotaInfo = $node->getQuotaInfo();
return $quotaInfo[0];
});
$propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) {
if (!$quotaInfo) {
$quotaInfo = $node->getQuotaInfo();
}
return $quotaInfo[1];
});
}
$propFind->handle('{DAV:}supported-report-set', function() use ($propFind) {
$reports = [];
foreach ($this->server->getPlugins() as $plugin) {
$reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath()));
}
return new Xml\Property\SupportedReportSet($reports);
});
$propFind->handle('{DAV:}resourcetype', function() use ($node) {
return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node));
});
$propFind->handle('{DAV:}supported-method-set', function() use ($propFind) {
return new Xml\Property\SupportedMethodSet(
$this->server->getAllowedMethods($propFind->getPath())
);
});
}