示例#1
0
文件: Merge.php 项目: netsensei/resin
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(MergeManager $mergeManager, FileManager $fileManager)
 {
     $columns = ['PID', 'entity type', 'title', 'document type', 'URL', 'enabled', 'notes', 'format', 'reference', 'order'];
     $items = $mergeManager->fetchAll();
     $writer = Writer::createFromFileObject(new SplTempFileObject());
     $writer->insertOne($columns);
     $count = 0;
     foreach ($items as $item) {
         $row = [$item->object_number, $item->entity_type, $item->object->title, $item->url, $item->enabled, $item->format, $item->representation_order, $item->reference];
         $writer->insertOne($row);
         $count++;
     }
     $output = (string) $writer;
     $timestamp = Carbon::now();
     $fileName = sprintf("import_%s.csv", $timestamp->format('dmY_His'));
     $fileManager->saveFile($fileName, $output);
     $merger = new Merger();
     $merger->filename = $fileName;
     $merger->documents = $count;
     $merger->save();
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send('test');
 }
示例#2
0
 public function fetchLatestMergers($limit = 5)
 {
     return Merger::orderBy('created_at', 'desc')->take($limit)->get();
 }