本文整理汇总了PHP中Zend\ServiceManager\ServiceManager类的典型用法代码示例。如果您正苦于以下问题:PHP ServiceManager类的具体用法?PHP ServiceManager怎么用?PHP ServiceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
// Load the user-defined test configuration file, if it exists; otherwise, load
if (is_readable(__DIR__ . '/TestConfig.php')) {
$testConfig = (include __DIR__ . '/TestConfig.php');
} else {
$testConfig = (include __DIR__ . '/TestConfig.php.dist');
}
$zf2ModulePaths = array();
if (isset($testConfig['module_listener_options']['module_paths'])) {
$modulePaths = $testConfig['module_listener_options']['module_paths'];
foreach ($modulePaths as $modulePath) {
if ($path = static::findParentPath($modulePath)) {
$zf2ModulePaths[] = $path;
}
}
}
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
$zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
static::initAutoloader();
// use ModuleManager to load this module and it's dependencies
$baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
$config = ArrayUtils::merge($baseConfig, $testConfig);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
static::$config = $config;
}
示例2: testCreateService
public function testCreateService()
{
$sm = new ServiceManager();
$sm->setService('Acelaya\\Yaml\\View\\Renderer\\YamlRenderer', new YamlRenderer());
$service = $this->factory->createService($sm);
$this->assertInstanceOf('Acelaya\\Yaml\\View\\Strategy\\YamlStrategy', $service);
}
示例3: setUp
public function setUp()
{
$this->pluginManager = new RulePluginManager();
$serviceManager = new ServiceManager();
$serviceManager->setService('MvcTranslator', new Translator());
$this->pluginManager->setServiceLocator($serviceManager);
}
示例4: get
/**
* Init an instance of QueueWriter and configure an internal instance of ServiceManager
*
* @param array $config
* @return QueueWriterInterface
*/
public static function get(array $config)
{
$serviceConfig = (include dirname(dirname(dirname(__DIR__))) . '/config/services.config.php');
$services = new ServiceManager(new Config($serviceConfig['service_manager']));
$services->setService("Config", $config);
return $services->get('recommerce.queue-manager.queue-writer');
}
示例5: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
$this->serviceManager = Bootstrap::getServiceManager();
$this->doa = new Doa();
$this->doa->setId(1);
$program = new Program();
$program->setId(1);
$program->setProgram('Program');
$this->doa->setProgram($program);
$organisation = new Organisation();
$organisation->setId(1);
$organisation->setOrganisation("Organisation");
$this->doa->setOrganisation($organisation);
$this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
if (!$this->authorizeService->getAcl()->hasResource($this->doa)) {
$this->authorizeService->getAcl()->addResource($this->doa);
$this->authorizeService->getAcl()->allow([], $this->doa, []);
}
/**
* Add the resource on the fly
*/
if (!$this->authorizeService->getAcl()->hasResource(new Doa())) {
$this->authorizeService->getAcl()->addResource(new Doa());
}
$this->authorizeService->getAcl()->allow([], new Doa(), []);
$this->doaLink = $this->serviceManager->get('viewhelpermanager')->get('programDoaLink');
/**
* Bootstrap the application to have the other information available
*/
$application = $this->serviceManager->get('application');
$application->bootstrap();
}
示例6: configureServiceManager
public function configureServiceManager(\Zend\ServiceManager\ServiceManager $serviceManager)
{
$serviceManager->setFactory('A', function () {
return new A();
});
$serviceManager->setShared('A', false);
}
示例7: testCreateService
/**
* @covers Hermes\Api\ClientFactory::createService
*/
public function testCreateService()
{
$sm = new ServiceManager(new Config([]));
$sm->setService('config', ['hermes' => ['uri' => 'http://localhost:8000', 'depth' => 0, 'headers' => [], 'http_client' => ['options' => []]]]);
$client = $this->object->createService($sm);
$this->assertInstanceOf(Client::class, $client);
}
示例8: testInvoke
public function testInvoke()
{
$sm = new ServiceManager();
$sm->setService('config', ['recaptcha' => ['private_key' => 'foo']]);
$instance = $this->factory->__invoke($sm, '');
$this->assertInstanceOf(ReCaptcha::class, $instance);
}
示例9: wp_authenticate
public function wp_authenticate($hash, $password, ServiceManager $sm)
{
/** @var PasswordHash $wp_hasher */
$wp_hasher = $sm->get('wp_hasher');
$result = $wp_hasher->CheckPassword($password, $hash);
return $result;
}
示例10: getServiceLocator
public function getServiceLocator(array $config = array())
{
$serviceLocator = new ServiceManager();
$serviceLocator->setFactory('MQUtil\\Service\\ShortUrl', 'MQUtil\\Service\\ShortUrlFactory');
$serviceLocator->setService('config', $config);
return $serviceLocator;
}
示例11: init
public static function init()
{
if (is_readable(__DIR__ . '/config.php')) {
$testConfig = (include __DIR__ . '/config.php');
} else {
$testConfig = (include __DIR__ . '/config.php.dist');
}
$moduleName = pathinfo(realpath(dirname(__DIR__)), PATHINFO_BASENAME);
if (defined('MODULE_NAME')) {
$moduleName = MODULE_NAME;
}
$zf2ModulePaths = array(dirname(dirname(__DIR__)));
if ($path = static::findParentPath('vendor')) {
$modulePaths[] = $path;
}
if (($path = static::findParentPath('module')) !== $modulePaths[0]) {
$modulePaths[] = $path;
}
if (isset($additionalModulePaths)) {
$zf2ModulePaths = array_merge($modulePaths, $additionalModulePaths);
} else {
$zf2ModulePaths = $modulePaths;
}
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
static::initAutoloader();
$baseConfig = ['module_listener_options' => ['module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)], 'modules' => [$moduleName]];
$config = ArrayUtils::merge($baseConfig, $testConfig);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
}
示例12: setUp
/**
* Setup
*/
protected function setUp()
{
// get service manager
$this->serviceLocator = FileManagerBootstrap::getServiceLocator();
// get base user model instance
$this->userModel = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('User\\Model\\UserBase');
}
示例13: setUp
/**
* Setup
*/
protected function setUp()
{
// get service manager
$this->serviceLocator = ApplicationBootstrap::getServiceLocator();
// get base model instance
$this->model = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Application\\Model\\ApplicationBase');
}
示例14: testCreateService
public function testCreateService()
{
$this->sm->setService('Matryoshka\\Model\\Object\\ObjectManager', $this->om);
$this->pm->setServiceLocator($this->sm);
$object = $this->factory->createService($this->pm);
$this->assertInstanceOf('Matryoshka\\Module\\Controller\\Plugin\\Object', $object);
}
示例15: noticeOfCreation
/**
* Sends the mail to user with info about successfull registration
*
* @param \User\Entity\User $user
* @param string $password
* @param string $siteName
*/
public function noticeOfCreation(UserEntity $user, $password, $siteName, $actUrl = null)
{
$template = $this->storage->getByKey(2);
$serverUrl = $this->serviceManager->get('ViewHelperManager')->get('serverUrl');
$body = str_replace(array("[NAME]", "[SITENAME]", "[LOGINNAME]", "[PASSWORD]", "[SITEURL]", "[ACTIVATIONLINK]"), array($user->username, $siteName, $user->username, $password, $serverUrl(), sprintf('<a href="%s">%s</a>', $actUrl, $actUrl)), $template->emailBody);
return $this->send($user->username, $template->emailSubject, $body);
}