当前位置: 首页>>代码示例>>PHP>>正文


PHP ServiceFactory::getInstance方法代码示例

本文整理汇总了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;
 }
开发者ID:edefine,项目名称:simple,代码行数:9,代码来源:AbstractController.php

示例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);
     }
 }
开发者ID:edefine,项目名称:simple,代码行数:10,代码来源:UserFixture.php

示例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);
 }
开发者ID:edefine,项目名称:framework,代码行数:12,代码来源:Bootstrap.php

示例4: getServiceFactory

 /**
  * @return \ServiceFactory
  */
 protected function getServiceFactory()
 {
     return \ServiceFactory::getInstance();
 }
开发者ID:edefine,项目名称:framework,代码行数:7,代码来源:AbstractController.php


注:本文中的ServiceFactory::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。