ds34222 2019-05-15 13:20
浏览 85
已采纳

“班级不存在。 反射失败。“延迟加载和对象存储

I'm upgrading a website from TYPO3 8 to TYPO3 9

All the code was working well with TYPO3 8.
Now I have to adapt a lot as it came from even earlier TYPO3 (TCA, doctrine, ...) and throws some errors.

At the moment I have the problem for some pages I only get this error (in slight modifications):

(1/2) #1278450972 TYPO3\CMS\Extbase\Reflection\Exception\UnknownClassException

Class VendorName\VendorExtensionName\Domain\Model\TYPO3\CMS\Extbase\Persistence\ObjectStorage does not exist. Reflection failed.

I assume it is triggered by this code:

<?php
namespace VendorName\VendorExtensionName\Controller;
use TYPO3\CMS\Extbase\Annotation\Inject;

class AnsprechpartnerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

    /**
     * ansprechpartnerRepository
     *
     * @Inject
     * @var \VendorName\VendorExtensionName\Domain\Repository\AnsprechpartnerRepository
     */
    protected $ansprechpartnerRepository;

    [...]

    /**
     * action showDetail
     *
     * @return void
     */
    public function showDetailAction() {
        $pids = $this->settings['pids'];
        $this->settings['ansprechpartner'] = explode(',', $this->settings['ansprechpartner']);
        foreach ($this->settings['ansprechpartner'] as $uid) {
            $person = $this->ansprechpartnerRepository->findByUid($uid);  

    [...]

as this last line is in the debug stack.

The extension has 8 kinds of records which relate to each other. I assume because of this the relations are defined lazy and object storages are used.

<?php
namespace VendorName\VendorExtensionName\Domain\Model;
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
/**
 *
 * @package vendor_extension_name
 *
 */
class Ansprechpartner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {

[...]


/**
 * Organisationseinheit
 *
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\VendorName\VendorExtensionName\Domain\Model\Organisation>
 * @Lazy
 */
protected $organisationseinheit;

/**
 * Dienstleistungen
 *
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\VendorName\VendorExtensionName\Domain\Model\AnsprechpartnerDienstleistung>
 * @Lazy
 */
protected $dienstleistungen = NULL;

[...]

But here the order of the mixed up classes is reversed.
Nonetheless this might be the reason for the mixing/concatenating of the existing namespaces VendorName\VendorExtensionName\Domain\Model[\Ansprechpartner] and
\TYPO3\CMS\Extbase\Persistence\ObjectStorage to the strange class name
VendorName\VendorExtensionName\Domain\Model\TYPO3\CMS\Extbase\Persistence\ObjectStorage, which of course does not exist.


Edit:
insert the usage of
use TYPO3\CMS\Extbase\Annotation\Inject; and
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy; instead of build in inject and lazy, which has no effect.


Edit 2:

Initialization of storages (example from the class above):

class Ansprechpartner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{

    :
    /**
     * __construct
     *
     * @return Ansprechpartner
     */
    public function __construct() {
        $this->initStorageObjects();
    }

    /**
     * Initializes all ObjectStorage properties.
     *
     * @return void
     */
    protected function initStorageObjects() {
        $this->organisationseinheit = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->dienstleistungen = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
    }
    :
  • 写回答

2条回答 默认 最新

  • doumengmian1180 2019-05-22 13:16
    关注

    We found out, this is due to the changes within 9.x that relative Namespaces are now supported within Annotations and TypeHints.

    Before 9.x, Extbase Reflection always asumed absolute namespaces.

    If there is a Method with this signature, that worked before 9.x (which is a Bug) and does not work since 9.x anymore:

    public function setSomeStorage(TYPO3\CMS\Extbase\Persistence\ObjectStorage $storage) {
    

    This has to be:

    public function setSomeStorage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $storage) {
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示