OrderFrontendButton.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/7/27
  8. * Time: 17:42
  9. */
  10. namespace app\frontend\modules\order\services;
  11. use app\frontend\modules\order\operations\OrderOperationInterface;
  12. class OrderFrontendButton extends OrderFrontendButtonBase
  13. {
  14. public function enable()
  15. {
  16. return true;
  17. }
  18. public function getButton()
  19. {
  20. $button = array_map(function ($operationName){
  21. /**
  22. * @var OrderOperationInterface $operation
  23. */
  24. $operation = new $operationName($this->order);
  25. if (!$operation->enable()) {
  26. return null;
  27. }
  28. $result['name'] = $operation->getName();
  29. $result['value'] = $operation->getValue();
  30. $result['api'] = $operation->getApi();
  31. $result['type'] = $operation->getType();
  32. return $result;
  33. }, $this->getStatus());
  34. $button = array_filter($button);
  35. return array_values($button) ? : [];
  36. }
  37. }