diff options
author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-09-16 11:55:13 +0200 |
---|---|---|
committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-09-16 11:55:13 +0200 |
commit | a562fea2306c8ba5b47a161568bea5fbe2ffd19f (patch) | |
tree | fcab88a3a5dd5f05c77934eef0983793f2e2bd6a /phpBB/phpbb/files/factory.php | |
parent | d4a47409f7da09790f38d3418401cbe34f8c3703 (diff) | |
parent | 6651c1d8f4aead15f4750989670f75721390ee21 (diff) | |
download | forums-a562fea2306c8ba5b47a161568bea5fbe2ffd19f.tar forums-a562fea2306c8ba5b47a161568bea5fbe2ffd19f.tar.gz forums-a562fea2306c8ba5b47a161568bea5fbe2ffd19f.tar.bz2 forums-a562fea2306c8ba5b47a161568bea5fbe2ffd19f.tar.xz forums-a562fea2306c8ba5b47a161568bea5fbe2ffd19f.zip |
Merge pull request #3727 from marc1706/ticket/13904
[ticket/13904] Refactor attachments functions into service
* marc1706/ticket/13904: (66 commits)
[ticket/13904] Use filespec's get_filesize instead of calling filesize()
[ticket/13904] Set properties to protected where possible in filespec
[ticket/13904] Fix tests after changes to factory
[ticket/13904] Minor coding style fixes
[ticket/13904] Add language entries for error messages in upload class
[ticket/13904] Modify files for updated fast-image-size library
[ticket/13904] Update composer.lock
[ticket/13904] Improve code coverage
[ticket/13904] Add unit tests for local upload type
[ticket/13904] Minor coding style fixes
[ticket/13904] Improve test coverage of base upload type class
[ticket/13904] Improve test coverage of remote upload type
[ticket/13904] Improve test coverage of form upload type
[ticket/13904] Improve test coverage of filespec class
[ticket/13904] Add back tests for retrieving floats
[ticket/13904] Use ini_get() wrapper in file upload types
[ticket/13904] Modify files for changes in ini wrapper
[ticket/13904] Add bantu/ini-get-wrapper to composer.json
[ticket/13904] Switch around constructor arguments
[ticket/13904] Use \phpbb\php\ini class for ini_get()
...
Diffstat (limited to 'phpBB/phpbb/files/factory.php')
-rw-r--r-- | phpBB/phpbb/files/factory.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/phpBB/phpbb/files/factory.php b/phpBB/phpbb/files/factory.php new file mode 100644 index 0000000000..84b7cc9449 --- /dev/null +++ b/phpBB/phpbb/files/factory.php @@ -0,0 +1,58 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\files; + +class factory +{ + /** + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + private $container; + + /** + * Constructor + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + */ + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container) + { + $this->container = $container; + } + + /** + * Get files service + * + * @param string $name Service name + * + * @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, '.') === false) ? 'files.' . $name : $name; + + try + { + $service = $this->container->get($name); + } + catch (\Exception $e) + { + // do nothing + } + + return $service; + } +} |