Skip to content

Instantly share code, notes, and snippets.

@mentisy
Created July 15, 2019 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mentisy/6643e8c8109239e05bab9993aa7b9667 to your computer and use it in GitHub Desktop.
Save mentisy/6643e8c8109239e05bab9993aa7b9667 to your computer and use it in GitHub Desktop.
CakePHP: Output entity errors in CLI
<?php
namespace App\Command\Helper;
use Cake\Console\Helper;
class ErrorHelper extends Helper {
/**
* @param array $args
*/
public function output($args): void
{
$this->_io->err('Errors:');
$errors_table[] = ['Field', 'Rule', 'Message'];
foreach($args as $field => $errors) {
foreach($errors as $rule => $message) {
$errors_table[] = [$field, $rule, $message];
}
}
$this->_io->helper('Table')->output($errors_table);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment