TestMarkdownToTpl.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Http\Controllers\ArticleController;
  4. use App\Tools\Tools;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Log;
  7. class TestMarkdownToTpl extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'test:markdown.tpl {item?}';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Command description';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return int
  34. */
  35. public function handle()
  36. {
  37. if (Tools::isStop()) {
  38. return 0;
  39. }
  40. Log::info('md render start item='.$this->argument('item'));
  41. $data = [];
  42. $data['basic'] = <<<'md'
  43. # 去除烦恼的五种方法(一种分类)
  44. 1 为了自己的利益而从别人处听法;
  45. 2 为了自己的利益而开示自己听闻过的法;
  46. 3 念诵听闻过、学习过的法;
  47. 4 一次又一次地用心思维听闻过、学习过的法;
  48. 5 在心中忆念自己适合的禅修业处,如十遍、十不净等。
  49. (无碍解道,义注,1,63)
  50. md;
  51. $data['tpl'] = <<<'md'
  52. 为了自己的利益而从别人处听法;
  53. {{168-916-2-9}}
  54. md;
  55. $article = new ArticleController;
  56. foreach ($data as $key => $value) {
  57. $_item = $this->argument('item');
  58. if (! empty($_item) && $key !== $_item) {
  59. continue;
  60. }
  61. $tpl = $article->toTpl($value,
  62. 'eb9e3f7f-b942-4ca4-bd6f-b7876b59a523',
  63. [
  64. 'user_uid' => 'ba5463f3-72d1-4410-858e-eadd10884713',
  65. 'user_id' => 4,
  66. ]
  67. );
  68. var_dump($tpl);
  69. }
  70. return 0;
  71. }
  72. }