首页 > 解决方案 > TYPO3 ObjectStorage + 瞬态域对象

问题描述

ObjectStorage 通常可以用于存储(瞬态,此模型没有数据库表)域对象吗?似乎不应该这样做。至少我在这个例子中遇到了麻烦:

    $storage = new ObjectStorage();

    // Add 10 items (transient domain objects) to storage
    for($i=0; $i<10; $i++) {
        $item = GeneralUtility::makeInstance(TransientDomainObjectWithoutDatabaseTable::class);
        $storage->attach($item);
    }

    // Remove all items
    foreach($storage as $item) {
        $storage->detach($item);
    }

    // Storage still contains 5 items
    DebuggerUtility::var_dump($storage);

标签: typo3extbasetransientobject-storage

解决方案


推荐阅读