[TYPO3-mvc] How to hide private domain class properties

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Tue Sep 20 13:25:54 CEST 2016


Hi Frans,

I think it happens when a object of the class is a property of some
other model, which is used in a Fluid form viewhelper. Then, Extbase
tries to validate the whole object and complains about missing getters.

For example:

I extended fe_user with a property Betrieb, which is a model class of my
extension. Betrieb has some variables without a getter.

In one of my actions I use fe_user as a argument to pre-load the fluid
form, when a record is available:

    /**
     * action list
     *
     * @param \GoCo\Eqbkanton\Domain\Model\FeUser $editUser
     * @return void
     * @ignorevalidation $editUser
     */
    public function listAction(\GoCo\Eqbkanton\Domain\Model\FeUser
$editUser=null) {
        $feUsers = $this->feUserRepository->findByUsergroup(2);
        $this->view->assign('feUsers', $feUsers);
        $this->view->assign('edituser', $editUser);
    }

In the view:
<f:form action="update">
    <label for="formid">Betrieb-ID:</label><f:form.textfield id="formid"
name="portalid">{edituser.betrieb.portalId}</f:form.textfield>
    <label for="formname">Betriebsname:</label><f:form.textfield
id="formname" name="name">{edituser.betrieb.name}</f:form.textfield>
    <label for="formfeusername">Benutzername:</label><f:form.textfield
id="formusername" name="feusername">{edituser.username}</f:form.textfield>
   .....
</f:form>

I.e. I'm using properties from both fe_user and fe_user.betrieb, which
is the class with the property issue...

I put the ignorevalidation annotation on every place that came into my
mind, but it did not help.

Regards,
Till

On 09/19/2016 09:42 PM, Frans Saris wrote:
> Hi Till,
>
> When do you get such errors? We use often properties that aren't exposed by
> getter/setter and haven't run into such an issue. To be honest we normally
> mark them as protected but don't think that matters.
>
> Groet Frans
>
> Op ma 19 sep. 2016 15:50 schreef <g4-lisz at tonarchiv.ch>:
>
>> He there,
>>
>> I already asked this question quite a while ago and never found a
>> solution. Now I have this issue again and it would help me a lot to
>> solve it:
>>
>> In some of my model classes I need helper arrays to cache some stuff.
>> But I do not want them to be exposed to any MVC mechanism. I.e. I do not
>> define any getters because there is nothing meaningful to get from
>> outside of the class.
>>
>> But then I always get an error like:
>>
>> PHP Warning: call_user_func_array() expects parameter 1 to be a valid
>> callback, class 'MyVend\Myext\Domain\Model\Betrieb' does not have a
>> method 'get_hasXXX'.
>>
>> I tried with variable names staring with a underscore, declaring them as
>> private... It does not help. The MVC "engine" always wants a getter for
>> them.
>>
>> How can I hide variables in a model class? Is there maybe some
>> annotation, like:
>>
>>   /*
>>    * _doNotTouch  for internal use only
>>    *
>>    * @ignore
>>    */
>>   private $_doNotTouch = array();
>>
>>
>> Of course I could write dummy getters for such variables. But it does
>> not make much sense...
>>
>> Regards,
>> Till
>>
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc




More information about the TYPO3-project-typo3v4mvc mailing list