From 2a5db804db2926ce51606a4b0bd32e0b63e0ee84 Mon Sep 17 00:00:00 2001 From: Emil Mohamed Date: Sun, 8 Oct 2017 14:52:55 +0300 Subject: [PATCH] Improve boilerplate comments --- _examples/01.menu-page/csv-importer.php | 32 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/_examples/01.menu-page/csv-importer.php b/_examples/01.menu-page/csv-importer.php index 5b61460..b620be0 100644 --- a/_examples/01.menu-page/csv-importer.php +++ b/_examples/01.menu-page/csv-importer.php @@ -3,25 +3,41 @@ use \Carbon_CSV\Import_Page; use \Carbon_CSV\Import_Process; +/** + * Import process for the names CSV file + */ class Names_Import_Process extends Import_Process { + /** + * This will be called before starting an import. Use this method to take + * care of any tasks that should be done before importing a CSV -- e.g. + * remove any old data, or write in a log file for future reference. + */ public function will_start() { - - // do stuff here with CSV - + // Initialize the importer } + /** + * Import single row from the CSV. Typically, this would involve calling + * wp_insert_post(). Throwing an exception from this method will not + * abort the whole process, but will show a warning to the user. + */ public function import_row( $row ) { - - // imported row + // Call wp_insert_post() or whatever you need to do with $row return true; } + /** + * An import has ended -- you could cleanup stuff here if you need to. + */ public function ended() { - // do cleanup stuff here - } - + + /** + * A Carbon_Csv\CsvFile instance that allows you to setup to the column + * names, the header, or to skip some rows or columns. + * See https://github.com/htmlburger/carbon-csv/blob/master/README.md + */ public function setup_csv() { $this->csv->use_first_row_as_header(); }