Advertisement
mtbrandall

TicketCommand.php

Feb 10th, 2021
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. namespace App\Command;
  3.  
  4. use Cake\Command\Command;
  5. use Cake\Console\Arguments;
  6. use Cake\Console\ConsoleIo;
  7. use Cake\Console\ConsoleOptionParser;
  8.  
  9. class TicketCommand extends Command
  10. {
  11.     protected $modelClass = 'Debug';
  12.    
  13.     public function execute(Arguments $args, ConsoleIo $io)
  14.     {
  15.         $fd = fopen("php://stdin", "r");
  16.         $email_content = "";
  17.         while (!feof($fd)) {
  18.         $email_content .= fread($fd, 1024);
  19.         }
  20.         fclose($fd);    
  21.        
  22.         $data['debug'] = $email_content;
  23.        
  24.        
  25.         $debug = $this->Debug->newEmptyEntity();
  26.        
  27.         $debug = $this->Debug->patchEntity($debug, $data);
  28.         if ($this->Debug->save($debug))
  29.         {
  30.             $io->out('The ticket header has been saved.');
  31.         }else{
  32.             $io->out('The ticket header could not be saved. Please, try again.');
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement