当前位置: 首页>>代码示例>>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;未经允许,请勿转载。