From c6273053beefbb7d01bbaf9945d731e4c99a9494 Mon Sep 17 00:00:00 2001 From: "alvaro.rosado" Date: Fri, 25 Feb 2022 14:45:38 +0100 Subject: [PATCH 1/2] some refactors --- src/Twig/Extension/DatatablesExtension.php | 40 +++++++++++----------- src/Twig/TwigFactory.php | 0 2 files changed, 20 insertions(+), 20 deletions(-) mode change 100644 => 100755 src/Twig/Extension/DatatablesExtension.php mode change 100644 => 100755 src/Twig/TwigFactory.php diff --git a/src/Twig/Extension/DatatablesExtension.php b/src/Twig/Extension/DatatablesExtension.php old mode 100644 new mode 100755 index b317160..21db8b2 --- a/src/Twig/Extension/DatatablesExtension.php +++ b/src/Twig/Extension/DatatablesExtension.php @@ -2,10 +2,12 @@ namespace Cluster28\TeamShareDocumentationUi\Twig\Extension; -use Cluster28\TeamShareDocumentation\Model\Collection\Annotations; +use Cluster28\TeamShareDocumentation\Annotation\ShareAnnotation; +use Cluster28\TeamShareDocumentation\Model\Annotation; +use Cluster28\TeamShareDocumentation\Model\AnnotationData; +use Cluster28\TeamShareDocumentation\Model\ExtractionResult; +use Cluster28\TeamShareDocumentation\Model\ClassInfo; use Cluster28\TeamShareDocumentationUi\Configuration\Templates\DatatablejsBs5Configuration; -use ReflectionClass; -use ReflectionMethod; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -31,31 +33,29 @@ public function getTableConfig(): string return json_encode($this->datatablejsBs5Configuration->getConfig()); } - public function getTableRows(Annotations $annotations): string + public function getTableRows(ExtractionResult $extractionResult): string { $rows = []; - foreach ($annotations as $arrayAnnotation) { - $rows[] = $this->getTableRow($arrayAnnotation); + foreach ($extractionResult->getResults() as $classInfo) { + /** @var ClassInfo $classInfo */ + /** @var ShareAnnotation $annotation */ + foreach ($classInfo->getAllAnnotations() as $annotation) { + $rows[] = $this->getTableRow($annotation); + } } return json_encode($rows); } - private function getTableRow($arrayAnnotation): array + private function getTableRow(AnnotationData $annotationData): array { - $class = $method = ''; - if ($arrayAnnotation[0] instanceof ReflectionClass) { - $class = $arrayAnnotation[0]->getName(); - } elseif ($arrayAnnotation[0] instanceof ReflectionMethod) { - $class = $arrayAnnotation[0]->class; - $method = $arrayAnnotation[0]->getName(); - } - + /** @var ShareAnnotation $annotation */ + $annotation = $annotationData->getAnnotation(); return [ - $arrayAnnotation[1]->date, - $class, - $method, - $arrayAnnotation[1]->description, - $arrayAnnotation[1]->tags + $annotation->getDate(), + $annotationData->getClassName(), + $annotationData->isInMethod() ? $annotationData->getMethodName() : "", + $annotation->getDescription(), + $annotation->getTags() ]; } } diff --git a/src/Twig/TwigFactory.php b/src/Twig/TwigFactory.php old mode 100644 new mode 100755 From bebe2310bcc22690633455f0caf4e627d15d2328 Mon Sep 17 00:00:00 2001 From: "alvaro.rosado" Date: Fri, 25 Feb 2022 15:26:11 +0100 Subject: [PATCH 2/2] some fixes --- src/Twig/Extension/DatatablesExtension.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Twig/Extension/DatatablesExtension.php b/src/Twig/Extension/DatatablesExtension.php index 21db8b2..b7e4f1f 100755 --- a/src/Twig/Extension/DatatablesExtension.php +++ b/src/Twig/Extension/DatatablesExtension.php @@ -36,12 +36,8 @@ public function getTableConfig(): string public function getTableRows(ExtractionResult $extractionResult): string { $rows = []; - foreach ($extractionResult->getResults() as $classInfo) { - /** @var ClassInfo $classInfo */ - /** @var ShareAnnotation $annotation */ - foreach ($classInfo->getAllAnnotations() as $annotation) { - $rows[] = $this->getTableRow($annotation); - } + foreach ($extractionResult->getAllAnnotations() as $annotation) { + $rows[] = $this->getTableRow($annotation); } return json_encode($rows); }