| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- declare(strict_types=1);
- namespace App\Command;
- use App\Repositories\Utils\AccessControllerListsRepository;
- use Hyperf\Command\Command as HyperfCommand;
- use Hyperf\Command\Annotation\Command;
- use Psr\Container\ContainerInterface;
- /**
- * @Command
- */
- class PermissionResourceCommand extends HyperfCommand
- {
- /**
- * @var ContainerInterface
- */
- protected $container;
- protected $name = 'permission:resource';
- /**
- * 属性描述.
- *
- * @var AccessControllerListsRepository
- */
- private $aclRepo = null;
- public function __construct(ContainerInterface $container)
- {
- $this->container = $container;
- parent::__construct($this->name);
- }
- public function configure()
- {
- parent::configure();
- $this->setDescription('更新后台权限资源表');
- }
- public function handle()
- {
- $authConfig = config('manage_acl');
- $this->getAclRepo()->getController(
- $authConfig,
- base_path(). '/Modules/Manage/Controllers',
- 'Controller',
- 'Modules\Manage\Controllers'
- );
- $this->line('更新权限资源完毕,可以去表[permission_resource]查看确认', 'info');
- }
- /**
- * 获取ACL仓库
- * @return AccessControllerListsRepository|null
- */
- private function getAclRepo()
- {
- if (empty($this->aclRepo)) {
- $this->aclRepo = make(AccessControllerListsRepository::class);
- }
- return $this->aclRepo;
- }
- }
|