Example #1
0
 /**
  * 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 = new \Hubzero\Content\Import\Model\Hook($hook);
         // Make sure we have an object
         if (!$importHook) {
             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;
 }
Example #2
0
 /**
  * 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
     foreach ($ids as $id) {
         // make sure we have an object
         $hook = new \Hubzero\Content\Import\Model\Hook($id);
         if (!$hook->exists()) {
             continue;
         }
         $hook->set('state', 2);
         if (!$hook->store(true)) {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=display', false), $hook->getError(), 'error');
             return;
         }
     }
     //inform user & redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=display', false), Lang::txt('COM_MEMBERS_IMPORTHOOK_REMOVED'), 'passed');
 }