Configure Snippet Helper
@param SnippetHelper $snippetHelper
@param array         $config
@param array         $snippetsConfig
@return SnippetHelper
172902
protected function configureSnippetHelper(SnippetHelper $snippetHelper, array $config, array $snippetsConfig)
    {
        $enableAll = isset($snippetsConfig['enable_all']) ?
            (bool)$snippetsConfig['enable_all'] :
            true;

        foreach ($snippetsConfig['snippets'] as $name => $snippetsConfig) {

            $values = [];

            // Retrive values from global config if a config key was provided
            if (isset($snippetsConfig['config_key']) && isset($config[$snippetsConfig['config_key']])) {
                $values = $config[$snippetsConfig['config_key']];
            }

            // Merge provided values, if any
            if (isset($snippetsConfig['values'])) {
                $values = array_merge_recursive($values, $snippetsConfig['values']);
            }

            $snippetHelper->appendSnippet(
                $name,
                isset($snippetsConfig['template']) ? $snippetsConfig['template'] : 'hanger-snippet/' . $name,
                $values,
                isset($snippetsConfig['placement']) ? $snippetsConfig['placement'] : null,
                isset($snippetsConfig['enabled']) ? $snippetsConfig['enabled'] : $enableAll
            );
        }

        return $snippetHelper;
    }
1351883
public function getSnippet($fieldName, $returnFirstValueOnly = true) {
        if(!empty($this->snippets[$fieldName]) && count($this->snippets[$fieldName] > 0)) {
            return ($returnFirstValueOnly) ? $this->snippets[$fieldName][0] : $this->snippets[$fieldName];
        }
    }
451839
public function loadConfigurations(IConfiguration $config, $configFolder, $usePrefix = false) {
        $diretory = new \DirectoryIterator($configFolder);
        foreach($diretory as $fileinfo) {
            if($fileinfo->isDot() ||
                    !$fileinfo->isFile() ||
                    !$fileinfo->isReadable() ||
                    substr($fileinfo->getFilename(), -strlen($this->extension), strlen($this->extension)) != $this->extension) {
                continue;
            }

            $prefix = "";
            if($usePrefix) {
                $prefix = substr($fileinfo->getFilename(), 0, -strlen($this->extension));
            }
            $config->loadFile($fileinfo->getPathname(), $prefix);
        }

        return $config;
    }
1368748
List<Snippet> sourceToSnippetsWithWrappers(String userSource) {
        List<Snippet> snippets = sourceToSnippets(userSource);
        for (Snippet snip : snippets) {
            if (snip.outerWrap() == null) {
                snip.setOuterWrap(
                        (snip.kind() == Kind.IMPORT)
                                ? state.outerMap.wrapImport(snip.guts(), snip)
                                : state.outerMap.wrapInTrialClass(snip.guts())
                );
            }
        }
        return snippets;
    }
870346
protected function configure(array $config)
	{
		if (isset($config['parsers']))
		{
			$this->registerParsers($config['parsers']);
		}

		if (isset($config['cache']))
		{
			$this->cachePath = rtrim('cache', '\\/').DIRECTORY_SEPARATOR;
		}

		if (isset($config['auto_filter']))
		{
			$this->autoFilter = (bool) $config['auto_filter'];
		}

		if (isset($config['view_folder']))
		{
			$this->setViewFolder($config['view_folder']);
		}

		if (isset($config['whitelist']))
		{
			$this->whitelist($config['whitelist']);
		}
	}
408923
public function setDisableAll()
    {
        foreach ($this->snippets as $name => $config) {
            $this->setDisabled($name);
        }
        return $this;
    }
419524
private function decorateSnippet(array $snippet, $locale)
    {
        return array_merge(
            $snippet,
            [
                '_links' => [
                    'self' => $this->urlGenerator->generate(
                        'get_snippet',
                        ['id' => $snippet['id'], 'language' => $locale]
                    ),
                    'delete' => $this->urlGenerator->generate(
                        'delete_snippet',
                        ['id' => $snippet['id'], 'language' => $locale]
                    ),
                    'new' => $this->urlGenerator->generate('post_snippet', ['language' => $locale]),
                    'update' => $this->urlGenerator->generate(
                        'put_snippet',
                        ['id' => $snippet['id'], 'language' => $locale]
                    ),
                ],
            ]
        );
    }
685
public static function fromString(Text $configString)
    {
        $scope = new Scope();
        while (false === $configString->eof()) {

            if (true === $configString->isEmptyLine()) {
                $scope->addPrintable(EmptyLine::fromString($configString));
            }

            $char = $configString->getChar();

            if ('#' === $char) {
                $scope->addPrintable(Comment::fromString($configString));
                continue;
            }

            if (('a' <= $char) && ('z' >= $char)) {
                $scope->addDirective(Directive::fromString($configString));
                continue;
            }

            if ('}' === $configString->getChar()) {
                break;
            }

            $configString->inc();
        }
        return $scope;
    }
1026975
private function logSnippetAddition(AggregateSnippet $snippet, $path)
    {
        if (!$this->logger) {
            return;
        }

        $steps = $snippet->getSteps();
        $reason = sprintf("`<comment>%s</comment>` definition added", $steps[0]->getText());

        $this->logger->fileUpdated($path, $reason);
    }
454054
public function addCfg(array $cfgConfig, $append = false)
    {
        $count = count($this->_cfgs);
        $iteration = $append ? $count + 1000 : $count;
        $this->_cfgs[$iteration] = (new BlockCfg($cfgConfig))->toArray();
    }
1146824
function (str, opts) {
    opts = extend({marker: 'snippet', action: 'add'}, opts);
    opts = extend({}, this.options, opts);

    var snippet = this.toSnippet(str, opts);
    return utils.inject(this, snippet, opts);
  }
639698
public function setEnableAll()
    {
        foreach ($this->snippets as $name => $config) {
            $this->setEnabled($name);
        }
        return $this;
    }
881412
public function helper($name, array $config = []) {
		if (isset($this->_helpers[$name])) {
			return $this->_helpers[$name];
		}
		try {
			$config += ['context' => $this];
			return $this->_helpers[$name] = Libraries::instance('helper', ucfirst($name), $config);
		} catch (ClassNotFoundException $e) {
			if (ob_get_length()) {
				ob_end_clean();
			}
			throw new RuntimeException("Helper `{$name}` not found.");
		}
	}
1322734
public function remove(string $snippet, array $params = [])
    {
        $path = $this->buildUsersPath($snippet);

        return $this->delete($path, $params);
    }
109871
private function generateSnippets()
    {
        if ($this->snippetsGenerated) {
            return null;
        }

        $snippetsSet = array();
        foreach ($this->undefinedSteps as $i => $undefinedStep) {
            $snippet = $this->generateSnippet($undefinedStep->getEnvironment(), $undefinedStep->getStep());

            if (!$snippet) {
                continue;
            }

            if (!isset($snippetsSet[$snippet->getHash()])) {
                $snippetsSet[$snippet->getHash()] = array();
            }

            $snippetsSet[$snippet->getHash()][] = $snippet;
            unset($this->undefinedSteps[$i]);
        }

        $this->snippets = array_values(
            array_map(
                function (array $snippets) {
                    return new AggregateSnippet($snippets);
                },
                $snippetsSet
            )
        );
        $this->undefinedSteps = array_values($this->undefinedSteps);
        $this->snippetsGenerated = true;
    }
502243
public function addSnippet($script, $isDynamic = false)
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $suffix = $isDynamic ? '_dynamic' : '';
        $scriptsParameterName = static::SNIPPETS_PARAMETER_NAME . $suffix;
        $scripts = (array) $config->getGlobalParameter($scriptsParameterName);
        $script = trim($script);
        if (!in_array($script, $scripts)) {
            $scripts[] = $script;
        }
        $config->setGlobalParameter($scriptsParameterName, $scripts);
    }
1087321
private function loadSnippetGenerators(ContainerBuilder $container)
    {
        $definition = new Definition('Behat\Behat\Context\Snippet\Generator\ContextSnippetGenerator', array(
            new Reference(DefinitionExtension::PATTERN_TRANSFORMER_ID)
        ));
        $definition->addTag(SnippetExtension::GENERATOR_TAG, array('priority' => 50));
        $container->setDefinition(self::CONTEXT_SNIPPET_GENERATOR_ID, $definition);
    }