fix: change namespaces

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

View File

@ -15,7 +15,8 @@
"php": ">=5.5", "php": ">=5.5",
"sabre/dav": "~3.1.2", "sabre/dav": "~3.1.2",
"sabre/vobject": "^4.0", "sabre/vobject": "^4.0",
"easycorp/easy-log-handler": "^1.0" "easycorp/easy-log-handler": "^1.0",
"zendframework/zend-validator": "^2.10"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit" : "> 4.8, <=6.0.0" "phpunit/phpunit" : "> 4.8, <=6.0.0"

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Aerex\TaskwarriorPlugin\Processors; namespace Aerex\TaskwarriorPlugin;
use Aerex\TaskwarriorPlugin\TaskwarriorManager; use Aerex\TaskwarriorPlugin\Taskwarrior\TaskwarriorManager;
use Sabre\VObject\Component\VTodo; use Sabre\VObject\Component\VTodo;
/** /**
* Class ToDo * Class CalendarProcessor
* *
* @author Aerex * @author Aerex
*/ */
@ -41,3 +41,4 @@ class CalendarProcessor
?> ?>

View File

@ -1,9 +1,9 @@
<?php <?php
namespace Aerex\TaskwarriorPlugin\Configuration; namespace Aerex\TaskwarriorPlugin;
use DavidBadura\Taskwarrior\Taskwarrior; use Aerex\TaskwarriorPlugin\Taskwarrior\Taskwarrior;
use Aerex\TaskwarriorPlugin\TaskwarriorManager; use Aerex\TaskwarriorPlugin\Taskwarrior\TaskwarriorManager;
class Config { class Config {

View File

@ -3,13 +3,15 @@
namespace Aerex\TaskwarriorPlugin; namespace Aerex\TaskwarriorPlugin;
use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\Exception\BadRequest;
use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Document;
use Sabre\HTTP\RequestInterface; use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface; use Sabre\HTTP\ResponseInterface;
use Sabre\Xml\ParseException; use Sabre\Xml\ParseException;
use Sabre\DAV\ServerPlugin; use Sabre\DAV\ServerPlugin;
use Sabre\DAV\Server; use Sabre\DAV\Server;
use Aerex\TaskwarriorPlugin\CalendarProcessor; use Aerex\TaskwarriorPlugin\CalendarProcessor;
use Aerex\TaskwarriorPlugin\Taskwarrior\Taskwarrior;
use Aerex\TaskwarriorPlugin\Taskwarrior\TaskwarriorManager;
use Aerex\TaskwarriorPlugin\Config; use Aerex\TaskwarriorPlugin\Config;
/** /**
@ -26,30 +28,24 @@ class Plugin extends ServerPlugin {
protected $server; protected $server;
/**
* Reference to TaskwarriorConfig object
* @var TaskwarriorConfig
*
*/
protected $twConfig;
/** /**
* Reference to TaskwarriorCalenderEvent object * Reference to TaskwarriorCalenderEvent object
* @var TaskwarriorCalendarEvent * @var TaskwarriorManager
*/ */
protected $TWCalManager; protected $TWCalManager;
/** /**
* Creates the Taskwarrior plugin * Creates the Taskwarrior plugin
* *
* @param TaskwarriorConfig $TWCalManager * @param CalendarProcessor $TWCalManager
* *
*/ */
function __construct(iCalEventProcessor $TWCalManager = null){ function __construct(Taskwarrior $taskwarrior = null){
if(!is_null($TWCalManager)){ if(!is_null($taskwarrior)){
$this->twCalManager = $TWCalManager; $this->twCalManager = new CalendarProcessor(new TaskwarriorManager($taskwarrior));
} else { } 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, 'propPatchProtectedPropertyCheck'], 90);
$server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200);
$server->on('propFind', [$this, 'propFind']); $server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
$server->on('propFind', [$this, 'propFindNode'], 120); //$server->on('propFind', [$this, 'propFind']);
$server->on('propFind', [$this, 'propFindLate'], 200); //$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 * @param VCalendar $vCal parsed calendar object
*/ */
function processCalendarEventForTaskwarrior(VCalendar $vCal){ function processCalendarEventForTaskwarrior(Document $vCal){
try { try {
$this->twCalManager->importTask($vCal->VTODO); $this->twCalManager->importTask($vCal->VTODO);
} catch(BadRequest $e){ } catch(BadRequest $e){
@ -123,9 +120,6 @@ class Plugin extends ServerPlugin {
* */ * */
function calendarObjectChange(RequestInterface $request, ResponseInterface $response, Document $vCal, $calendarPath, &$modified, $isNew) { function calendarObjectChange(RequestInterface $request, ResponseInterface $response, Document $vCal, $calendarPath, &$modified, $isNew) {
$calendarNode = $this->server->tree->getNodeForPath($calendarPath); $calendarNode = $this->server->tree->getNodeForPath($calendarPath);
$addresses = $this->getAddressesForPrincipal(
$calendarNode->getOwner()
);
if ($isNew) { if ($isNew) {
try { try {
$this->processCalendarEventForTaskwarrior($vCal); $this->processCalendarEventForTaskwarrior($vCal);
@ -747,48 +741,6 @@ class Plugin extends ServerPlugin {
*/ */
function propFind(PropFind $propFind, INode $node) { 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())
);
});
} }

View File

@ -3,6 +3,7 @@
namespace Aerex\TaskwarriorPlugin\Taskwarrior; namespace Aerex\TaskwarriorPlugin\Taskwarrior;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Aerex\TaskwarriorPlugin\Commands\IStrategy; use Aerex\TaskwarriorPlugin\Commands\IStrategy;
use Aerex\TaskwarriorPlugin\Config;
class Taskwarrior { class Taskwarrior {
@ -39,9 +40,9 @@ class Taskwarrior {
* @var string * @var string
*/ */
public function __construct(TaskwarriorConfig $config){ public function __construct(Config $config){
if(!isset($config)){ if(!isset($config)){
$this->config = new TaskwarriorConfig(); $this->config = new Configwg();
} }
$this->config = $config; $this->config = $config;
} }
@ -64,3 +65,4 @@ class Taskwarrior {
?> ?>

View File

@ -1,11 +1,10 @@
<?php <?php
namespace Aerex\TaskwarriorPlugin; namespace Aerex\TaskwarriorPlugin\Taskwarrior;
use Aerex\TaskwarriorPlugin\Taskwarrior; use Aerex\TaskwarriorPlugin\Taskwarrior\Taskwarrior;
use Aerex\TaskwarriorPlugin\Taskwarrior\Task;
use Sabre\VObject\Component\VTodo; use Sabre\VObject\Component\VTodo;
use DavidBadura\Taskwarrior\TaskManager;
use DavidBadura\Taskwarrior\Task;
class TaskwarriorManager { class TaskwarriorManager {
@ -22,7 +21,11 @@ class TaskwarriorManager {
const END = 'end'; const END = 'end';
public function __construct($taskwarrior){ public function __construct($taskwarrior){
parent::__construct($taskwarrior); if(!isset($taskwarrior)){
$this->taskwarrior = new Taskwarrior();
} else {
$this->taskwarrior = $taskwarrior;
}
} }
public function createTask($UUID){ public function createTask($UUID){
@ -156,3 +159,4 @@ class TaskwarriorManager {
} }
?> ?>