Project

General

Profile

Bug #87064

Updated by Coders.Care Extension Team over 5 years ago

While it is a good idea to convert public to protected properties to avoid manipulation from the outside, it will make access to these properties within hooks provided within the same class as these properties impossible. 

 Example taken from the Gridelements new item wizard hook: 

 Within the NewContentElementController there are 
 <pre><code class="php"> 
     /** 
      * @var array 
      */ 
     protected $deprecatedPublicProperties = [ 
         'id' => 'Using $id of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'sys_language' => 'Using $sys_language of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'R_URI' => 'Using $R_URI of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'colPos' => 'Using $colPos of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'uid_pid' => 'Using $uid_pid of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'modTSconfig' => 'Using $modTSconfig of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'doc' => 'Using $doc of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'content' => 'Using $content of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'access' => 'Using $access of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
         'config' => 'Using $config of NewContentElementController from the outside is discouraged as this variable is used for internal storage.', 
     ]; 
 </code></pre> 
 Now the whole class is handed over to hook objects via 
 <pre><code class="php"> 
 $hookObject->manipulateWizardItems($wizardItems, $this); 
 </code></pre> and then processed like this 
 <pre><code class="php"> 
 public function manipulateWizardItems(&$wizardItems, $parentObject) 
 </code></pre> 
 As soon as these properties are really deprecated with CMS 10, it won't be possible anymore to get $parentObject->id or $parentObject->colPos from within the hook, which is essential information while rendering the wizard items. 

 Solution: Since There should be at least getters for those properties, since the PublicPropertyDeprecationTrait is used quite a lot all over the core, we should make sure that properties which are handed over information does not have to hooks always 
 provide a getter to access their values while keeping them be secret, but just protected. 

Back