对于标志,我可以指定 --help 命令中出现的描述
flag.String("a", "", "Is is a flag")
Run Code Online (Sandbox Code Playgroud)
但我没有标志,只有参数,我像这样使用 cli
mycommand start 4
Run Code Online (Sandbox Code Playgroud)
是否可以使用 --help 查看“start”(和其他)参数的描述?
我使用 Api 平台。我有订阅者
namespace App\EventSubscriber\Api;
use ApiPlatform\Core\EventListener\EventPriorities;
use App\Entity\Product;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\KernelEvents;
final class ProductCreateSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
KernelEvents::VIEW => ['createHost', EventPriorities::POST_WRITE],
];
}
public function createHost(GetResponseForControllerResultEvent $event)
{
$product = $event->getControllerResult();
$method = $event->getRequest()->getMethod();
if (!$product instanceof Product || Request::METHOD_POST !== $method) {
return;
}
I NEED ENTITY MANAGER HERE
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以在这里找到实体经理?
创建产品后,我需要创建另一个实体