I want to override function doGenerate() in this class, but it's not possible to xclass this class.
Alternatively, I tried Helmut Hummel's solution in typo3-config-handling, where he uses a class_alias, like this:
class_alias(\Helhum\TYPO3\ConfigHandling\Xclass\ConfigurationManager::class, \TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
but no luck either:
'PHP Warning: Cannot declare class TYPO3\CMS\Core\Routing\UrlGenerator, because the name is already in use in /home/ahkalbert/vendor/netklaar/typo3-routing/res/php/autoload-include.php on line 2'
Any suggestions how to solve this?
Related
I'm trying to follow this article: https://bronsonzgeb.com/index.php/2021/03/20/pseudo-metaballs-with-scriptable-renderer-features-in-unitys-urp/
I've gotten to the end of it and tried to compile but got the following message:
RenderWater.cs(38,30): error CS0115: 'RenderWater.RenderObjectsPass.OnCameraSetup(CommandBuffer, ref RenderingData)': no suitable method found to override
The line in question is:
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
I'm new to URP and so I have likely missed something, but I have not idea what
Edit: Just need to make sure you have "Universal RP" installed in the Package Manager.
Are you inheriting the right class? You need to make sure that you're doing the following instead of inheriting from MonoBehavior.
YourClass : TheClassWithThatMethodInIt
Are you running into a namespace issue? Does VS flag it as missing the method to override as well?
Lots of missing functions are added to the 2020 version you might want to update your unity to the newer one. You can check the unity change log:
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal#12.1/changelog/CHANGELOG.html
"OnCameraSetup" is added on the 2020
How can I override a constructor in Magento2? I want to override the execute function of Magento\Customer\Controller\Account\LoginPost class. And while doing that I want to use Magento\Customer\Api\Data\GroupInterface for changing customers group. I can use objectManager but that is not recommended. So what are the other ways?
There are two ways to do that:
create a new module, create a new class that would extend from Magento\Customer\Controller\Account\LoginPost and override constructor and execute method,
use a plugin, since the execute method is public, then you can inject Magento\Customer\Api\Data\GroupInterface inside the plugin constructor.
The second option is much easier, go with that. You can read more about plugins here. There is no example with constructor, but you can add it and dependency injection would work there as usual.
I would like to change the function \TYPO3\CMS\Backend\View\PageLayoutView::getContentRecordsPerColumn a little bit. But I don't like to overwrite the whole class. There is no hook and no signal in the nearby programming code.
How can this be done?
You could write an XClass that extends
\TYPO3\CMS\Backend\View\PageLayoutView and just override
the method getContentRecordsPerColumn()
Answer from Andreas Fernandez on typo3.slack.com
I saw some extension files which are in TYPO3 4.5. (class.tx_ajaxsearch_pi1.php...), looks like this way:
class tx_ajaxsearch_pi1 extends tslib_pibase {
...
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ajax_search/pi1/class.tx_ajaxsearch_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ajax_search/pi1/class.tx_ajaxsearch_pi1.php']);
}
I am checking this document about XCLASS: http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/3/8/
Questions:
According to this document: http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/3/8/
Extending TYPO3s PHP classes is recommended mostly for special needs in individual projects. This is due to the limitation that a class can only be extended once. Thus, if many extensions try to extend the same class, only one of them will succeed and in turn the others will not function correctly.
But why class tslib_pibase can be extended many times by different extension classes?
Is it a good habit to put below codes in every extension scripts? Just in case the extension class needs to be extended in the future?
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ajax_search/pi1/class.tx_ajaxsearch_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ajax_search/pi1/class.tx_ajaxsearch_pi1.php']);
XCLASS'ing is an approach, when someone substitutes one class with another one. Sounds like inheritance in OOP, but in fact it is different, because you can XCLASS only once, since in TYPO3 global scope one class definition is substituted with another one.
So, i.e. you XCLASS t3lib_db with ux_t3lib_db - that means, taht t3lib_db will never be used in DB processing, but ux_t3lib_db
Sure, your XCLASS can extend the base class, like ux_t3lib_db extends t3lib_db, so it works with inheritance of OOP, but if someone else would like to XCLASS t3lib_db too this will fail simply because TYPO3 will not find t3lib_db in it's scope, because it is already substituted with ux_t3lib_db. So, the only winner will be the one, who XCLASS'ed first.
You can read more here.
But, general note is, that XCLASS'ing is the last option you should try. Use hooks or signals/slots (last works in ExtBase only).
Answering your second question, I can say, that yes, you can do this in 4.5, but no - you shouldn't do that from 6.0.
Is there a simple, straightforward way to get an IType from a class name? I think there must be some static method somewhere. Basically, I'd like to do something like:
IType objectType = Somewhere.getType("java.lang.Object")
Does anybody know of something like this? I have been searching in vain.
Given an IProject, one can use the IJavaProject#findType methods, e.g.
IType objectType = project.findType("java.lang.Object");
Look at org.eclipse.jdt.core.search.SearchEngine. I haven't tried it myself, I'm usually using the ASTParser with the Resolve option on (that's when you parse a source), but it should do the trick.