Back to Registry class

Method getService

public string|object
getService
(string $key)
Get the service for a given key
Parameters
  • string $key The service key to look up
Returns
  • string|object
Since
  • 4.0.0
Class: Registry
Project: Joomla

Method getService - Source code

/**
 * Get the service for a given key
 *
 * @param   string  $key  The service key to look up
 *
 * @return  string|object
 *
 * @since   4.0.0
 */
public function getService(string $key)
{
    if (!$this->hasService($key)) {
        throw new \InvalidArgumentException("The '{$key}' service key is not registered.");
    }
    return $this->serviceMap[$key];
}