1
votes

I have written an extension based on TYPO3 version 9. I have now installed it in a TYPO3 version 10 system and everything seems to work fine. Only the show pages can not be opened anymore.

The error comes:

Cannot access protected property myname\myextension\Domain\Model\Country::$name

I do not understand the mistake. On the list page I use the country name normally. On the Show pages I do not use it at all. So it makes no sense why this should cause problems.

Here is my Show.html

<div class="card">
    <h5 class="card-header" style="text-align: center">
        {house.name}
    </h5>
    <div class="card-body" style="text-align: center">
        <p class="card-text">
            <f:link.external uri="{house.link}" target="_blank">{house.link}</f:link.external>
        </p>
        <h2>Rooms</h2>
        <ul>
            <f:for each="{house.room}" as="room">
                <li>{room.name}</li>
            </f:for>
        </ul>
    </div>
</div>
<f:link.action action="list" class="btn btn-primary">
    BACK
</f:link.action>

My Controller

class HouseController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
............
............
    /**
     * @param House $house
     */
    public function showAction(House $house)
    {
        $this->view->assign('house', $house);
    }

As said before the complete code works fine on version 9, there must be some change in version 10 the problems.

Edit: Here is my Country Model

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

    /**
     * Country Name
     * 
     * @var string
     * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
     */
    protected $name = '';

    /**
     * Returns the name
     * 
     * @return string $name
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Sets the name
     * 
     * @param string $name
     * @return void
     */
    public function setName($name)
    {
        $this->name = $name;
    }
}

And here my House Model (not all lines):

class House extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
    /**
     * __construct
     */
     public function __construct()
     {

            //Do not remove the next line: It would break the functionality
            $this->initStorageObjects();
     }
    /**
     * Countrie House
     * 
     * @var \myname\myextension\Domain\Model\Country
     * @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
     */
    protected $country = null;

    /**
     * Returns the country
     * 
     * @return \myname\myextension\Domain\Model\Country $country
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     * Sets the country
     * 
     * @param \myname\myextension\Domain\Model\Country $country
     * @return void
     */
    public function setCountry(\myname\myextension\Domain\Model\Country $country)
    {
        $this->country = $country;
    }
}
1
I don't see any country model in your HTML and controller. Where is that model used? And how does the country model look like?Thomas Löffler
Exactly there is no country Model in my Show HTML. Thats crazy. But every House Model has a relationship to one country. (A house is exactly in one country and a house has several rooms.) But this model is also used in the List.html and works without error.Lehtis
You should give more information, what's the code of the House model ?Florian Rival
Ok i have added my country and house modelLehtis
Can you remove the Lazy part in your house model and try again? Of course, clearing all caches after removal.Thomas Löffler

1 Answers

4
votes

Problem is that you're using @TYPO3\CMS\Extbase\Annotation\ORM\Lazy for a direct relation to a model. The @TYPO3\CMS\Extbase\Annotation\ORM\Lazy annotation is helpful for using it for ObjectStorage, it's not recommended to use for other models directly.