我的主控制器是:
namespace Drupal\facebook_sharer\Controller;
use Drupal\Core\Controller\ControllerBase;
use Facebook\Facebook;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\facebook_sharer\FbConnectFbManager;
use Drupal\facebook_sharer\FbConnectPersistentDataHandler;
use Drupal\facebook_sharer\FbConnectFbFactory;
class Facebook_sharerController extends ControllerBase {
protected $fbManager;
protected $persistentDataHandler;
protected $fbFactory;
public function __construct(FbConnectFbManager $fb_manager, FbConnectPersistentDataHandler $persistent_data_handler, FbConnectFbFactory $fb_factory) {
$this->fbManager = $fb_manager;
$this->persistentDataHandler = $persistent_data_handler;
$this->fbFactory = $fb_factory;
}
在Facebook_sharerController.php文件中
我想访问模块文件中的此类对象,我尝试这样做但失败了
$fb_share_manager = new Facebook_sharerController();
我也尝试使用服务
$d = \Drupal::service("Drupal\facebook_sharer\Controller\Facebook_sharerController");
var_dump(get_class($d));die;
但是它不起作用。 请帮助我。