This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/3930' into develop
- Loading branch information
106 parents
3783159
+
34ed3ed
+
83f6472
+
db74e8c
+
7b75da1
+
bb4c48f
+
9fa3c05
+
139c0b1
+
a587eef
+
7a782f4
+
39cb2e2
+
31f8c80
+
a9b7779
+
de058f6
+
67b97f6
+
40d86d0
+
b5234cc
+
17b4e13
+
8af24aa
+
1a9df55
+
2c85c99
+
5557fac
+
fe78a35
+
f6430c3
+
6041a1e
+
86b9031
+
674bd75
+
67a1bfb
+
4d4dd8b
+
c655082
+
dbb18b2
+
97a9134
+
80367df
+
98d5255
+
7946c9f
+
ea67c13
+
44df0b2
+
38e090d
+
7af74e7
+
8b311b1
+
e2c2b94
+
51601cb
+
dcc1eaf
+
6f4b805
+
a30a64f
+
ee7347d
+
8b04bfe
+
b487f00
+
ecdfdf6
+
d8cde75
+
b7a33bb
+
65ecb58
+
571d938
+
625a786
+
6fe4efc
+
f94838d
+
76607e3
+
492076c
+
17b56b8
+
c5509fe
+
e0fa433
+
7d74e99
+
309136e
+
f1dd38a
+
7be533f
+
6a618c2
+
3a454e3
+
f66ca80
+
f1bebf2
+
850249d
+
674d7ba
+
597ff82
+
ae87c49
+
fb156fb
+
9c474de
+
1a75c72
+
47d1cd2
+
a937ea3
+
4219922
+
49e380f
+
5903df6
+
7a9d632
+
2ef7274
+
b606220
+
a09c5c7
+
21afa5c
+
8faa67f
+
1731915
+
efa1bb3
+
5576455
+
86d3ae8
+
de3fd70
+
398a3c4
+
5c56554
+
7ad896f
+
fa91c9b
+
1372a45
+
a0c8737
+
e368d53
+
462b1f7
+
79675fe
+
a8104b9
+
91ed9d0
+
b1d1358
+
18ca28d
+
5e733b5
commit c1290fa
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Log; | ||
|
||
use Zend\ServiceManager\AbstractFactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* Logger abstract service factory. | ||
* | ||
* Allow to configure multiple loggers for application. | ||
*/ | ||
class LoggerAbstractServiceFactory implements AbstractFactoryInterface | ||
{ | ||
/** | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @param string $name | ||
* @param string $requestedName | ||
* @return bool | ||
*/ | ||
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) | ||
{ | ||
$config = $serviceLocator->get('Config'); | ||
return isset($config['log'][$requestedName]); | ||
} | ||
|
||
/** | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @param string $name | ||
* @param string $requestedName | ||
* @return \Zend\Log\Logger | ||
*/ | ||
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) | ||
{ | ||
$config = $serviceLocator->get('Config'); | ||
return new Logger($config['log'][$requestedName]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Log | ||
*/ | ||
|
||
namespace ZendTest\Log; | ||
|
||
use Zend\ServiceManager\ServiceManager; | ||
use Zend\Mvc\Service\ServiceManagerConfig; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Log | ||
* @subpackage UnitTests | ||
* @group Zend_Log | ||
*/ | ||
class LoggerAbstractServiceFactoryTeset extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Zend\ServiceManager\ServiceLocatorInterface | ||
*/ | ||
private $serviceManager; | ||
|
||
/** | ||
* Set up LoggerAbstractServiceFactory and loggers configuration. | ||
* | ||
* @see PHPUnit_Framework_TestCase::setUp() | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->serviceManager = new ServiceManager(new ServiceManagerConfig(array( | ||
'abstract_factories' => array('Zend\Log\LoggerAbstractServiceFactory'), | ||
))); | ||
|
||
$this->serviceManager->setService('Config', array( | ||
'log' => array( | ||
'Application\Frontend\Logger' => array(), | ||
'Application\Backend\Logger' => array(), | ||
), | ||
)); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function providerValidLoggerService() | ||
{ | ||
return array( | ||
array('Application\Frontend\Logger'), | ||
array('Application\Backend\Logger'), | ||
); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function providerInvalidLoggerService() | ||
{ | ||
return array( | ||
array('Application\Unknown\Logger'), | ||
); | ||
} | ||
|
||
/** | ||
* @param string $service | ||
* @dataProvider providerValidLoggerService | ||
*/ | ||
public function testValidLoggerService($service) | ||
{ | ||
$actual = $this->serviceManager->get($service); | ||
$this->assertInstanceOf('Zend\Log\Logger', $actual); | ||
} | ||
|
||
/** | ||
* @param string $service | ||
* @dataProvider providerInvalidLoggerService | ||
* @expectedException \Zend\ServiceManager\Exception\ServiceNotFoundException | ||
*/ | ||
public function testInvalidLoggerService($service) | ||
{ | ||
$actual = $this->serviceManager->get($service); | ||
} | ||
} |