PHP code example of tourze / resource-manage-bundle
1. Go to this page and download the library: Download tourze/resource-manage-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tourze / resource-manage-bundle example snippets
class MyResource implements ResourceIdentity
{
public function getResourceId(): string
{
return $this->id;
}
public function getResourceLabel(): string
{
return $this->name;
}
}
use Symfony\Component\Security\Core\User\UserInterface;
use Tourze\ResourceManageBundle\Model\ResourceIdentity;
use Tourze\ResourceManageBundle\Service\ResourceProvider;
class MyResourceProvider implements ResourceProvider
{
public function getCode(): string
{
return 'my_resource';
}
public function getLabel(): string
{
return '我的资源';
}
public function getIdentities(): iterable|null
{
// 返回所有可用资源
}
public function findIdentity(string $identity): ResourceIdentity|null
{
// 查找特定资源
}
public function sendResource(UserInterface $user, ?ResourceIdentity $identity, string $amount, int|float|null $expireDay = null, ?\DateTimeInterface $expireTime = null): void
{
// 实现资源发放逻辑
}
}