Conversation
| $reflectionProp = new \ReflectionProperty($entityClass, $property); | ||
| $relation = $reader->getPropertyAnnotation($reflectionProp, 'AppBundle\\Annotations\\Annotation\\Excel'); | ||
|
|
||
| if($relation) { |
| return ResponseFactory::streamFile($response,$this->name.'.csv',$type); | ||
|
|
||
| case self::FORMAT_EXPORT_XLSX: | ||
| $export = new ListToExcel($this->container->getParameter('cache_temporary_documents_dir')); |
There was a problem hiding this comment.
Ca devrait être un service je pense
| /** | ||
| * @return String | ||
| */ | ||
| public function getCssClass() |
There was a problem hiding this comment.
Ca devrait plutot être un array, du genre addCssClass($class) et à la fin on fait un implode(' ', $this->cssClass), ca permet d'en ajouter à plusieurs endroits
| { | ||
| public static function hydrateObject($entityClass, $data) | ||
| { | ||
| $reader = new AnnotationReader(); |
There was a problem hiding this comment.
Plutot que de créer une nouvelle instance, il est dispo en service ca évite d'en recréer un
| if($reflectionObj->hasProperty($property)) { | ||
|
|
||
| $reflectionProp = new \ReflectionProperty($entityClass, $property); | ||
| $relation = $reader->getPropertyAnnotation($reflectionProp, 'AppBundle\\Annotations\\Annotation\\Excel'); |
There was a problem hiding this comment.
Bonne pratique : Excel::class plutot que la classe en dur
| use JMS\Serializer\Annotation\VirtualProperty; | ||
| use JMS\Serializer\Annotation\MaxDepth; | ||
|
|
||
| use AppBundle\Annotations\Annotation\Excel; |
There was a problem hiding this comment.
Ca vaudrait presque le coup de direct faire un use AppBundle\Annotations\Annotation as App; comme ca si on en crée de nouvelles elles sont direct dispo
| $list->addColumn(new Column('Date', function (PayementFile $file) use ($router) { | ||
| $this->addColumn(new Column('Date', function (PayementFile $file) use ($router) { | ||
| return $file->getDate(); | ||
| },'date(global_datetime_format)')); |
There was a problem hiding this comment.
Il faut qu'on crée un service qui contient tous les paramètres de ce type, qu'on stockerait en base de donnée et qu'on cacherait dès récupération initiale
| @@ -46,7 +46,7 @@ public function getDefault($items, $url = null) | |||
| } | |||
|
|
||
| public function generateExcel(AbstractList $list) | ||
| { | ||
| $workBook = new \PHPExcel(); |
There was a problem hiding this comment.
Utiliser le service fournis par le bundle de PHPExcel
| { | ||
| $workBook = new \PHPExcel(); | ||
|
|
||
| $workBook->setActiveSheetIndex(0); |
There was a problem hiding this comment.
Et créer un service qui permet de générer des objets excels pré formatés (auteur, description...) de manière centralisée
| * @param $contentType | ||
| * @return Response | ||
| */ | ||
| static function streamFile($fileContent,$fileName,$contentType) |
There was a problem hiding this comment.
Le bundle https://github.com/liuggio/ExcelBundle fournis tout ca et plus encore
resolve #79