Repository navigation
[IMPROVEMENT] Excel: keep phpoffice/phpspreadsheet inside the Excel component - #12269
Conversation
|
Hi @thojou please Look into this for Test. Thanks |
iszmais
left a comment
There was a problem hiding this comment.
Thanks for the changes within the DataCollection!
LGMT 👍
There was a problem hiding this comment.
Thank you very much @chfsx for this improvement!
I'm very happy with the CellType, I'm unhappy with the Exception.
- Please remove all
@throwswith theExcelcomponent. There is nobody really relying on it throwing anything specific right now and I would very much like it to stay this way. We usually do not useExceptions for our command flow as I understand it and I do not want to start doing so here. - Please remove the specific
Exceptionand simply throw an\ilExceptionwith the corresponding text. - Please remove the
wrapper-function and try catch every place individually.
I know, this is ugly, but it is so on purpose. We might go any other way in the future and I do not want to cement any possible approach right now. If we now start throwing a specific Exception here this makes it look like it is by design. It isn't, it is by convenience/coincidence.
Thank you very much again and best,
@kergomard
|
Thanks a lot @kergomard, understood! Done in ce3fbb1:
|
|
Thank you so much @chfsx ! I will leave this open until wednesday OCT 28 for anybody to react and I will then merge to make sure it is in ILIAS 12. |
ilExcelwrapsphpoffice/phpspreadsheet, but its API let two library details through:setCell()expected theDataType::TYPE_*constants of the library for explicit cell types, and its public methods threw the exceptions of the library. DataCollection therefore importedPhpOffice\PhpSpreadsheet\Cell\DataType, and Test, Exercise, Survey and DataCollection documentedPhpOffice\PhpSpreadsheet\Exceptionin their@throws. This PR gives Excel its own types for both. Same approach as #12266 (guzzlehttp/psr7), #12267 (pimple/pimple) and #12268 (dflydev/fig-cookies).Excel
ILIAS\Excel\CellType(string enum:STRING,NUMERIC,BOOL,FORMULA).ilExcel::setCell()acceptsCellType|string|null; strings keep working (e.g. for plugins) but are deprecated.ILIAS\Excel\ExcelException extends \RuntimeException.ilExceltranslates the exceptions of the library into it, keeping the original one as previous (constructor,loadFromFile(),addSheet(),setActiveSheet(),sendToClient(),writeToFile(),writeToTmpFile(),addLink(),mergeCells()). The library exception is a\RuntimeExceptionas well, so callers catching that keep working.ExcelTestTBDis active again asExcelTest(it was deactivated in 2024 because the library was missing) and gets tests for the exception translation and forCellType::STRING.Components
CellType::STRING.@throwsof DataCollection, Test, Exercise and Survey name\ILIAS\Excel\ExcelException; an unused import ofDataTypein Test is removed.Testing
[OK] All static artifacts are build!RootFolderTest, which only fails locally because of untracked files in the root folder of my checkout.components/ILIAS: green. php-cs-fixer on the changed files: clean.@kergomard for Excel, @iszmais for DataCollection, @alex40724 for Exercise, @abrahammordev @juanma1331 for Survey, @dsstrassner for Test.
If there are no objections, I will merge this before Coding Completed.