(注册)锁定的服务，也可在注册后锁定,防止 getNew() 强制重载
@param  string $id description
@param $definition
@param $share
@return $this
@throws \Inhere\Exceptions\DependencyResolutionException
@throws \InvalidArgumentException
960245
public function lock(string $id, $definition, $share = false)
    {
        return $this->set($id, $definition, [
            'shared' => $share,
            'locked' => true,
        ]);
    }
831110
public function shareUpdate($id)
    {
        return $this->send($this->getHttp()->post($this->url.'updates/'.$id.'/share.json'));
    }
784539
private function addServiceInstance($id, Definition $definition, $isSimpleInstance)
    {
        $class = $this->dumpValue($definition->getClass());

        if (0 === strpos($class, "'") && false === strpos($class, '$') && !preg_match('/^\'(?:\\\{2})?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
            throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
        }

        $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
        $instantiation = '';

        if (!$isProxyCandidate && $definition->isShared()) {
            $instantiation = "\$this->services['$id'] = ".($isSimpleInstance ? '' : '$instance');
        } elseif (!$isSimpleInstance) {
            $instantiation = '$instance';
        }

        $return = '';
        if ($isSimpleInstance) {
            $return = 'return ';
        } else {
            $instantiation .= ' = ';
        }

        $code = $this->addNewInstance($definition, $return, $instantiation, $id);

        if (!$isSimpleInstance) {
            $code .= "\n";
        }

        return $code;
    }
89994
public function editGist(string $id, string $description = '', array $files = [], string $content = '',
                             string $filename = ''): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id), Request::METHOD_PATCH, [
            'description' => $description,
            'files'       => $files,
            'content'     => $content,
            'filename'    => $filename
        ]);
    }
379575
public function getNew(string $id)
    {
        $definition = $this->raw($id);

        if (is_callable($definition)) {
            $service = call_user_func($definition, $this);
        } else {
            $service = $definition;
        }

        if (isset($this->extensionQueues[$id])) {
            $service = $this->extensionQueues[$id]->getService($service);
        }

        return $service;
    }
103332
public function haveServiceInDi($name, $definition, $shared = false)
    {
        return $this->addServiceToContainer($name, $definition, $shared);
    }
699380
private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition)
    {
        // Never use abstract services
        if ($definition->isAbstract()) {
            return;
        }

        if ('' === $id || '.' === $id[0] || $definition->isDeprecated() || !$reflectionClass = $container->getReflectionClass($definition->getClass(), false)) {
            return;
        }

        foreach ($reflectionClass->getInterfaces() as $reflectionInterface) {
            $this->set($reflectionInterface->name, $id);
        }

        do {
            $this->set($reflectionClass->name, $id);
        } while ($reflectionClass = $reflectionClass->getParentClass());
    }
1218458
public function setSharedByDefault($sharedByDefault)
    {
        if ($this->locked) {
            throw new Exception\LockedContainerException();
        }

        $this->sharedByDefault = (bool) $sharedByDefault;

        return $this;
    }
791910
public function hasInitialized($id, $args = null) {
		if (isset($args[2])) {
			$args = func_get_args();
			array_shift($args);
		}
		
		return $this->getDefinition($id)->hasInitialized($args);
	}
706343
public function delete(EntityDefinition $definition, array $ids, WriteContext $writeContext): DeleteResult
    {
        $this->validateWriteInput($ids);

        $commandQueue = new WriteCommandQueue();

        $fields = $definition->getPrimaryKeys();

        $resolved = [];
        foreach ($ids as $raw) {
            $mapped = [];

            /** @var Field $field */
            foreach ($fields as $field) {
                if (!($field instanceof StorageAware)) {
                    continue;
                }

                if (array_key_exists($field->getPropertyName(), $raw)) {
                    $mapped[$field->getStorageName()] = $raw[$field->getPropertyName()];
                    continue;
                }

                if ($field instanceof ReferenceVersionField) {
                    $mapped[$field->getStorageName()] = $writeContext->getContext()->getVersionId();
                    continue;
                }

                if ($field instanceof VersionField) {
                    $mapped[$field->getStorageName()] = $writeContext->getContext()->getVersionId();
                    continue;
                }

                $fieldKeys = $fields
                    ->filter(function (Field $field) {
                        return !$field instanceof VersionField && !$field instanceof ReferenceVersionField;
                    })
                    ->map(function (Field $field) {
                        return $field->getPropertyName();
                    });

                throw new IncompletePrimaryKeyException($fieldKeys);
            }

            $resolved[] = $mapped;
        }

        if (!$definition instanceof MappingEntityDefinition) {
            $restrictions = $this->foreignKeyResolver->getAffectedDeleteRestrictions($definition, $resolved, $writeContext->getContext());

            if (!empty($restrictions)) {
                $restrictions = array_map(function ($restriction) {
                    return new RestrictDeleteViolation($restriction['pk'], $restriction['restrictions']);
                }, $restrictions);

                throw new RestrictDeleteViolationException($definition, $restrictions, $this->registry);
            }
        }

        $cascades = [];
        if (!$definition instanceof MappingEntityDefinition) {
            $cascadeDeletes = $this->foreignKeyResolver->getAffectedDeletes($definition, $resolved, $writeContext->getContext());

            $cascadeDeletes = array_column($cascadeDeletes, 'restrictions');
            foreach ($cascadeDeletes as $cascadeDelete) {
                $cascades = array_merge_recursive($cascades, $cascadeDelete);
            }

            foreach ($cascades as $affectedDefinitionClass => &$cascade) {
                $affectedDefinition = $this->registry->get($affectedDefinitionClass);

                $cascade = array_map(function ($key) use ($affectedDefinition) {
                    $payload = $key;

                    if (!\is_array($key)) {
                        $payload = ['id' => $key];
                    }

                    return new EntityWriteResult($key, $payload, $affectedDefinition, null);
                }, $cascade);
            }
        }

        $skipped = [];
        foreach ($resolved as $mapped) {
            $mappedBytes = array_map(function ($id) {
                return Uuid::fromHexToBytes($id);
            }, $mapped);

            $existence = $this->gateway->getExistence($definition, $mappedBytes, [], $commandQueue);

            if (!$existence->exists()) {
                $skipped[$definition->getClass()][] = new EntityWriteResult($mapped, $mapped, $definition, $existence);
                continue;
            }

            $commandQueue->add(
                $definition,
                new DeleteCommand(
                    $definition,
                    $mappedBytes,
                    $existence
                )
            );
        }

        $writeContext->setLanguages($this->languageLoader->loadLanguages());
        $identifiers = $this->getWriteResults($commandQueue);
        $this->gateway->execute($commandQueue->getCommandsInOrder(), $writeContext);

        return new DeleteResult(
            array_merge_recursive($identifiers, $cascades),
            $skipped
        );
    }
676953
public function share( $alias, $definition ) {
		$this->define( $alias, $definition );

		if ( is_array( $alias ) ) {
			$alias = key( $alias );
		}

		$this->shared[ $alias ] = true;

		return $this;
	}
1148117
protected function share($binding, $class, $params = [], $alias = false)
    {
        if (is_string($class)) {
            $closure = function (Application $app) use ($class, $params) {
                $method = method_exists($app, 'build') ? 'build' : 'makeWith';
                return $app->$method($class, $params);
            };
        } else {
            $closure = $class;
        }
        $this->app->singleton($binding, $closure);
//        $this->app[ $binding ] = $this->app->share($closure);
        if ($alias) {
            $this->app->alias($binding, $class);
        }
    }
970535
public function makeBlockShared($id)
    {
        $block = $this->find($id, true);
        $this->publish($block);

        // Duplicate some of the settings to the pointer
        $pointer = new PointerBlock();
        $pointer->setOwner($block->getOwner());
        $pointer->setParent($block->getParent());
        $pointer->setPosition($block->getPosition());
        $pointer->setSort($block->getSort());
        $pointer->setReference($block);
        $pointer->setDraft(true);

        // Detach and make shared
        $block->setShared(true);
        $block->setSharedName(sprintf('%s_%s', $block->getBlockType(), $block->getOwner()->getId()));
        $block->setSharedDisplayName(sprintf('%s from %s', $block->getBlockType(), $block->getOwnerName()));
        $block->setParent(null);
        $block->setOwner(null);
        $block->setPosition(null);
        $block->setSort(null);

        $this->save($block, false)->save($pointer);

        if ($block instanceof CompositeBlock) {
            $iterator = new \RecursiveIteratorIterator(
                new RecursiveBlockIterator($block->getChildren()),
                \RecursiveIteratorIterator::SELF_FIRST
            );

            foreach ($iterator as $child) {
                $child->setOwner(null);
                $this->publish($child);
                $this->save($child, false);
            }
        }

        return $pointer;
    }
705143
public function addDefinition(Definition $definition)
    {
        if ($this->hasDefinition($definition)) {
            throw new \InvalidArgumentException(sprintf('Definition "%s" allready exists.', $definition->getName()));
        }

        $this->definitions[$definition->getName()] = $definition;

        return $this;
    }
1176256
private function shareService(Definition $definition, $service, $id, array &$inlineServices)
    {
        $inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service;

        if (null !== $id && $definition->isShared()) {
            $this->services[$id] = $service;
            unset($this->loading[$id]);
        }
    }
1366544
private function checkDefinition($id, array $definition, $file)
    {
        if ($throw = $this->isLoadingInstanceof) {
            $keywords = self::$instanceofKeywords;
        } elseif ($throw = (isset($definition['resource']) || isset($definition['namespace']))) {
            $keywords = self::$prototypeKeywords;
        } else {
            $keywords = self::$serviceKeywords;
        }

        foreach ($definition as $key => $value) {
            if (!isset($keywords[$key])) {
                if ($throw) {
                    throw new InvalidArgumentException(sprintf('The configuration key "%s" is unsupported for definition "%s" in "%s". Allowed configuration keys are "%s".', $key, $id, $file, implode('", "', $keywords)));
                }

                @trigger_error(sprintf('The configuration key "%s" is unsupported for service definition "%s" in "%s". Allowed configuration keys are "%s". The YamlFileLoader object will raise an exception instead in Symfony 4.0 when detecting an unsupported service configuration key.', $key, $id, $file, implode('", "', $keywords)), E_USER_DEPRECATED);
            }
        }
    }
107128
public function delete_share_dataowner_sysaccount($shareid) {
        $shareid = (int) $shareid;
        $deleteshareparams = [
            'share_id' => $shareid
        ];
        $deleteshareresponse = $this->ocsclient->call('delete_share', $deleteshareparams);
        $xml = simplexml_load_string($deleteshareresponse);

        if (empty($xml->meta->statuscode) || $xml->meta->statuscode != 100 ) {
            notification::warning('You just shared a file with a access controlled link.
             However, the share between you and the systemaccount could not be deleted and is still present in your instance.');
        }
    }