AbstractTool.php 831 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Dcat\Admin\Grid\Tools;
  3. use Dcat\Admin\Grid;
  4. abstract class AbstractTool extends Grid\GridAction
  5. {
  6. /**
  7. * @var string
  8. */
  9. public $selectorPrefix = '.tool-action-';
  10. /**
  11. * @var string
  12. */
  13. protected $style = 'btn btn-sm btn-primary';
  14. /**
  15. * @return string|void
  16. */
  17. protected function href()
  18. {
  19. }
  20. /**
  21. * @return string|void
  22. */
  23. public function html()
  24. {
  25. if ($href = $this->href()) {
  26. $this->usingHandler = false;
  27. }
  28. $this->setHtmlAttribute([
  29. 'data-_key' => $this->key(),
  30. 'href' => $href ?: 'javascript:void(0);',
  31. 'class' => $this->style.' '.$this->elementClass(),
  32. ]);
  33. return "<a {$this->formatHtmlAttributes()}>{$this->title()}</a>";
  34. }
  35. }