some improvements
This commit is contained in:
parent
a26758dc67
commit
7019d21a71
@ -33,6 +33,11 @@ class TaskManager
|
|||||||
*/
|
*/
|
||||||
private $tasks = [];
|
private $tasks = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Serializer
|
||||||
|
*/
|
||||||
|
private $serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Taskwarrior $taskwarrior
|
* @param Taskwarrior $taskwarrior
|
||||||
*/
|
*/
|
||||||
@ -400,12 +405,16 @@ class TaskManager
|
|||||||
*/
|
*/
|
||||||
private function getSerializer()
|
private function getSerializer()
|
||||||
{
|
{
|
||||||
|
if ($this->serializer) {
|
||||||
|
return $this->serializer;
|
||||||
|
}
|
||||||
|
|
||||||
$propertyNamingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
|
$propertyNamingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
|
||||||
|
|
||||||
$visitor = new JsonSerializationVisitor($propertyNamingStrategy);
|
$visitor = new JsonSerializationVisitor($propertyNamingStrategy);
|
||||||
$visitor->setOptions(JSON_UNESCAPED_UNICODE);
|
$visitor->setOptions(JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
return SerializerBuilder::create()
|
return $this->serializer = SerializerBuilder::create()
|
||||||
->setPropertyNamingStrategy($propertyNamingStrategy)
|
->setPropertyNamingStrategy($propertyNamingStrategy)
|
||||||
->configureHandlers(function (HandlerRegistryInterface $registry) {
|
->configureHandlers(function (HandlerRegistryInterface $registry) {
|
||||||
$registry->registerSubscribingHandler(new CarbonHandler());
|
$registry->registerSubscribingHandler(new CarbonHandler());
|
||||||
|
@ -38,6 +38,7 @@ class Taskwarrior
|
|||||||
* @param string $taskData
|
* @param string $taskData
|
||||||
* @param array $rcOptions
|
* @param array $rcOptions
|
||||||
* @param string $bin
|
* @param string $bin
|
||||||
|
* @throws TaskwarriorException
|
||||||
*/
|
*/
|
||||||
public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task')
|
public function __construct($taskrc = '~/.taskrc', $taskData = '~/.task', $rcOptions = [], $bin = 'task')
|
||||||
{
|
{
|
||||||
@ -51,6 +52,10 @@ class Taskwarrior
|
|||||||
),
|
),
|
||||||
$rcOptions
|
$rcOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (version_compare($this->version(), '2.4.3') < 0) {
|
||||||
|
throw new TaskwarriorException(sprintf("Taskwarrior version %s isn't supported", $this->version()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user