Hi Alexander,

thanks for that question, it was somehow challaging. But first let me explain 
the situation in my to make sure i got it correctly:

Module 3 is extending a class from module one by using the extends section in 
metadata.php.
It works, and at the first look the only special thing here is that we are 
using namespaces.

But then having a look into the class in module 3 we are confused because we 
missing the extends classname_parent. And infact that is wrong so why does it 
work?

The reason is that it works because it is a very simple example and we are not 
using anything from module 2 that would let us know that something is wrong 
here. But lets have a look a the 'magic' behinde that:

When oxnew is used to get the instance of our extended class, it generates a 
chain by building the parent for class of class3. In this case 
Test3Content_parent as alias of the class in module 2.
As test3content is NOT extending Test3Content_parent it not a child class of 
module2. But as the only method we are using on Test3Content exists we are not 
going to recognize that we are not using the modulechain at all.

Btw. I am working on "module internals" to find and display such problems, any 
help is welcome.

I hope i am right with the stuff i wrote, and that it is understandable. I am 
looking forward to use namespaces in modules by my self.

Best regards

Keywan
________________________________________
Von: Alexander Nostadt [a...@tro.net]
Gesendet: Freitag, 11. November 2016 16:06
An: dev-general@lists.oxidforge.org
Betreff: Namespace usage in modules

Hello together,

these days I am developing modules for OXID CE v6 BETA. As with OXID v6 
namespaces have been introduced I want to make use of them as needed. Now I 
have reached a point I want to extend existing classes. Of course I want to use 
the new classes which are located in a namespace.

Well, at this point I am stucked. I got this link sent: 
https://github.com/OXID-eSales/oxideshop_ce/tree/b1f8361a1a2fd710bd1169f5b69339995428b586/source/modules/test
 which are simply code samples. However, e.g. in module 3 
https://github.com/OXID-eSales/oxideshop_ce/blob/b1f8361a1a2fd710bd1169f5b69339995428b586/source/modules/test/module3/metadata.php
 “ContentController::getTitle()” will be overridden and as expected, in the 
extend-block "test/module3/Model/Test3Content” is defined. BUT when taking a 
look at Test3Content class file one notice there is no “extend someClass”. How 
this is supposed to work?

Is there some kind of magic I didn’t get yet or …? I appreciate your help ☺

Best regards,

Alex

Reply via email to