In PHP frameworks like Symfony, how can inheritance limitations in built-in classes like sfAction be overcome to customize functionality without modifying core framework code?

In Symfony, the limitations of inheritance in built-in classes like sfAction can be overcome by using the event system provided by the framework. By creating a custom event listener or subscriber, you can customize the functionality of the built-in classes without directly modifying the core framework code. This allows you to extend and modify the behavior of the classes without breaking compatibility with future updates.

// CustomEventSubscriber.php

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;

class CustomEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            KernelEvents::CONTROLLER => 'onControllerEvent',
        ];
    }

    public function onControllerEvent(ControllerEvent $event)
    {
        // Custom logic to modify the behavior of sfAction
    }
}