fix: change namespaces
This commit is contained in:
parent
98b67855ca
commit
4d96cc4e8c
@ -15,7 +15,8 @@
|
||||
"php": ">=5.5",
|
||||
"sabre/dav": "~3.1.2",
|
||||
"sabre/vobject": "^4.0",
|
||||
"easycorp/easy-log-handler": "^1.0"
|
||||
"easycorp/easy-log-handler": "^1.0",
|
||||
"zendframework/zend-validator": "^2.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit" : "> 4.8, <=6.0.0"
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Aerex\TaskwarriorPlugin\Processors;
|
||||
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
||||
namespace Aerex\TaskwarriorPlugin;
|
||||
use Aerex\TaskwarriorPlugin\Taskwarrior\TaskwarriorManager;
|
||||
use Sabre\VObject\Component\VTodo;
|
||||
|
||||
/**
|
||||
* Class ToDo
|
||||
* Class CalendarProcessor
|
||||
*
|
||||
* @author Aerex
|
||||
*/
|
||||
@ -41,3 +41,4 @@ class CalendarProcessor
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Aerex\TaskwarriorPlugin\Configuration;
|
||||
namespace Aerex\TaskwarriorPlugin;
|
||||
|
||||
use DavidBadura\Taskwarrior\Taskwarrior;
|
||||
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
||||
use Aerex\TaskwarriorPlugin\Taskwarrior\Taskwarrior;
|
||||
use Aerex\TaskwarriorPlugin\Taskwarrior\TaskwarriorManager;
|
||||
|
||||
class Config {
|
||||
|
||||
|
@ -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())
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Aerex\TaskwarriorPlugin\Taskwarrior;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Aerex\TaskwarriorPlugin\Commands\IStrategy;
|
||||
use Aerex\TaskwarriorPlugin\Config;
|
||||
|
||||
class Taskwarrior {
|
||||
|
||||
@ -39,9 +40,9 @@ class Taskwarrior {
|
||||
* @var string
|
||||
*/
|
||||
|
||||
public function __construct(TaskwarriorConfig $config){
|
||||
public function __construct(Config $config){
|
||||
if(!isset($config)){
|
||||
$this->config = new TaskwarriorConfig();
|
||||
$this->config = new Configwg();
|
||||
}
|
||||
$this->config = $config;
|
||||
}
|
||||
@ -64,3 +65,4 @@ class Taskwarrior {
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?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 DavidBadura\Taskwarrior\TaskManager;
|
||||
use DavidBadura\Taskwarrior\Task;
|
||||
|
||||
class TaskwarriorManager {
|
||||
|
||||
@ -22,7 +21,11 @@ class TaskwarriorManager {
|
||||
const END = 'end';
|
||||
|
||||
public function __construct($taskwarrior){
|
||||
parent::__construct($taskwarrior);
|
||||
if(!isset($taskwarrior)){
|
||||
$this->taskwarrior = new Taskwarrior();
|
||||
} else {
|
||||
$this->taskwarrior = $taskwarrior;
|
||||
}
|
||||
}
|
||||
|
||||
public function createTask($UUID){
|
||||
@ -156,3 +159,4 @@ class TaskwarriorManager {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user