當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ServiceFactory::create方法代碼示例

本文整理匯總了PHP中ServiceFactory::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP ServiceFactory::create方法的具體用法?PHP ServiceFactory::create怎麽用?PHP ServiceFactory::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ServiceFactory的用法示例。


在下文中一共展示了ServiceFactory::create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createService

 /**
  * @param string $id
  * @return mixed
  * @throws CircularDependencyException
  */
 private function createService($id)
 {
     if (isset($this->servicesCreating[$id])) {
         $msg = 'Circular dependency: ' . implode(' => ', array_keys($this->servicesCreating)) . " => {$id}";
         throw new CircularDependencyException($msg);
     }
     $this->servicesCreating[$id] = true;
     $service = $this->factory->create($id, $this);
     unset($this->servicesCreating[$id]);
     $this->repository->add($id, $service);
     return $service;
 }
開發者ID:freyr,項目名稱:envelope,代碼行數:17,代碼來源:Container.php

示例2: get

 /**
  * Gets the instance via lazy initialization (created on first usage)
  *
  * @param $id
  *
  * @throws CircularDependencyException
  *
  * @return a registered service
  */
 public function get($id)
 {
     $service = $this->repository->get($id);
     if (is_null($service)) {
         if (isset($this->servicesCreating[$id])) {
             $msg = 'Circular dependency detected: ' . implode(' => ', array_keys($this->servicesCreating)) . " => {$id}";
             throw new CircularDependencyException($msg);
         }
         // remmember ids called
         $this->servicesCreating[$id] = true;
         // pass the container to force only one instantiation per class
         $service = $this->factory->create($id, $this);
         unset($this->servicesCreating[$id]);
         $this->repository->add($id, $service);
     }
     return $service;
 }
開發者ID:leo009394,項目名稱:syringe,代碼行數:26,代碼來源:Container.php

示例3: getById

 /**
  * Load data by given Identity
  *
  * @param string $serviceId
  * @return Service
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function getById($serviceId)
 {
     $service = $this->serviceFactory->create();
     $this->resource->load($service, $serviceId);
     if (!$service->getId()) {
         throw new NoSuchEntityException(__('Item with id "%1" does not exist.', $serviceId));
     }
     return $service;
 }
開發者ID:swissup,項目名稱:email,代碼行數:16,代碼來源:ServiceRepository.php

示例4: create

 /**
  * Creates the appropriate mapper service for the current environment.
  *
  * @param string $mapperClass the class to instantiate; overrides the current configuration.
  * @return Social_IdMappingService
  */
 public static function create($mapperClass = null)
 {
     return ServiceFactory::create('Social_IdMappingService', self::DEFAULT_MAPPING_SERVICE, $mapperClass);
 }
開發者ID:jkinner,項目名稱:ringside,代碼行數:10,代碼來源:IdMappingService.php


注:本文中的ServiceFactory::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。