[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE 8 */ 9 10 namespace Joomla\CMS\Helper; 11 12 use Joomla\Database\DatabaseAwareInterface; 13 use Joomla\Database\DatabaseAwareTrait; 14 15 // phpcs:disable PSR1.Files.SideEffects 16 \defined('_JEXEC') or die; 17 // phpcs:enable PSR1.Files.SideEffects 18 19 /** 20 * Namespace based implementation of the HelperFactoryInterface 21 * 22 * @since 4.0.0 23 */ 24 class HelperFactory implements HelperFactoryInterface 25 { 26 use DatabaseAwareTrait; 27 28 /** 29 * The extension namespace 30 * 31 * @var string 32 * 33 * @since 4.0.0 34 */ 35 private $namespace; 36 37 /** 38 * HelperFactory constructor. 39 * 40 * @param string $namespace The namespace 41 * 42 * @since 4.0.0 43 */ 44 public function __construct(string $namespace) 45 { 46 $this->namespace = $namespace; 47 } 48 49 /** 50 * Returns a helper instance for the given name. 51 * 52 * @param string $name The name 53 * @param array $config The config 54 * 55 * @return \stdClass 56 * 57 * @since 4.0.0 58 */ 59 public function getHelper(string $name, array $config = []) 60 { 61 $className = '\\' . trim($this->namespace, '\\') . '\\' . $name; 62 63 if (!class_exists($className)) { 64 return null; 65 } 66 67 $helper = new $className($config); 68 69 if ($helper instanceof DatabaseAwareInterface) { 70 $helper->setDatabase($this->getDatabase()); 71 } 72 73 return $helper; 74 } 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |