本文整理汇总了PHP中ServiceFactory::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceFactory::getInstance方法的具体用法?PHP ServiceFactory::getInstance怎么用?PHP ServiceFactory::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceFactory
的用法示例。
在下文中一共展示了ServiceFactory::getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
protected function getUser()
{
$userId = $this->getSession()->get('userId');
if (!$userId) {
return null;
}
$user = \ServiceFactory::getInstance()->getUserRepository()->findOneById($userId);
return $user;
}
示例2: load
public function load()
{
$manager = \ServiceFactory::getInstance()->getEntityManager();
$admin = $this->createAdmin('FirstName', 'LastName', 'email@address.com', 'password');
$manager->save($admin);
for ($i = 1; $i <= self::USERS_TO_CREATE; $i++) {
$user = $this->createUser("FirstName {$i}", "LastName {$i}", "email{$i}@address.com", "password{$i}");
$manager->save($user);
}
}
示例3: run
public function run()
{
$serviceFactory = \ServiceFactory::getInstance();
$request = $serviceFactory->getRequest();
$serviceFactory->getDispatcher()->dispatch('kernel.request', new RequestEvent($request));
$controllerPath = sprintf('Controller\\%sController', $request->getControllerName());
$actionMethod = sprintf('%sAction', $request->getActionName());
$actionDispatcher = new ActionDispatcher();
$response = $actionDispatcher->dispatch($controllerPath, $actionMethod);
$responseHandler = new ResponseHandler();
$responseHandler->handle($response);
}
示例4: getServiceFactory
/**
* @return \ServiceFactory
*/
protected function getServiceFactory()
{
return \ServiceFactory::getInstance();
}