[ticket/13904] Remove magic method from factory and allow short names

PHPBB3-13904
This commit is contained in:
Marc Alexander 2015-06-01 13:51:05 +02:00
parent 1af6f052d8
commit 8c2cbc0599

View file

@ -35,13 +35,15 @@ class factory
* *
* @param string $name Service name * @param string $name Service name
* *
* @return object|false Requested service or false if service could not be * @return object|bool Requested service or false if service could not be
* found by the container * found by the container
*/ */
public function get($name) public function get($name)
{ {
$service = false; $service = false;
$name = (strpos($name, 'files.') === false) ? 'files.' . $name : $name;
try try
{ {
$service = $this->container->get($name); $service = $this->container->get($name);
@ -53,27 +55,4 @@ class factory
return $service; return $service;
} }
/**
* Magic function for handling get calls, e.g. get_fileupload() or
* get_filespec() and turning them into call for files. services like
* files.fileupload.
*
* @param string $name Name of called function
* @param mixed $arguments Possible supplied arguments
*
* @return object|false Requested service or false if service could not be
* found by the container
*/
public function __call($name, $arguments)
{
if (substr($name, 0, 4) === 'get_')
{
return $this->get('files.' . substr($name, 4));
}
else
{
return false;
}
}
} }