This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:dev:284:registry [26.09.2023 04:17] – [Application of WbAdaptor] Manuela v.d.Decken | en:dev:284:registry [26.09.2023 07:14] (current) – [Changed identifiers] Manuela v.d.Decken | ||
---|---|---|---|
Line 8: | Line 8: | ||
Global constants (as well as global variables), used within classes, break up their clear encapsulation and can prevent the reusability of the code. See ' | Global constants (as well as global variables), used within classes, break up their clear encapsulation and can prevent the reusability of the code. See ' | ||
- | Global constants are, as has long been stated, from this version on deprecated, that is undesirable. See: [[en:dev: | + | Global constants are, as has long been stated, from this version on deprecated, that is undesirable. See: [[dev: |
Of course, discarding all previous constants without any replacement is clearly not a feasible approach. That's simply impossible. At least in the first step, the class ' | Of course, discarding all previous constants without any replacement is clearly not a feasible approach. That's simply impossible. At least in the first step, the class ' | ||
Line 27: | Line 27: | ||
^old constant | ^old constant | ||
- | |NEW |Db | + | |NEW |getDatabase() |
- | |NEW |Trans |the current translation object | + | |NEW |getTranslate() |
- | |NEW |App |the current application/ | + | |NEW |getApplication() |
+ | |NEW | ||
|NEW | |NEW | ||
|NEW | |NEW | ||
Line 69: | Line 70: | ||
__for all statements in common the following rules apply:__ | __for all statements in common the following rules apply:__ | ||
- | * As PATH_SEPERATOR only the slash** / ** is allowed. Adjustments can be made easily with\\ <php> $sPath = str_replace(' | + | * As PATH_SEPERATOR only the slash** / ** is allowed. Adjustments can be made easily with\\ <code> $sPath = str_replace(' |
* If the last element of a URL, Rel, Path-, or Dir-specified directory, the indication must terminate on a slash** / **.\\ | * If the last element of a URL, Rel, Path-, or Dir-specified directory, the indication must terminate on a slash** / **.\\ | ||
- | * To ensure that a directory path is terminated with a single slash** / **the short sequence is sufficient\\ <php> $sPath = rtrim($sPath, | + | * To ensure that a directory path is terminated with a single slash** / **the short sequence is sufficient\\ <code> $sPath = rtrim($sPath, |
- | * Leading slashes** / **are removed by\\ <php> $sPath = ltrim($sPath, | + | * Leading slashes** / **are removed by\\ <code> $sPath = ltrim($sPath, |
OLD => NEW example: | OLD => NEW example: | ||
Line 86: | Line 87: | ||
===== Application of WbAdaptor ===== | ===== Application of WbAdaptor ===== | ||
- | This class can be reached from anywhere. It is sufficient to import that only existing active instance of the class with\\ <php> $oReg = \bin\WbAdaptor:: | + | This class can be reached from anywhere. It is sufficient to import that only existing active instance of the class with\\ <code> $oReg = \bin\WbAdaptor:: |
But even better is the use of dependency injection, i.e. the transfer of the instance from outside to the function or class. | But even better is the use of dependency injection, i.e. the transfer of the instance from outside to the function or class. | ||
Line 92: | Line 93: | ||
Also the request of the individual values quite straightforward: | Also the request of the individual values quite straightforward: | ||
- | <php> echo $oReg-> | + | <code> echo $oReg-> |
Output: | Output: | ||