コード例 #1
0
ファイル: Archive.php プロジェクト: kevinwojo/framework
 /**
  * Get a count or list of import hooks
  *
  * @param   string   $rtrn     What data to return
  * @param   array    $filters  Filters to apply to data retrieval
  * @param   boolean  $boolean  Clear cached data?
  * @return  mixed
  */
 public function hooks($rtrn = 'list', $filters = array(), $clear = false)
 {
     $model = Hook::all();
     if (isset($filters['state']) && $filters['state']) {
         if (!is_array($filters['state'])) {
             $filters['state'] = array($filters['state']);
         }
         $filters['state'] = array_map('intval', $filters['state']);
         $model->whereIn('state', $filters['state']);
     }
     if (!isset($filters['type'])) {
         $filters['type'] = $this->type;
     }
     if (isset($filters['type']) && $filters['type']) {
         $model->whereEquals('type', $filters['type']);
     }
     if (isset($filters['event']) && $filters['event']) {
         $model->whereEquals('event', $filters['event']);
     }
     if (isset($filters['created_by']) && $filters['created_by'] >= 0) {
         $model->whereEquals('created_by', $filters['created_by']);
     }
     if (strtolower($rtrn) == 'count') {
         return $model->total();
     }
     return $model->ordered()->paginated()->rows();
 }
コード例 #2
0
ファイル: imports.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * 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;
 }
コード例 #3
0
 /**
  * Method to create import filespace if needed
  *
  * @param   object   $hook  \Hubzero\Content\Import\Model\Hook
  * @return  boolean
  */
 private function _createImportFilespace(\Hubzero\Content\Import\Model\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;
 }