Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.3.0
-
Fix Version/s: 4.7
-
Component/s: None
-
Labels:None
-
Documentation Required?:None
Description
Drupal 8 is getting PSR-0 namespaces.
Namespaces:
Drupal\Core\..
Drupal\Component\..
Drupal\$modulename\..
Drupal\$themename\..
(they have a distinction of Core and Component, where Component is stuff that would be reusable outside of Drupal, and Core is what is only relevant to Drupal. As a consequence, obviously, extensions (modules, themes) cannot be named 'Core' or 'Component'.)
Directories:
core/lib/Drupal/Core/..
core/lib/Drupal/Component/..
$module_dir/lib/Drupal/$modulename/...
$module_dir/lib/Drupal/$modulename/SubNamespace/ClassName.php
(following PSR-0 spec)
Suggestion for CiviCRM:
Namespaces:
CiviCRM\Core\..
CiviCRM\Component\..
CiviCRM\$extension_name\...
Directories:
lib/CiviCRM/Core/..
lib/CiviCRM/Component/..
CRM/.. (for classes that are still with underscore instead of namespace)
The use case seems quite similar to Drupal 8.
We can start a slow transition, where we only use the PSR-0 for specific new stuff.