TestMarkdownToTpl.php 2.1 KB

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