Gets configuration data from a new lock instance form.

@param string $plugin
@param stdClass $data
@return array
@throws coding_exception
433873
public static function get_lock_configuration_from_data($plugin, $data) {
        global $CFG;
        $file = $CFG->dirroot.'/cache/locks/'.$plugin.'/lib.php';
        if (!file_exists($file)) {
            throw new coding_exception('Invalid cache plugin provided. '.$file);
        }
        require_once($file);
        $class = 'cachelock_'.$plugin;
        if (!class_exists($class)) {
            throw new coding_exception('Invalid cache plugin provided.');
        }
        if (array_key_exists('cache_is_configurable', class_implements($class))) {
            return $class::config_get_configuration_array($data);
        }
        return array();
    }
886895
protected function iblockPropertyUpdate($iblock, array $data)
    {
        $return = [];

        $iblock = $this->iblockLocate($iblock);

        if (empty($data['CODE'])) {
            throw new Exception('You must set property CODE');
        }

        $res = CIBlockProperty::getList([], [
            'CODE' => $data['CODE'],
            'IBLOCK_ID' => $iblock['ID'],
            'CHECK_PERMISSIONS' => 'N',
        ]);
        if ($ob = $res->fetch()) {
            if (!empty($ob['USER_TYPE']) && empty($data['USER_TYPE'])) {
                $data['USER_TYPE'] = $ob['USER_TYPE'];
            }
            $ib = new CIBlockProperty();
            $id = $ib->update($ob['ID'], $data);
            if ($id) {
                $return[] = "Property {$data['CODE']}({$ob['ID']}) for iblock {$iblock['CODE']}({$iblock['ID']}) updated";
            } else {
                throw new Exception(
                    "Can't update {$data['CODE']} property. Error: {$ib->LAST_ERROR}"
                );
            }
        } else {
            throw new Exception(
                "Can't find {$data['CODE']} property for iblock {$iblock['CODE']}({$iblock['ID']})"
            );
        }

        return $return;
    }
1218294
public function configurationFor(string $extensionName, string $pluginName, string $contextRecord = 'currentPage')
    {
        list($tableName, $uid) = $this->resolveTableNameAndUidFromContextString($contextRecord);
        $pluginSignature = $this->buildPluginSignature($extensionName, $pluginName);
        $renderingPath = $this->resolveRenderingPath($pluginSignature);
        return [
            'record' => $tableName . '_' . $uid,
            'path' => $renderingPath,
        ];
    }
225362
public static function get_store_configuration_from_data(stdClass $data) {
        global $CFG;
        $file = $CFG->dirroot.'/cache/stores/'.$data->plugin.'/lib.php';
        if (!file_exists($file)) {
            throw new coding_exception('Invalid cache plugin provided. '.$file);
        }
        require_once($file);
        $class = 'cachestore_'.$data->plugin;
        if (!class_exists($class)) {
            throw new coding_exception('Invalid cache plugin provided.');
        }
        if (array_key_exists('cache_is_configurable', class_implements($class))) {
            return $class::config_get_configuration_array($data);
        }
        return array();
    }
999780
private function getClassInstance(\stdClass $data, \ReflectionClass $reflection)
    {
        switch (true):
            case $this->genericInstantiator->supports($data, $reflection):
                $output = $this->genericInstantiator->instantiate($data, $reflection);
                break;
            case $this->customInstantiator->supports($data, $reflection):
                $output = $this->customInstantiator->instantiate($data, $reflection);
                break;
            default:
                throw new \Exception('Cannot determine how to instantiate object of class: '.$reflection->getParentClass());
        endswitch;

        return $output;
    }
482161
public static function config($namespace)
    {
        $configPath = pluginsPath($namespace.'/config.json');
        if(file_exists($configPath)) {
            return json_decode(File::get($configPath));
        }
        throw  new \Exception("No config.json file found for plugin ".$configPath);
    }
874489
public function getDefaultInstanceConfig($pluginName)
    {
        $blockConfig = $this->blockConfigRepository->findById($pluginName);

        if (empty($blockConfig)) {
            throw new \Exception('Block config not found for ' . $pluginName); //@TODO throw custom exception class
        }

        return $blockConfig->getDefaultConfig();
    }
64162
public function set_plugin_data() {

		// Load plugin.php if get_plugins() not available
		if ( ! function_exists( 'get_plugins' ) ) {
			require_once ABSPATH . 'wp-admin/includes/plugin.php';
		}

		// Get path to plugin's directory
		$plugin_dir = plugin_basename( dirname( __FILE__ ) );

		// Get plugin data
		$plugin_data = current( get_plugins( '/' . $plugin_dir ) );

		// Set plugin data
		$this->plugin_data = apply_filters( 'ctc_plugin_data', $plugin_data );

	}
789729
public function getPluginInfo($plugin)
    {
        $zipArchive = $this->openZipArchive($plugin);

        if ($path = $this->searchForPluginJson($zipArchive)) {
            $jsonString = $this->getFileFromZip($path, $zipArchive);
            return json_decode($jsonString, true);
        } elseif ($path = $this->searchForPluginXml($zipArchive)) {
            $xmlString = $this->getFileFromZip($path, $zipArchive);
            return $this->readXml($xmlString);
        } else {
            throw new \RuntimeException('Plugin info file not found in zip (plugin.json or plugin.xml)');
        }
    }
47219
public function getPlugin( string $name, array $data = [], bool $rawResult = false )
	{
		if( ! isset($this->plugins[$name]) )
		{
			return "The '{$name}' plugin not found";
		}

		$plug = $this->plugins[$name];
		$class_name = $plug["class_name"];
		if( !is_array($data) )
		{
			$data = [$data];
		}

		/** @var Plugin $plugin */
		$plugin = new $class_name($data);

		if( !$plugin instanceof Plugin )
		{
			throw new \RuntimeException("Plugin must be inherited of " . Plugin::class, 500);
		}

		if( $rawResult )
		{
			return $plugin
				->load()
				->getPluginData();
		}

		$cache_type = $plugin->cacheType();
		$cache_view = $cache_type === "view";

		if( $cache_view || $cache_type === "plugin" )
		{
			$cache_name = Str::snake($name);
			$cache_data = $plugin->cacheData();
			$id = $name;
			if( isset($cache_data["id"]) )
			{
				$id = $cache_data["id"];
				unset($cache_data["id"]);
			}

			$cache = new Cache( $id, "plugin/" . $cache_name, $cache_data );
			if( $cache->ready() )
			{
				$content = $cache->import();
			}
			else
			{
				$content = $plugin
					->load()
					->getRenderContent($this);

				$cache->export($content);
			}

			if($cache_view) {
				return $content;
			}
		}
		else
		{
			$content = $plugin
				->load()
				->getRenderContent($this);
		}

		$number = $this->plugin_index ++;
		$hash = md5(mt_rand( 1000, 100000 )) . "-" . time();
		$this->plugin[$number] = [
			"package"       => $plug["package_name"],
			"name"          => $name,
			"cache"         => $cache_type,
			"cache_data"    => $plugin->cacheData(),
			"content"       => $content,
			"data"          => $data,
			"hash"          => $hash
		];

		return '{plugin:' . $number . ':' . $hash . '}';
	}
40658
public function getConfigData($data = null) {
        if ($data !== null && isset($this->_config[$data])) {
            return $this->_config[$data];
        } elseif ($data === null) {
            return $this->_config;
        } else {
            throw new ConfigException("Error while requesting config value: " . $data);
        }
    }
788987
private function pluginConfiguration(PluginInterface $plugin, array $processedConfiguration)
    {
        if (!isset($processedConfiguration[$plugin->name()])) {
            if ($plugin->isRequireConfigurationKey()) {
                throw new UnsetKeyException(sprintf('The %s key must be set.', $plugin->name()));
            }

            return array();
        }

        return $processedConfiguration[$plugin->name()];
    }
451640
protected function getSettings()
    {
        $this->responseData = $this->plugin->getSettings();

        // set data and return response
        if (empty($this->response)) {
            $this->response = new ShopgatePluginApiResponseAppJson($this->trace_id);
        }
    }
1113931
public static function config_get_configuration_array($data) {
        return array(
            'server' => $data->server,
            'prefix' => $data->prefix,
            'password' => $data->password,
            'serializer' => $data->serializer
        );
    }
1010641
public function getData() : \stdClass
    {
        $output = new \stdClass();

        $propertyNames = array_keys($this->defaultProperties);
        foreach ($propertyNames as $property) {
            $key = strtolower($property);

            if (array_key_exists($key, $this->data)) {
                $output->{$key} = $this->data[$key];
            } elseif ('parent' !== $key) {
                $output->{$key} = $this->defaultProperties[$property];
            }
        }

        // Don't want to normally do this, just if it exists in the data file
        // for our test runs
        if (array_key_exists('patternid', $this->data)) {
            $output->patternid = $this->data['patternid'];
        }

        return $output;
    }
65062
public function getEntity($plugin)
    {
        $plugin = Inflector::camelize($plugin);
        $slug   = Str::low($plugin);
        $entity = $this->_controller->Extensions->findBySlug($slug)->first();
        if ($entity === null) {
            $entity = $this->_controller->Extensions->newEntity([
                'params' => [],
                'slug'   => $slug,
                'name'   => $plugin
            ]);

            $config = Plugin::getData($plugin, 'meta');
            $entity
                ->set('core', $config->get('core', false))
                ->set('name', $config->get('name', $plugin));
        }

        return $entity;
    }
516063
public function load($pluginName, array $overrideProps = [])
	{
		// Validate the plugin name / class
		$pluginName = $this->normalizeKey($pluginName);
		$className  = 's9e\\TextFormatter\\Plugins\\' . $pluginName . '\\Configurator';

		if (!class_exists($className))
		{
			throw new RuntimeException("Class '" . $className . "' does not exist");
		}

		// Create the plugin
		$plugin = new $className($this->configurator, $overrideProps);

		// Save it
		$this->set($pluginName, $plugin);

		// Return it
		return $plugin;
	}