コード例 #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
 /**
  * Method to create import filespace if needed
  *
  * @param   object   $hook  Models\Import\Hook
  * @return  boolean
  */
 private function _createImportFilespace(Models\Import\Hook $hook)
 {
     // upload path
     $uploadPath = $hook->fileSpacePath();
     // if we dont have a filespace, create it
     if (!is_dir($uploadPath)) {
         \Filesystem::makeDirectory($uploadPath, 0775);
     }
     // all set
     return true;
 }