/** * Process Import data * * @access public * @param Closure Object */ public function process(\Components\Resources\Models\Import $import, array $callbacks, $dryRun) { // create new xml reader $iterator = new \Components\Resources\Import\Iterators\Csv($import->getDatapath(), $this->delimiter); // get the import params $options = new \Hubzero\Config\Registry($import->get('params')); // get the mode $mode = $import->get('mode', 'UPDATE'); // loop through each item foreach ($iterator as $index => $record) { // make sure we have a record if ($record === null) { continue; } // do we have a post parse callback ? $record = $this->map($record, $callbacks['postparse'], $dryRun); // convert to resource objects $resource = new \Components\Resources\Models\Import\Record($record, $options->toArray(), $mode); // do we have a post map callback ? $resource = $this->map($resource, $callbacks['postmap'], $dryRun); // run resource check & store $resource->check()->store($dryRun); // do we have a post convert callback ? $resource = $this->map($resource, $callbacks['postconvert'], $dryRun); // add to data array array_push($this->data, $resource); // mark record processed $import->runs('current')->processed(1); } return $this->data; }
/** * Edit an Import * * @return void */ public function editTask() { Request::setVar('hidemainmenu', 1); // get request vars $ids = Request::getVar('id', array()); $id = isset($ids[0]) ? $ids[0] : 0; // get the import object $import = new Models\Import($id); // import params $params = new \Hubzero\Config\Registry($import->get('params')); // get all files in import filespace $files = Filesystem::files($import->fileSpacePath(), '.'); // get all imports from archive $hooksArchive = Models\Import\Hook\Archive::getInstance(); $hooks = $hooksArchive->hooks('list', array('state' => array(1))); // Get groups $groups = Group::find(array('authorized' => 'admin', 'fields' => array('cn', 'description', 'published', 'gidNumber', 'type'), 'type' => array(1, 3), 'sortby' => 'description')); // Output the HTML $this->view->set('import', $import)->set('params', $params)->set('files', $files)->set('hooks', $hooks)->set('groups', $groups)->setErrors($this->getErrors())->setLayout('edit')->display(); }