Wallogit.com
2017 © Pedro Peláez
Small easy extbase object instantiation
This package provides a mixin (read: trait) that lets you bestow the power of self-instantiation (using TYPO3
conventional mechanisms) to your classes. Add this mixin to any class to make it instantiable using the Extbase
ObjectManager with ease., (*1)
Once you've mixed the trait into your class, you can call MyClass::get() to get an instance of the class., (*2)
/**
* Class MyClass
*/
class MyClass
{
use \Castiron\ExtbaseInstantiable\Traits\ExtbaseInstantiable;
/**
* Some public interface
*/
public function execute()
{
// yadda yadda whatever
}
}
/**
* Instantiate (with ObjectManager) and call a public method.
*/
MyClass::get()->execute();
A couple of reasons why this is handy:
- It makes instantiating your class in TYPO3-world easy-peasy (vs GeneralUtility::makeInstance or ObjectManager::get called directly)
- It uses ObjectManager::get under the hood, so automatic dependency injection works if you use annotations like @inject, (*3)
SingletonInterface?Yes! It's using normal TYPO3 object instantiation under the hood, so all that weirdo magic will work., (*4)
composer require castiron/typo3-extbaseinstantiable