In older extensions or inherited Magento code, you may find direct calls to the ObjectManager. A regular expression makes it easy to search for those calls throughout the codebase.
|
1 |
grep -RInP 'ObjectManager\s*::\s*getInstance\s*\(' app/code |
For example, the search may find:
|
1 2 3 4 5 |
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productRepository = $objectManager->get( \Magento\Catalog\Api\ProductRepositoryInterface::class ); |
The regular expression…