I'm Sorry, I feel a little nervous by writing here again after long time.

Replace '/' by '\' and PATH( HELPER_PATH | SERVICE_PATH )  by NAMESPACE( 
HELPER_NAMESPACE | SERVICE_NAMESPACE  ).


Sorry






 ---- En vie, 26 feb 2021 09:16:18 +0100 Manuel Canga <p...@manuelcanga.dev> 
escribió ----
 > Hello, another example with "factories method"[1]:
 > 
 > ```php
 > use MyProject\Framework;
 > 
 > abstract class AbstractController {
 >     private const HELPER_PATH = static::namespace.'/Helpers';
 >     private const SERVICE_PATH = static::namespace.'/Services';
 > 
 >      public function instanceHelper( string $helperClass ) {
 >             $helperClassName = self::HELPER_PATH."/{$helperClass}";
 > 
 >            return new $helperClassName();
 >     }
 > 
 >    public function instanceService( string $serviceClass )  {
 >             $serviceClassName = self::SERVICE_PATH."/{$serviceClass}";
 > 
 >            return new $serviceClassName();
 >    }
 > }
 > 
 > use MyProject\MyModule;
 > 
 > class Controller {
 >     public function __invoke() {
 >                  //......
 >        $date = $this->instanceHelper('Date');
 >               //...
 >     }
 > 
 > }
 > ```
 > 
 > [1]: https://en.wikipedia.org/wiki/Factory_method_pattern
 > 
 > Regards
 > --
 > Manuel Canga
 > 
 > Zend Certified PHP Engineer 
 > Websites: https://manuelcanga.dev | https://trasweb.net
 > Linkedin: https://es.linkedin.com/in/manuelcanga
 > 
 > -- 
 > PHP Internals - PHP Runtime Development Mailing List
 > To unsubscribe, visit: https://www.php.net/unsub.php
 > 
 > 

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to