Reho Posted August 30, 2017 Share Posted August 30, 2017 I see in version 1.7.1.0 the Tab::getIdFromClassName function is deprecated. The comment shows above the deprecated function: available now in PrestaShopBundle\Entity\Repository\TabRepository::getOneIdByClassName($className) Can anybody explain how to use TabRepository::getOneIdByClassName in my custom module? I'm an absolute beginner in Symfony... (and also PS module dev) Thanks! Link to comment Share on other sites More sharing options...
bellini13 Posted August 30, 2017 Share Posted August 30, 2017 While the comment says it is deprecated, there is actually no deprecation here yet and you can continue to use the existing method. However if you want to learn how to use the new class/function, then you can always search the source code for TabRepository and see how Prestashop may be using it. TabRepository is located within the src folder, but part of the issue is that it does not contain a function named getOneIdByClassName, but rather it is called findOneIdByClassName Searching the source code for findOneIdByClassName, would result in 2 classes \src\PrestaShopBundle\Controller\Admin\ModuleController.php \src\Adapter\Module\Tab\ModuleTabRegister.php The issue right now is that PS v1.7 is a mix of symphony and smarty, and these new bundle classes are probably only being used by the Product page. Link to comment Share on other sites More sharing options...
Reho Posted August 30, 2017 Author Share Posted August 30, 2017 While the comment says it is deprecated, there is actually no deprecation here yet and you can continue to use the existing method. Ok, I've seen that its still working. But if you mark a function as deprecated it will be useless soon (if it still not) and the developer in my head says to not to use and try the offered alternative solution. However if you want to learn how to use the new class/function, then you can always search the source code for TabRepository and see how Prestashop may be using it. TabRepository is located within the src folder, but part of the issue is that it does not contain a function named getOneIdByClassName, but rather it is called findOneIdByClassName Searching the source code for findOneIdByClassName, would result in 2 classes \src\PrestaShopBundle\Controller\Admin\ModuleController.php \src\Adapter\Module\Tab\ModuleTabRegister.php The issue right now is that PS v1.7 is a mix of symphony and smarty, and these new bundle classes are probably only being used by the Product page. I still found the right function and the two suggested use of them, but in the first case they call some Symfony Container class to get the Tabrepository object and in the second case they got the TR object by the constructor. So I still don't know how to use the Symfony classes in module dev, but I'm warned old functions will be deprecated. Link to comment Share on other sites More sharing options...
bellini13 Posted August 31, 2017 Share Posted August 31, 2017 Ok, I've seen that its still working. But if you mark a function as deprecated it will be useless soon (if it still not) and the developer in my head says to not to use and try the offered alternative solution. Prestashop usually adds this code to deprecated functions, which would display a warning message in debug mode. It does not exist in the function with the comment only... Tools::displayAsDeprecated('Use Cart->getPackageShippingCost()'); Link to comment Share on other sites More sharing options...
Jems Khadgi Posted June 13, 2021 Share Posted June 13, 2021 For someone who might stumble into this thing. This answer might help. You could replace: Tab::getIdFromClassName() with PrestaShopBundle\Entity\Repository\TabRepository::findOneIdByClassName($className) Link to comment Share on other sites More sharing options...
leagris Posted December 29, 2021 Share Posted December 29, 2021 On 6/13/2021 at 9:14 AM, Jems Khadgi said: For someone who might stumble into this thing. This answer might help. You could replace: Tab::getIdFromClassName() with PrestaShopBundle\Entity\Repository\TabRepository::findOneIdByClassName($className) This is an illegal static call of an instance method: PrestaShopBundle\Entity\Repository\TabRepository::findOneIdByClassName($className) Quote Non-static method 'findOneIdByClassName' should not be called statically Inspection info: Reports static calls to dynamic class methods. Link to comment Share on other sites More sharing options...
Pedram Posted September 12, 2023 Share Posted September 12, 2023 On 12/29/2021 at 9:01 AM, leagris said: This is an illegal static call of an instance method: PrestaShopBundle\Entity\Repository\TabRepository::findOneIdByClassName($className) I know this is several years old but this was #1 result in google when I searched for what alternative I use for Tab::getIdFromClassName function in Presta 8. Since it might be fully removed in P8+ versions soon, might be a good time to replace it. but most search results and even in documentations i could not easily find a clear answer. This illegal static call just need you to make a instance from that class for it to fix, but I don't believe this is the correct thing to do. $tabRes = new TabRepository(); $tab_id = $tabRes->findOneIdByClassName("MyClassName"); after checking some more places including the Github, I found the correct method is to get the current instance of TabRepository instead of making a new one is the corect answer. So Instead of using Tab::getIdFromClassName in newer versions of Prestashop, we can use this code and avoid the deprecated error as well : SymfonyContainer::getInstance()->get('prestashop.core.admin.tab.repository')->findOneIdByClassName('MyClassName'); Link to comment Share on other sites More sharing options...
Yelish Posted September 22, 2023 Share Posted September 22, 2023 Hello, how are you? Is your question serious? I don't think so. This is a forum for programmers. A programmer can implement a class and give it any methods they want. You can give the class any method you desire. I don't understand this question. It's senseless. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now