第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

TYPO3 v9.5.11 Extbase:將ContainerClass生成的Service

TYPO3 v9.5.11 Extbase:將ContainerClass生成的Service

PHP
胡子哥哥 2022-07-16 18:42:57
我正在嘗試將服務(wù)對(duì)象注入我的存儲(chǔ)庫(kù)。我在 Classes/Services 目錄下創(chuàng)建了不同的服務(wù)類(lèi)。我還創(chuàng)建了一個(gè)名為 ContainerService 的類(lèi),它為每個(gè)服務(wù)類(lèi)創(chuàng)建并實(shí)例化一個(gè) ServiceObject。容器服務(wù)類(lèi):namespace VendorName\MyExt\Service;use VendorName\MyExt\Service\RestClientService;class ContainerService {    private $restClient;         private $otherService;    /**     * @return RestClientService     */    public function getRestClient() {        $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);        if ($this->restClient === null) {            $this->restClient = $objectManager->get(RestClientService::class);                    }        return $this->restClient;    }...正如我所說(shuō),我在 ContainerService 類(lèi)中創(chuàng)建了我的 ServiceObjects?,F(xiàn)在我想將 ContainerService 注入我的存儲(chǔ)庫(kù)并使用它。MyRepository 類(lèi):namespace VendorName\MyExt\Domain\Repository;use VendorName\MyExt\Service\ContainerService;class MyRepository extends Repository{        /**     * @var ContainerService     */    public $containerService;    /**     * inject the ContainerService     *          * @param ContainerService $containerService      * @return void     */    public function injectContainerService(ContainerService $containerService) {        $this->containerService = $containerService;    }    // Use Objects from The ContainerService    public function findAddress($addressId) {        $url = 'Person/getAddressbyId/'         $someData = $this->containerService->getRestClient()->sendRequest($url)    return $someData;    }在 MyController 中,我從 findAddress 函數(shù)中接收 $someData 并對(duì)其進(jìn)行一些處理。但是當(dāng)我調(diào)用我的頁(yè)面時(shí),我收到以下錯(cuò)誤消息:(1/2) #1278450972 TYPO3\CMS\Extbase\Reflection\Exception\UnknownClassExceptionClass ContainerService does not exist. Reflection failed.已經(jīng)嘗試重新加載所有緩存并轉(zhuǎn)儲(chǔ)自動(dòng)加載也無(wú)濟(jì)于事。沒(méi)有用 composer 安裝 TYPO3。我感謝任何建議或幫助!謝謝!
查看完整描述

1 回答

?
慕神8447489

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超1個(gè)贊

實(shí)際發(fā)現(xiàn)了問(wèn)題。在 MyRepository 類(lèi)中,注釋和 TypeHint 存在問(wèn)題:


namespace VendorName\MyExt\Domain\Repository;


use VendorName\MyExt\Service\ContainerService;


class MyRepository extends Repository

{    

    /**

     *** @var \VendorName\MyExt\Service\ContainerService**

     */

    public $containerService;


    /**

     * inject the ContainerService

     *     

     * @param \VendorName\MyExt\Service\ContainerService $containerService 

     * @return void

     */

    public function injectContainerService(\VendorName\MyExt\Service\ContainerService $containerService) {

        $this->containerService = $containerService;

    }


    // Use Objects from The ContainerService


    public function findAddress($addressId) {

        $url = 'Person/getAddressbyId/' 

        $someData = $this->containerService->getRestClient()->sendRequest($url)

    return $someData;

    }

現(xiàn)在它起作用了。


查看完整回答
反對(duì) 回復(fù) 2022-07-16
  • 1 回答
  • 0 關(guān)注
  • 105 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)