Please, could anyone explain to me why some attributes and methods are private instead of protected?
Follow some examples:
private $backendConfig;
/** @var ContainerInterface */
private $container;
private function executeDynamicMethod($methodNamePattern, array $arguments = array())
It becomes boring to extend some classes and prevent custom code on vendor implementation IMO.
We probably didn't make it right, but we tried to follow Symfony's practice: make everything private by default and change to protected/public when it makes real sense.
So, which methods do you think we should make them public?
Ok, I was considering to do the following changes to get reusability when extending classes/services:
// ConfigManager class
private $backendConfig; // To protected
private $container; // To protected
private function processConfig(); // To protected
private function doProcessConfig($backendConfig); // To protected
// AdminController class
private function updateEntityProperty($entity, $property, $value); // To protected
private function executeDynamicMethod($methodNamePattern, array $arguments = array()); // To protected
private function redirectToBackendHomepage(); // To protected
In my case, I extends \JavierEguiluz\Bundle\EasyAdminBundle\Controller\AdminController to write custom get<EntityName>EntityFunction in and I try to call executeDynamicMethod in other custom function in this controller...
I have to copy/paste the executeDynamicMethod function :
In #1700 I've changed the admin controller methods from private to protected. The other change in ConfigManager is no longer needed because thanks to #1686 we have a better way to manipulate the configuration. Thanks!
Most helpful comment
Ok, I was considering to do the following changes to get reusability when extending classes/services: