获取对象

@param string $name
类、接口名称、简要标识
@param bool $isSingleton
是否获取单例
@param int $instanceId
实现类别id
@return object
422489
public function make(string $name, bool $isSingleton = true, int $instanceId = 0)
    {
        // 获取标识
        if (isset($this->shortNameMap[$name])) {
            $funcKey = $this->shortNameMap[$name];
        } else {
            $funcKey = $this->getFuncKey($name, $instanceId);
        }
        // 非单例模式
        if (! $isSingleton) {
            return $this->getNewInstance($funcKey);
        }
        // 单例模式
        if (! isset($this->objectMap[$funcKey])) {
            $objectInstance = $this->getNewInstance($funcKey);
            $this->objectMap[$funcKey] = $objectInstance;
        }
        return $this->objectMap[$funcKey];
    }
1012352
public Instance getInstance(final String my_instance_id) {
    // [START instance_admin_client_get_instance]
    final String instanceId = my_instance_id;
    Instance ins = instanceAdminClient.getInstance(instanceId);
    // [END instance_admin_client_get_instance]
    return ins;
  }
1234757
public function createOrUpdate($id, $instanceName, $content)
    {
        Redis::set($this->getKey($id, $instanceName), $content);
    }
574097
public static function getInstanceById(string $instanceId): ExtendedCacheItemPoolInterface
    {
        if (isset(self::$instances[$instanceId])) {
            return self::$instances[$instanceId];
        }

        throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId));
    }
396246
public static function get_instance_info($instanceid) {
        global $DB, $CFG;

        require_once($CFG->libdir . '/enrollib.php');

        $params = self::validate_parameters(self::get_instance_info_parameters(), array('instanceid' => $instanceid));

        // Retrieve self enrolment plugin.
        $enrolplugin = enrol_get_plugin('self');
        if (empty($enrolplugin)) {
            throw new moodle_exception('invaliddata', 'error');
        }

        self::validate_context(context_system::instance());

        $enrolinstance = $DB->get_record('enrol', array('id' => $params['instanceid']), '*', MUST_EXIST);
        $course = $DB->get_record('course', array('id' => $enrolinstance->courseid), '*', MUST_EXIST);
        if (!core_course_category::can_view_course_info($course) && !can_access_course($course)) {
            throw new moodle_exception('coursehidden');
        }

        $instanceinfo = (array) $enrolplugin->get_enrol_info($enrolinstance);
        if (isset($instanceinfo['requiredparam']->enrolpassword)) {
            $instanceinfo['enrolpassword'] = $instanceinfo['requiredparam']->enrolpassword;
        }
        unset($instanceinfo->requiredparam);

        return $instanceinfo;
    }
862617
protected function getInstanceConfig($instanceId = 0)
    {
        /** @var \Rcm\Service\PluginManager $pluginManager */
        $pluginManager = $this->getServiceLocator()->get(
            'Rcm\Service\PluginManager'
        );

        $instanceConfig = [];

        $pluginName = $this->getRcmPluginName();

        if ($instanceId > 0) {
            try {
                $instanceConfig = $pluginManager->getInstanceConfig($instanceId);
            } catch (PluginInstanceNotFoundException $e) {
                // ignore error
            }
        }

        if (empty($instanceConfig)) {
            $instanceConfig = $pluginManager->getDefaultInstanceConfig(
                $pluginName
            );
        }

        return $instanceConfig;
    }
125159
static function get_instance_by_id( $id ) {
            return isset ( self::$_instances[ 'm_' . $id ] ) ?
                self::$_instances[ 'm_' . $id ] :
                false;
        }
1286661
public void bindEip(String eip, String instanceId, String instanceType) {
        this.bindEip(new BindEipRequest().withEip(eip).withInstanceId(instanceId).withInstanceType(instanceType));
    }
257518
public function singleton($name, $object)
    {
        if (IOC::hasSingleton($name)) {
            return IOC::singleton($name);
        } else {
            IOC::singleton($name, $object);
            return $object;
        }
    }
1251624
public function findByIdAndInstanceName($id, $instanceName)
    {
        $content = Redis::get($this->getKey($id, $instanceName));

        if ($content === null) {
            return;
        }

        return (object) [
            'id' => $id,
            'instance' => $instanceName,
            'content' => $content,
        ];
    }
976390
public static function instance($userid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_USER, $userid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_USER, 'instanceid' => $userid))) {
            if ($user = $DB->get_record('user', array('id' => $userid, 'deleted' => 0), 'id', $strictness)) {
                $record = context::insert_context_record(CONTEXT_USER, $user->id, '/'.SYSCONTEXTID, 0);
            }
        }

        if ($record) {
            $context = new context_user($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }
333812
public function get($instanceId)
    {
        $siteId = $this->getServiceLocator()->get(\Rcm\Service\CurrentSite::class)
            ->getSiteId();
        /** @var RcmUserService $rcmUserService */
        $rcmUserService = $this->serviceLocator->get(RcmUserService::class);

        /** @var ResourceName $resourceName */
        $resourceName = $this->getServiceLocator()->get(
            ResourceName::class
        );

        $allowed = $rcmUserService->isAllowed(
            $resourceName->get(ResourceName::RESOURCE_SITES, $siteId),
            'admin',
            \Rcm\Acl\ResourceProvider::class
        );

        if (!$allowed) {
            $this->getResponse()->setStatusCode(401);

            return $this->getResponse();
        }

        $routeMatch = $this->getEvent()->getRouteMatch();
        $pluginType = $routeMatch->getParam('pluginType');
        /**
         * @var $pluginMgr PluginManager
         */
        $pluginMgr = $this->getServiceLocator()
            ->get('Rcm\Service\PluginManager');
        $defaultInstanceCfg = $pluginMgr->getDefaultInstanceConfig($pluginType);
        if (!is_array($defaultInstanceCfg)) {
            return $this->notFoundAction();
        }

        if ($instanceId > 0) {
            try {
                $instanceConfig = $pluginMgr->getInstanceConfig($instanceId);
            } catch (PluginInstanceNotFoundException $e) {
                return $this->notFoundAction();
            }
        } else {
            $instanceConfig = $defaultInstanceCfg;
        }

        return new JsonModel(
            [
                'instanceConfig' => $instanceConfig,
                'defaultInstanceConfig' => $defaultInstanceCfg
            ]
        );
    }
579075
public static function create($config, $instanceOf = null)
    {
        // Closure check
        if (is_callable($config)) {
            return static::createFromCallable($config, $instanceOf);
        }

        // Get class from config
        $class = static::checkConfig($config, $instanceOf);

        // New object
        return new $class($config);
    }
502691
public static function doEscapeIdentifier($Identifier, $instance=null) {
		self::prepareInstance($instance);
		return self::$instances[$instance]->escapeIdentifier($Identifier);
	}
768512
public function getParameterForConstructor($instanceName, $index) {
		if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['value'])) {
			return $this->declaredInstances[$instanceName]['constructor'][$index]['value'];
		} else {
			return null;
		}
	}
781357
public function removeInstance($instanceName)
    {
        $curlInstance = $this->curlInstances[$instanceName];

        unset($this->curlInstances[$instanceName]);

        return $curlInstance;
    }
432499
static function instance( $id, $secondary_id, $network_level_or_blog_id = false ) {
            $key = $id . ':' . $secondary_id;

            if ( is_multisite() ) {
                if ( true === $network_level_or_blog_id ) {
                    $key .= ':ms';
                } else if ( is_numeric( $network_level_or_blog_id ) && $network_level_or_blog_id > 0 ) {
                    $key .= ":{$network_level_or_blog_id}";
                } else {
                    $network_level_or_blog_id = get_current_blog_id();

                    $key .= ":{$network_level_or_blog_id}";
                }
            }

			if ( ! isset( self::$_instances[ $key ] ) ) {
				self::$_instances[ $key ] = new FS_Key_Value_Storage( $id, $secondary_id, $network_level_or_blog_id );
			}

			return self::$_instances[ $key ];
		}