public function go(ImportURLModel $importURL) { global $app; $iurlrRepo = new ImportURLResultRepository(); $importURLRun = new ImportURLRun($importURL); $handlers = array(); // Get foreach ($app['extensions']->getExtensionsIncludingCore() as $extension) { foreach ($extension->getImportURLHandlers() as $handler) { $handlers[] = $handler; } } // Sort usort($handlers, function ($a, $b) { if ($a->getSortOrder() == $b->getSortOrder()) { return 0; } else { if ($a->getSortOrder() > $b->getSortOrder()) { return 1; } else { if ($a->getSortOrder() < $b->getSortOrder()) { return -1; } } } }); // Run foreach ($handlers as $handler) { $handler->setImportURLRun($importURLRun); if ($handler->canHandle()) { if ($handler->isStopAfterHandling()) { $iurlr = $handler->handle(); $iurlr->setImportUrlId($importURL->getId()); $iurlrRepo->create($iurlr); return; } else { $handler->handle(); } } } // Log that couldn't handle feed $iurlr = new ImportURLResultModel(); $iurlr->setImportUrlId($importURL->getId()); $iurlr->setIsSuccess(false); $iurlr->setMessage("Did not recognise data"); $iurlrRepo->create($iurlr); }