コード例 #1
0
ファイル: import.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Return Hook for Post Parsing or Post Convert
  *
  * @param   string   $type    Hook we want
  * @param   object   $import  Resource Import Model
  * @return  Closure
  */
 private function _hooks($type, $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->{$type})) {
         return $callbacks;
     }
     // loop through each hook
     foreach ($hooks->{$type} as $hook) {
         // load hook object
         $importHook = new Models\Import\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;
 }
コード例 #2
0
ファイル: importhooks.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Show Raw immport hook file
  *
  * @return  void
  */
 public function rawTask()
 {
     // get request vars
     $id = Request::getVar('id', array());
     if (is_array($id)) {
         $id = !empty($id) ? $id[0] : 0;
     }
     // create hook model object
     $hook = new Models\Import\Hook($id);
     // get path to file
     $file = $hook->fileSpacePath() . DS . $hook->get('file');
     // default contents
     $contents = '';
     // if we have a file
     if (file_exists($file)) {
         // get contents of file
         $contents = file_get_contents($file);
     }
     // output contents of hook file
     highlight_string($contents);
     exit;
 }