本文整理汇总了PHP中Zend\ServiceManager\ServiceLocatorInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocatorInterface类的具体用法?PHP ServiceLocatorInterface怎么用?PHP ServiceLocatorInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceLocatorInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createService
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
*
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$pluginManager = $serviceLocator->get('Phpro\\MailManager\\PluginManager');
$adapter = $serviceLocator->get('Phpro\\MailManager\\DefaultAdapter');
$instance = new Instance($pluginManager, $adapter);
return $instance;
}
示例2: createServiceWithName
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
$entity = substr($requestedName, 18);
$em = $serviceLocator->get('doctrine.entitymanager.orm_default');
$repository = $em->getRepository('Fulbis\\Core\\Entity\\' . $entity);
return $repository;
}
示例3: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('DbAdapter');
$hydrator = new HydratingResultSet(new ClassMethods(), new OrderItemEntity());
$tableGateway = new TableGateway('order_items', $dbAdapter, null, $hydrator);
return $tableGateway;
}
示例4: createService
/**
* Factory method.
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$service = new PicService();
$service->setEntityManager($serviceLocator->get('Doctrine\\ORM\\EntityManager'));
$service->setAuthService($serviceLocator->get('zfcuser_auth_service'));
return $service;
}
示例5: createService
public function createService(ServiceLocatorInterface $pluginManager)
{
$serviceManager = $pluginManager->getServiceLocator();
return new JSONErrorResponse($serviceManager);
// return
// $serviceManager->get('Application\Controller\Plugin\JSONErrorResponse');
}
示例6: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
try {
$pdo = $pdo = new \PDO($config['dbAdapterPostgre']['dsn'], $config['dbAdapterPostgre']['username'], $config['dbAdapterPostgre']['password']);
$sql = " \n SELECT \n REPLACE(TRIM(SUBSTRING(crypt(sf_private_key_value,gen_salt('xdes')),6,20)),'/','*') AS public_key\n FROM info_users a \n INNER JOIN sys_acl_roles sar ON sar.id = a.role_id AND sar.active=0 AND sar.deleted=0 \n WHERE a.username = :username \n AND a.password = :password \n AND a.deleted = 0 \n AND a.active = 0 \n Limit 1 \n \n ";
$statement = $pdo->prepare($sql);
$statement->bindValue(':username', $_POST['eposta'], \PDO::PARAM_STR);
$statement->bindValue(':password', md5($_POST['sifre']), \PDO::PARAM_STR);
//echo debugPDO($sql, $parameters);
$statement->execute();
$result = $statement->fetchAll(\PDO::FETCH_ASSOC);
$publicKey = true;
if (isset($result[0]['public_key'])) {
$publicKey = $result[0]['public_key'];
}
$errorInfo = $statement->errorInfo();
if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) {
throw new \PDOException($errorInfo[0]);
}
//return array("found" => true, "errorInfo" => $errorInfo, "resultSet" => $result);
return $publicKey;
} catch (\PDOException $e) {
$pdo->rollback();
return array("found" => false, "errorInfo" => $e->getMessage());
}
//return false;
}
示例7: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$dbOptions = $config['db'];
$db = new Adapter($dbOptions);
return $db;
}
示例8: initialize
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
{
if ($instance instanceof TagReaderAwareInterface) {
$tagReader = $serviceLocator->get('DocBlockTags\\TagReader');
$instance->setTagReader($tagReader);
}
}
示例9: createService
/**
* Create the DefaultAuthorizationListener
*
* @param ServiceLocatorInterface $services
* @return DefaultAuthorizationListener
*/
public function createService(ServiceLocatorInterface $services)
{
if (!$services->has('ZF\\MvcAuth\\Authorization\\AuthorizationInterface')) {
throw new ServiceNotCreatedException('Cannot create DefaultAuthorizationListener service; ' . 'no ZF\\MvcAuth\\Authorization\\AuthorizationInterface service available!');
}
return new DefaultAuthorizationListener($services->get('ZF\\MvcAuth\\Authorization\\AuthorizationInterface'));
}
示例10: createService
/**
* Create Service
*
* @param ServiceLocatorInterface $serviceLocator Zend Service Manager
*
* @return Stream
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$path = $config['rcmLogWriter']['logPath'];
$writer = new Stream($path);
return $writer;
}
示例11: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$em = $serviceLocator->get('doctrine.entitymanager.orm_default');
$options = $serviceLocator->get('BiBoBlogOptions');
$form = new \BiBoBlog\Form\BiBoBlogForm($em, $options);
return $form;
}
示例12: createService
/**
* Create and return the router
*
* Retrieves the "router" key of the Config service, and uses it
* to instantiate the router. Uses the TreeRouteStack implementation by
* default.
*
* @param ServiceLocatorInterface $serviceLocator
* @param string|null $cName
* @param string|null $rName
* @return \Zend\Mvc\Router\RouteStackInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
{
$config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
// Defaults
$routerClass = 'Zend\\Mvc\\Router\\Http\\TreeRouteStack';
$routerConfig = isset($config['router']) ? $config['router'] : array();
// Console environment?
if ($rName === 'ConsoleRouter' || $cName === 'router' && Console::isConsole()) {
// We are in a console, use console router defaults.
$routerClass = 'Zend\\Mvc\\Router\\Console\\SimpleRouteStack';
$routerConfig = isset($config['console']['router']) ? $config['console']['router'] : array();
}
// Obtain the configured router class, if any
if (isset($routerConfig['router_class']) && class_exists($routerConfig['router_class'])) {
$routerClass = $routerConfig['router_class'];
}
// Inject the route plugins
if (!isset($routerConfig['route_plugins'])) {
$routePluginManager = $serviceLocator->get('RoutePluginManager');
$routerConfig['route_plugins'] = $routePluginManager;
}
// Obtain an instance
$factory = sprintf('%s::factory', $routerClass);
return call_user_func($factory, $routerConfig);
}
示例13: createService
/**
* Creates a {@link SocialProfilesFieldset}
*
* Uses config from the config key [form_element_config][attach_social_profiles_fieldset]
* to configure fetch_url, preview_url and name or uses the defaults:
* - fetch_url: Route named "auth-social-profiles" with the suffix "?network=%s"
* - preview_url: Route named "lang/applications/detail" with the suffix "?action=social-profile&network=%s"
* - name: "social_profiles"
*
* @param ServiceLocatorInterface $serviceLocator
* @return SocialProfilesFieldset
* @see \Zend\ServiceManager\FactoryInterface::createService()
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
/* @var $serviceLocator \Zend\Form\FormElementManager
* @var $router \Zend\Mvc\Router\RouteStackInterface */
$services = $serviceLocator->getServiceLocator();
$router = $services->get('Router');
$config = $services->get('Config');
$options = isset($config['form_element_config']['attach_social_profiles_fieldset']) ? $config['form_element_config']['attach_social_profiles_fieldset'] : array();
if (!isset($options['fetch_url'])) {
$options['fetch_url'] = $router->assemble(array('action' => 'fetch'), array('name' => 'auth-social-profiles')) . '?network=%s';
}
if (!isset($options['preview_url'])) {
$options['preview_url'] = $router->assemble(array('id' => 'null'), array('name' => 'lang/applications/detail'), true) . '?action=social-profile&network=%s';
}
if (isset($options['name'])) {
$name = $options['name'];
unset($options['name']);
} else {
$name = 'social_profiles';
}
$options['is_disable_capable'] = false;
$options['is_disable_elements_capable'] = false;
$fieldset = new SocialProfilesFieldset($name, $options);
return $fieldset;
}
示例14: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
/** @var \Detail\Apigility\View\JsonRenderer $renderer */
$renderer = $serviceLocator->get('Detail\\Apigility\\View\\JsonRenderer');
$strategy = new JsonStrategy($renderer);
return $strategy;
}
示例15: createService
/**
* Create and return a view manager based on detected environment
*
* @param ServiceLocatorInterface $serviceLocator
* @return ConsoleViewManager|HttpViewManager
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
if (Console::isConsole()) {
return $serviceLocator->get('ConsoleViewManager');
}
return $serviceLocator->get('HttpViewManager');
}