-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom filename field for exported PDF to project properties
- Loading branch information
Showing
5 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Changelog | ||
|
||
## [2.1] | ||
|
||
- added custom field to project properties to be able to provide a custom filename for the generated PDF | ||
- changed the custom PDF template name to `custom-export.pdf.twig` | ||
|
||
## [2.0] | ||
|
||
- added compatability for Kimai version >= 2.0.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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 KimaiPlugin\CustomExportBundle\EventSubscriber; | ||
|
||
use App\Entity\MetaTableTypeInterface; | ||
use App\Entity\ProjectMeta; | ||
use App\Event\ProjectMetaDefinitionEvent; | ||
use App\Event\ProjectMetaDisplayEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Validator\Constraints\Length; | ||
|
||
class MetaFieldSubscriber implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
ProjectMetaDefinitionEvent::class => ['loadProjectMeta', 200], | ||
ProjectMetaDisplayEvent::class => ['loadProjectFields', 200], | ||
]; | ||
} | ||
|
||
private function getMetaField(): MetaTableTypeInterface | ||
{ | ||
$definition = new ProjectMeta(); | ||
$definition->setName('custom_export_filename'); | ||
$definition->setLabel('Leistungsnachweis: Dateiname'); | ||
$definition->setOptions(['help' => 'Erlaubt es einen Dateinamen für den Custom PDF Export für diese Projekt anzugeben']); | ||
$definition->setType(TextType::class); | ||
$definition->addConstraint(new Length(['max' => 255])); | ||
$definition->setIsVisible(true); | ||
|
||
return $definition; | ||
} | ||
|
||
public function loadProjectMeta(ProjectMetaDefinitionEvent $event): void | ||
{ | ||
$event->getEntity()->setMetaField($this->getMetaField()); | ||
} | ||
|
||
public function loadProjectFields(ProjectMetaDisplayEvent $event): void | ||
{ | ||
$event->addField($this->getMetaField()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters