$aRequestedHandlers = $requestedHandlers ? explode(',', $requestedHandlers) : $importINI->variable('ImportSettings', 'AvailableSourceHandlers'); $areValidHandlers = SQLIImportFactory::checkExistingHandlers($aRequestedHandlers); // An exception may be thrown if a handler is not defined in sqliimport.ini if ($aRequestedHandlers) { $aHandlersOptions = SQLIImportHandlerOptions::decodeHandlerOptionLine($options['options']); $importUser = eZUser::fetchByName('admin'); // As this is a manual script, "Admin" user will be used to import $aImportItems = array(); // First stores an SQLIImportItem for each handler to process foreach ($aRequestedHandlers as $handler) { $handlerOptions = isset($aHandlersOptions[$handler]) ? $aHandlersOptions[$handler] : null; $pendingImport = new SQLIImportItem(array('handler' => $handler, 'user_id' => $importUser->attribute('contentobject_id'))); if ($handlerOptions instanceof SQLIImportHandlerOptions) { $pendingImport->setAttribute('options', $handlerOptions); } $pendingImport->store(); $aImportItems[] = $pendingImport; } $importFactory = SQLIImportFactory::instance(); $importFactory->runImport($aImportItems); $importFactory->cleanup(); $cli->notice('Import is over :)'); } else { $cli->warning('No import handler to process ! Check sqliimport.ini to define handlers'); } $memoryMax = memory_get_peak_usage(); $memoryMax = round($memoryMax / 1024 / 1024, 2); // Convert in Megabytes $cli->notice('Peak memory usage : ' . $memoryMax . 'M'); } $script->shutdown();