mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/13904] Remove magic method from factory and allow short names
PHPBB3-13904
This commit is contained in:
parent
1af6f052d8
commit
8c2cbc0599
1 changed files with 3 additions and 24 deletions
|
@ -35,13 +35,15 @@ class factory
|
|||
*
|
||||
* @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
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
$service = false;
|
||||
|
||||
$name = (strpos($name, 'files.') === false) ? 'files.' . $name : $name;
|
||||
|
||||
try
|
||||
{
|
||||
$service = $this->container->get($name);
|
||||
|
@ -53,27 +55,4 @@ class factory
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue