[TYPO3-mvc] Where to put eID Class?
Bastian Waidelich
bastian at typo3.org
Mon Jul 13 11:09:04 CEST 2009
Joerg Schoppet wrote:
Hi,
>> I'm introducing an eID-Feature to my MVC-Extension, but where should I
>> put it?
> My last information is to put such a class/script under
> Resources/Private/PHP
I think you mix up something. Resources/Private/PHP is the location for
3rd party libraries (e.g. Resources/Private/PHP/PHPUnit or
Resources/Private/PHP/phpMyAdmin)
In the case of eID-classes it depends on the purpose I guess. For
instance: when your eID implementation acts like some kind of API to
your extension you might put it in Classes/Api, Classes/Gateway,
Classes/Interface or similar.
After all, an eID class could be just a regular class that might be used
in several places.
To avoid that the class is instantiated in non-eID-usecases I usually so
something like:
class Tx_MyExtension_Api_Customer {
public function getCustomerById($customerId) {
...
}
}
if (isset(t3lib_div::_GET('eID'))) {
$customerApi = t3lib_div::makeInstance('Tx_MyExtension_Api_Customer');
$customer =
$customerApi->getCustomerById((integer)t3lib_div::_GET('customerId'));
echo t3lib_div::array2xml_cs($customer);
}
This is just dummy code, but you get the point - you can reuse this
class from other places like typoscript or from other extensions.
So, I think it is probably not the best idea to add the convention that
eID-classes should reside in a special directory cause it just depends
on the use case.. But I'm open to be convinced otherwise ;)
Bastian
More information about the TYPO3-project-typo3v4mvc
mailing list