@param $instance

@return array

@throws \Exception
506399
public function getConfiguration($instance)
    {
        $request                = $this->requestStack->getCurrentRequest();
        $efParameters           = $this->parameters;
        $parameters             = $efParameters['instances'][$instance];
        $options                = array();
        $options['corsSupport'] = $parameters['cors_support'];
        $options['debug']       = $parameters['connector']['debug'];
        $options['bind']        = $parameters['connector']['binds'];
        $options['plugin']      = $parameters['connector']['plugins'];
        $options['roots']       = array();

        foreach ($parameters['connector']['roots'] as $parameter) {
            $path              = $parameter['path'];
            $homeFolder        = $request->attributes->get('homeFolder');
            $pathAndHomeFolder = $homeFolder ? sprintf('%s/%s', $path, $homeFolder) : $path;

            if ($parameter['flysystem']['enabled']) {
                if ($parameter['flysystem']['filesystem']) {
                    $serviceName = $parameter['flysystem']['filesystem'];
                    $filesystem  = $this->getFlysystemFilesystem($serviceName);
                } else {
                    $adapter     = $parameter['flysystem']['type']; // ftp ex.
                    $serviceName = $parameter['flysystem']['adapter_service'];
                    $opt         = $parameter['flysystem']['options'];
                    $filesystem  = $this->configureFlysystem($opt, $adapter, $serviceName);
                }
            }
            $driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : null;

            $driverOptions = array(
                'driver'            => $parameter['driver'],
                'service'           => $driver,
                'glideURL'          => $parameter['glide_url'],
                'glideKey'          => $parameter['glide_key'],
                'plugin'            => $parameter['plugins'],
                'path'              => $pathAndHomeFolder,
                'startPath'         => $parameter['start_path'],
                'encoding'          => $parameter['encoding'],
                'URL'               => $this->getURL($parameter, $request, $homeFolder, $path),
                'alias'             => $parameter['alias'],
                'mimeDetect'        => $parameter['mime_detect'],
                'mimefile'          => $parameter['mimefile'],
                'imgLib'            => $parameter['img_lib'],
                'tmbPath'           => $parameter['tmb_path'],
                'tmbPathMode'       => $parameter['tmb_path_mode'],
                'tmbURL'            => $parameter['tmb_url'],
                'tmbSize'           => $parameter['tmb_size'],
                'tmbCrop'           => $parameter['tmb_crop'],
                'tmbBgColor'        => $parameter['tmb_bg_color'],
                'copyOverwrite'     => $parameter['copy_overwrite'],
                'copyJoin'          => $parameter['copy_join'],
                'copyFrom'          => $parameter['copy_from'],
                'copyTo'            => $parameter['copy_to'],
                'uploadOverwrite'   => $parameter['upload_overwrite'],
                'uploadAllow'       => $parameter['upload_allow'],
                'uploadDeny'        => $parameter['upload_deny'],
                'uploadMaxSize'     => $parameter['upload_max_size'],
                'defaults'          => $parameter['defaults'],
                'attributes'        => $parameter['attributes'],
                'acceptedName'      => $parameter['accepted_name'],
                'disabled'          => $parameter['disabled_commands'],
                'treeDeep'          => $parameter['tree_deep'],
                'checkSubfolders'   => $parameter['check_subfolders'],
                'separator'         => $parameter['separator'],
                'timeFormat'        => $parameter['time_format'],
                'archiveMimes'      => $parameter['archive_mimes'],
                'archivers'         => $parameter['archivers'],
                'fileMode'          => $parameter['fileMode'],
            );

            if ($parameter['volume_id'] > 0) {
                $driverOptions['id'] = $parameter['volume_id'];
            }

            if (!$parameter['show_hidden']) {
                $driverOptions['accessControl'] = array($this, 'access');
            }

            if ($parameter['security_voter']) {
                /** @var ElfinderSecurityInterface $voter */
                $voter = $this->container->get($parameter['security_voter']);

                $driverOptions['disabled'] = $this->parseSecurityConfiguration($voter);
            }

            if ('Flysystem' == $parameter['driver']) {
                $driverOptions['filesystem'] = $filesystem;
            }
            $options['roots'][] = array_merge($driverOptions, $this->configureDriver($parameter));
        }

        return $options;
    }
1051520
public function getOwnerComponents($instanceName) {
		$instancesList = array();

		foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) {
			if (isset($instanceDesc['fieldBinds'])) {
				foreach ($instanceDesc['fieldBinds'] as $declaredBindProperty) {
					if (is_array($declaredBindProperty)) {
						if (array_search($instanceName, $declaredBindProperty) !== false) {
							$instancesList[$scannedInstance] = $scannedInstance;
							break;
						}
					} elseif ($declaredBindProperty == $instanceName) {
						$instancesList[$scannedInstance] = $scannedInstance;
					}
				}
			}
		}

		foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) {
			if (isset($instanceDesc['setterBinds'])) {
				foreach ($instanceDesc['setterBinds'] as $declaredBindProperty) {
					if (is_array($declaredBindProperty)) {
						if (array_search($instanceName, $declaredBindProperty) !== false) {
							$instancesList[$scannedInstance] = $scannedInstance;
							break;
						}
					} elseif ($declaredBindProperty == $instanceName) {
						$instancesList[$scannedInstance] = $scannedInstance;
					}
				}
			}
		}
		
		foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) {
			if (isset($instanceDesc['constructor'])) {
				foreach ($instanceDesc['constructor'] as $declaredConstructorProperty) {
					if ($declaredConstructorProperty['parametertype']=='object') {
						$value = $declaredConstructorProperty['value'];
						if (is_array($value)) {
							if (array_search($instanceName, $value) !== false) {
								$instancesList[$scannedInstance] = $scannedInstance;
								break;
							}
						} elseif ($value == $instanceName) {
							$instancesList[$scannedInstance] = $scannedInstance;
						}
					}
				}
			}
		}

		return $instancesList;

	}
785529
public static function getPrimitiveTypeOf($instance)
    {
        $phpType = gettype($instance);

        if (isset(self::$phpToJson[$phpType])) {
            return self::$phpToJson[$phpType];
        }

        throw new UnsupportedTypeException($phpType);
    }
1095064
function getImplementations ($instance){

		$rc = new ReflectionClass(get_class($instance));
		$interfaces = $rc->getInterfaces();
		$i = array();
		foreach($interfaces as $name => $crap){
			$i[]=$name;
		}
		return $i;
	}
947582
protected function convertExceptionToArray(Exception $e)
    {
        return $this->container->make('config')->get('app.debug') ? [
            'message' => $e->getMessage(),
            'exception' => get_class($e),
            'file' => $e->getFile(),
            'line' => $e->getLine(),
            'trace' => collect($e->getTrace())->map(function ($trace) {
                return Arr::except($trace, ['args']);
            })->all(),
        ] : [
            'message' => $this->isServiceException($e) ? $e->getMessage() : 'Server Error',
        ];
    }
200786
public static function setInstance($instance)
    {
        if ($instance instanceof self) {
            self::$instance = $instance;
        } elseif (is_array($instance)) {
            self::$instance = new self($instance);
        } else {
            $message = 'Argument 1 passed to Storage::setInstance must be '.
                'an instance of go\DB\DB or array, '.gettype($instance).' given';
            trigger_error($message, E_USER_ERROR);
        }
        return self::$instance;
    }
553265
public static function &getInstance( $instance = null )
	{
		if ( parent::hasInstance() )
		{
			return parent::getInstance();
		}

		$instance = parent::getInstance( new self() );
		$instance->fromFile();
		return $instance;
	}
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,
        ];
    }
772599
public function convert(\Exception $ex)
    {
        $exceptions = array();

        do {
            $exceptions[] = $this->convertException($ex);
        } while (null !== $ex = $ex->getPrevious());

        return $exceptions;
    }
1341208
public function get_instance_name($instance) {
        global $DB;

        if (empty($instance->name)) {
            if (!empty($instance->roleid) and $role = $DB->get_record('role', array('id'=>$instance->roleid))) {
                $role = ' (' . role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING)) . ')';
            } else {
                $role = '';
            }
            $enrol = $this->get_name();
            return get_string('pluginname', 'enrol_'.$enrol) . $role;
        } else {
            return format_string($instance->name);
        }
    }
1347714
protected function getServiceInfo($instance = null)
    {
        $file = $this->runDir . 'service-info.php';
        $info = is_file($file) ? include($file) : [];
        return $instance ? fnGet($info, $instance, []) : $info;
    }
988174
private function findInstanceByCallbackType($instanceName) {
		// Note: we execute the code in another thread. Always.
		// This prevent crashing the main thread.
		try {
			$fullyQualifiedClassName = MoufReflectionProxy::getReturnTypeFromCode($this->declaredInstances[$instanceName]["code"], $this->getScope() == self::SCOPE_ADMIN);
			unset($this->declaredInstances[$instanceName]["error"]);
			unset($this->declaredInstances[$instanceName]["constructor"]);
			unset($this->declaredInstances[$instanceName]["fieldProperties"]);
			unset($this->declaredInstances[$instanceName]["setterProperties"]);
			unset($this->declaredInstances[$instanceName]["fieldBinds"]);
			unset($this->declaredInstances[$instanceName]["setterBinds"]);
			$this->declaredInstances[$instanceName]["class"] = $fullyQualifiedClassName;
		} catch (\Exception $e) {
			$this->declaredInstances[$instanceName]["error"] = $e->getMessage();
			unset($this->declaredInstances[$instanceName]["class"]);
			$fullyQualifiedClassName = null;
		}
		return $fullyQualifiedClassName;
	}
714587
protected function get_instance($instance) {
        global $DB;
        if (is_scalar($instance)) {
            // instance id is passed as parameter
            $instance = $DB->get_record('grading_instances', array('id'  => $instance), '*', MUST_EXIST);
        }
        if ($instance) {
            $class = 'gradingform_'. $this->get_method_name(). '_instance';
            return new $class($this, $instance);
        }
        return null;
    }
339862
public function getSetterInjection(Expr\Variable $instance, array $setterMethods) : array
    {
        $setters = [];
        foreach ($setterMethods as $setterMethod) {
            $isOptional = ($this->privateProperty)($setterMethod, 'isOptional');
            $method = ($this->privateProperty)($setterMethod, 'method');
            $argumentsObject = ($this->privateProperty)($setterMethod, 'arguments');
            $arguments = ($this->privateProperty)($argumentsObject, 'arguments');
            $args = $this->getSetterParams($arguments, $isOptional);
            if (! $args) {
                continue;
            }
            $setters[] = new Expr\MethodCall($instance, $method, $args);
        }

        return $setters;
    }
512788
private static function getInstanceAndNodeByType(string $instance, string $node, int $type): array
    {
        if (!empty($node)) {
            return [$instance, $node];
        }

        if ($type === self::RETURN_ROWS || $type === self::RETURN_INSERTID) {
            return [$instance, Pool::MASTER];
        }

        return [$instance, Pool::SLAVE];
    }
1157210
public static function instance($instance = null)
	{
		if ($instance === true)
		{
			return static::$_instances;
		}
		elseif ($instance !== null)
		{
			if ( ! array_key_exists($instance, static::$_instances))
			{
				return false;
			}

			return static::$_instances[$instance];
		}

		return static::$_instance;
	}
106486
protected function collectMethods($instance, $filter = ReflectionMethod::IS_PUBLIC)
    {
        static $methodsCache = null;

        if (null === $methodsCache) {
            $methodsCache = $instance
                ? (new ReflectionClass($instance))->getMethods($filter)
                : [];
        }

        return $methodsCache;
    }