[TYPO3-core] Creating aliases with the "use" operator

Jigal van Hemert jigal.van.hemert at typo3.org
Fri Oct 12 22:54:45 CEST 2012


Hi,

On 12-10-2012 22:14, Steffen Müller wrote:
> There are other cases, where I have different namespaces:
>
> TYPO3\CMS\Core\Log
> TYPO3\CMS\Core\Log\Writer
> TYPO3\CMS\Core\Log\Processor
>
> All of them are part of the Logging API.
>
> How to alias TYPO3\CMS\Core\Log\Writer\FileWriter within
> TYPO3\CMS\Core\Log\Logger?

use TYPO3\CMS\Core\Log\Writer;
is the same as
use TYPO3\CMS\Core\Log\Writer as Writer;

As the last part of all these namespaces differs there is no need to 
explicitly set an alias:

namespace TYPO3\CMS\Core\Log\Logger;
use TYPO3\CMS\Core\Log\Writer\FileWriter;

class MyClass {

   function MyFunction () {
     // calls TYPO3\CMS\Core\Log\Writer\FileWriter::writeLogFile()
     FileWriter::writeLogFile($somedata);
   }
}

-- 
Jigal van Hemert
TYPO3 CMS Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-team-core mailing list