/** * Return Hook for Post Parsing or Post Convert * * @param string $event Hook we want * @param object $import Import Model * @return object Closure */ private function _hooks($event, $import) { // Array to hold callbacks $callbacks = array(); // Get hooks on import $hooks = json_decode($import->get('hooks')); // Make sure we have this type of hook if (!isset($hooks->{$event})) { return $callbacks; } // Loop through each hook foreach ($hooks->{$event} as $hook) { // Load hook object $importHook = Hook::oneOrNew($hook); // Make sure we have an object if (!$importHook->get('id')) { continue; } // Build path to script $hookFile = $importHook->fileSpacePath() . DS . $importHook->get('file'); // Make sure we have a file if (!is_file($hookFile)) { continue; } // Add callback $callbacks[] = function ($data, $dryRun) use($hookFile) { return include $hookFile; }; } // Return closures as callbacks return $callbacks; }
/** * Delete record * * @return void */ public function removeTask() { // check token Request::checkToken(); // get request vars $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; // loop through all ids posted $i = 0; foreach ($ids as $id) { // make sure we have an object $hook = Hook::oneOrNew($id); if (!$hook->get('id')) { continue; } $hook->set('state', 2); if (!$hook->save()) { Notify::error($hook->getError()); continue; } $i++; } if ($i) { Notify::success(Lang::txt('COM_MEMBERS_IMPORTHOOK_REMOVED')); } //inform user & redirect $this->cancelTask(); }