Session 获取/请求会话Symfony2的另一种方式?

Session 获取/请求会话Symfony2的另一种方式?,session,symfony,console,command,request,Session,Symfony,Console,Command,Request,关于如何在symfony2中请求/获取会话,还有其他方法吗?除了打开服务容器和通过请求之外?谢谢 我正在创建一个会话管理器,它将通过命令控制台创建会话。您可以将会话直接插入会话管理器: 1创建会话管理器: <?php namespace Acme\YourBundle\Manager; use Symfony\Component\Session/SessionInterface; class SessionManager { /** * The session

关于如何在symfony2中请求/获取会话,还有其他方法吗?除了打开服务容器和通过请求之外?谢谢


我正在创建一个会话管理器,它将通过命令控制台创建会话。您可以将会话直接插入会话管理器:

1创建会话管理器:

<?php

namespace Acme\YourBundle\Manager;

use Symfony\Component\Session/SessionInterface;

class SessionManager
{

    /**
     * The session
     *
     * @var SessionInterface
     */
    private $session;

    /**
     * @param SessionInterface
     */
    public function __construct(SessionInterface $session)
    {
        $this->session = $session;
    }


}

您可以查看的api,它将帮助您完成。

非常感谢您:)
services:
    # Session manager
    acme_your_bundle.session_manager:
        class: Acme\YourBundle\Manager\SessionManager
        arguments:
            session: "@session"