added annotation based exporter (#1831)

* added user exporter
* added project exporter
* added customer exporter
* added activity exporter
This commit is contained in:
Kevin Papst
2020-07-21 03:37:51 +02:00
committed by GitHub
parent 93a23f3fa3
commit aee063bb3c
79 changed files with 2980 additions and 215 deletions

View File

@@ -0,0 +1,76 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Spreadsheet\Entities;
use App\Export\Annotation as Exporter;
/**
* @Exporter\Order({"a-time", "publicProperty", "a-date", "something", "privateProperty"})
* @Exporter\Expose("accessor", label="label.accessor", exp="object.accessorMethod()")
* @Exporter\Expose("a-date", label="label.type-date", exp="object.getDateTime()", type="date")
* @Exporter\Expose("a-time", label="label.type-time", exp="object.getDateTime()", type="time")
*/
class DemoFull
{
/**
* @Exporter\Expose(label="label.Public-Property", type="string")
*/
public $publicProperty = 'public-property';
/**
* @Exporter\Expose("fake-name", label="label.Protected-Property", type="boolean")
*/
protected $protectedProperty = false;
/**
* @Exporter\Expose(label="label.Private-Property", type="integer")
*/
private $privateProperty = 123;
/**
* @Exporter\Expose(label="label.Public-Method")
*/
public function publicMethod(): string
{
return 'public-method';
}
/**
* @Exporter\Expose(label="label.Protected-Method", type="datetime")
*/
protected function protectedMethod(): \DateTime
{
return new \DateTime();
}
public function getDateTime(): \DateTime
{
return new \DateTime();
}
/**
* @Exporter\Expose("renamedDuration", label="label.duration", type="duration")
*/
protected function duration(): int
{
return 12345;
}
/**
* @Exporter\Expose(name="fake-method", label="label.Private-Method", type="boolean")
*/
private function privateMethod(): bool
{
return true;
}
public function accessorMethod(): string
{
return 'accessor-method';
}
}

View File

@@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Spreadsheet\Entities;
use App\Export\Annotation as Exporter;
class ExpressionOnMethod
{
/**
* @Exporter\Expose("accessor", label="label.accessor", exp="object.foo")
*/
public function foo()
{
}
}

View File

@@ -0,0 +1,20 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Spreadsheet\Entities;
use App\Export\Annotation as Exporter;
class ExpressionOnProperty
{
/**
* @Exporter\Expose("accessor", label="label.accessor", exp="object.foo")
*/
private $foo;
}

View File

@@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Spreadsheet\Entities;
use App\Export\Annotation as Exporter;
class MethodRequiresParams
{
/**
* @Exporter\Expose("accessor", label="label.accessor")
*/
public function foo(string $foo)
{
}
}

View File

@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Spreadsheet\Entities;
use App\Export\Annotation as Exporter;
/**
* @Exporter\Expose("accessor", label="label.accessor")
*/
class MissingExpressionOnClass
{
}

View File

@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Spreadsheet\Entities;
use App\Export\Annotation as Exporter;
/**
* @Exporter\Expose(label="label.accessor", exp="foo")
*/
class MissingNameOnClass
{
}