コード例 #1
0
 /**
  * Process the workflow's result object.
  */
 protected function processResult()
 {
     $succeeded = $this->result->getSuccessCount();
     $failed = $this->result->getTotalProcessedCount() - $succeeded;
     if ($succeeded > 0) {
         $this->addNotice(sprintf('Successfully imported %s records.', $succeeded), 'success');
     }
     if ($failed > 0) {
         $this->addNotice(sprintf('%s records contained errors and were skipped.', $failed), 'error');
         // Format exception messages for display
         $messages = [];
         $i = 0;
         /**
          * @var int             $row
          * @var WriterException $exception
          */
         foreach ($this->result->getExceptions() as $row => $exception) {
             $messages[] = sprintf('<b>Row #%s:</b> %s', $row, $exception->getMessage());
             $i++;
             if ($i === 10) {
                 // If there are more than 10 errors recorded, stop here and add a line indicating
                 // that there are more errors that haven't been shown
                 $remainingErrors = $this->result->getErrorCount() - $i;
                 $messages[] = sprintf('<i>...and %s more errors</i>', $remainingErrors);
                 break;
             }
         }
         // Add an additional notice to display up to 10 of the logged import errors
         $this->addNotice(sprintf('<p><b>Errors:</b></p><ul><li>%s</li></ul>', implode('</li><li>', $messages)), 'warning');
     }
 }
コード例 #2
0
ファイル: ResultTest.php プロジェクト: repat/data-import
 public function testGetExceptions()
 {
     $exceptions = new \SplObjectStorage();
     $exceptions->attach(new \Exception());
     $exceptions->attach(new \Exception());
     $result = new Result('export', new \DateTime(), new \DateTime(), 10, $exceptions);
     $this->assertSame($exceptions, $result->getExceptions());
 }
コード例 #3
0
ファイル: ResultTest.php プロジェクト: lmkhang/mcntw
 public function testGetExceptions()
 {
     $exceptions = array(new \Exception(), new \Exception());
     $result = new Result('export', new \DateTime(), new \DateTime(), 10, $exceptions);
     $this->assertSame($exceptions, $result->getExceptions());
 }