@param \Twig_Environment $twig
@param string            $path
@param string            $packageName

@return string
187378
public function getAssetUrl(\Twig_Environment $twig, $path, $packageName = null)
    {
        /** @var AssetExtension $asset */
        $asset = $twig->getExtension('Symfony\Bridge\Twig\Extension\AssetExtension');

        if (isset($this->assetMap[$path])) {
            $path = $this->assetMap[$path];
        }

        return $asset->getAssetUrl($path, $packageName);
    }
888815
private function initPackageClassPhp($path, $packageName)
    {
        $class = $this->getClass($packageName);
        $namespace = $this->getNamespace($packageName);
        $file = $path.'/src/'.$class.'.php';
        if (file_exists($file)) {
            return;
        }
        $code = file_get_contents(__DIR__.'/../../tpl/PackageClass.php.txt');
        $code = str_replace(['%%CLASS%%', '%%NAMESPACE%%'], [$class, $namespace], $code);
        if (!is_dir($path.'/src')) {
            mkdir($path.'/src');
        }
        file_put_contents($file, $code);
    }
442758
public function getTwig() {
		if ($this->twig === null) {
			$options = [];
			if (KEEKO_ENVIRONMENT == KEEKO_DEVELOPMENT) {
				$options['debug'] = true;
			}

			$repo = $this->getResourceRepository();
			$loader = new PuliTemplateLoader($repo);
			$this->twig = new Twig_Environment($loader, $options);

			// puli extension
			$generator = $this->getUrlGenerator();
			$this->twig->addExtension(new PuliExtension($repo, $generator));

			// translator function
			$translator = $this->getTranslator();
			$trans = function($key, $params = [], $domain = null) use ($translator) {
				return $translator->trans($key, $params, $domain);
			};
			$this->twig->addFunction(new Twig_SimpleFunction('t', $trans));

			// firewall
			$firewall = $this->getFirewall();
			$access = function ($module, $action) use ($firewall) {
				return $firewall->hasPermission($module, $action);
			};

			// debug
			if (KEEKO_ENVIRONMENT == KEEKO_DEVELOPMENT) {
				$this->twig->addExtension(new Twig_Extension_Debug());
			}

			$this->twig->addFunction(new Twig_SimpleFunction('can', $access));
		}

		return $this->twig;
	}
1145242
public function getTwig(\Twig_Environment $twig)
    {

        $this->functions->rewind();
        while ($this->functions->valid()) {

            $function = $this->functions->current();
            $twig->addFunction(new \Twig_SimpleFunction($function->getFunctionName(), array($function, 'getFunctionBody')));
            $this->functions->next();

        }

        return $twig;

    }
637736
public function getMenu(\Twig_Environment $environment, $name, $lang, $options = array())
    {
        $options = array_merge($this->getDefaultOptions(), $options);

        $renderService = $this->renderService;
        $options['nodeDecorator'] = function ($node) use ($environment, $renderService, $options) {
            return $renderService->renderMenuItemTemplate($environment, $node, $options);
        };

        $arrayResult = $this->getMenuItems($name, $lang);
        $html = $this->repository->buildTree($arrayResult, $options);

        return $html;
    }
1191577
public static function newTwig($content = null, $name = null, bool $persist = false)
    {
        $loader = new TwigLoaderString();
        $name = $loader->register($content, $name, $persist);
        $twig = (new Twig($loader, self::getTwigConfig()));
        $twig->addExtension(new Sandbox(self::buildSandboxPolicies()));
        return $twig->load($name);
    }
143165
protected function fetchRepositoryUpdates(PackageInterface $package, $path, $url)
    {
        /**
         * Copy-pasted from doUpdate
         *
         * @see GitDownloader::doUpdate()
         */
        $this->io->write('    Checking out ' . $package->getSourceReference());
        $command = $this->getFetchCommand();
        $commandCallable = function ($url) use ($command) {
            return sprintf($command, ProcessExecutor::escape($url));
        };
        $this->gitUtil->runCommand($commandCallable, $url, $path);
        return $this;
    }
883192
public function publishPackage($package, $packagePath = null)
    {
        $source = $this->getSource($package, $packagePath ?: $this->packagePath);

        return $this->publish($package, $source);
    }
1099518
public function getCategoryTree(
        \Twig_Environment $environment,
        $template = 'ONGRContentBundle:Category:inc/categorytree.html.twig',
        $maxLevel = 0,
        $selectedCategory = null
    ) {
        $this->setMaxLevel($maxLevel);
        $this->setTemplate($template);

        $this->categoryService->setCurrentCategoryId($selectedCategory);
        $tree = $this->categoryService->getTree($this->getMaxLevel(), true);
        $currentCategory = $this->categoryService->getCurrentCategoryDocument();

        return $this->renderCategoryTree($environment, $tree, $selectedCategory, $currentCategory);
    }
254223
public function thumb($path)
    {
        try{
            $cacheManager = $this->container->get('liip_imagine.cache.manager');
            $filter = FileManager::FILTER_NAME;
            return new \Twig_Markup(
                $cacheManager->getBrowserPath($path, $filter, array()),
                'utf8'
            );
        } catch(\Exception $e){
            return $path;
        }

    }
678759
public function add_to_twig( $twig ) {
		$twig->addExtension( new Twig_Extension_StringLoader() );
		$twig->addFilter( new Twig_SimpleFilter( 'myfoo', array( $this, 'myfoo' ) ) );
		return $twig;
	}
876346
protected function getPackageName($path)
    {
        if (ends_with($path, '.zip')) {
            $path = dirname($path);
        }
        $manifest = new Manifest(new Filesystem(), $path);
        return $manifest->get('package');
    }
226219
public function onTwigRegistered(Twig_Environment &$twig)
    {
        $this->twig = $twig;

        $this->triggerEvent(self::API_VERSION_0_9, 'before_twig_register');
        $this->triggerEvent(self::API_VERSION_1_0, 'onTwigRegistration');
    }
203586
private static function selectPackage(string $pathname): string {
    $filename = $pathname . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang::$locale . ".json";
    if (file_exists($filename)) {
      $pathname = $filename;
    } else {
      $pathname .= DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang::STANDARD_LOCALE . ".json";
    }
    return $pathname;
  }
1146672
function packageNameFromPath(path) {
  var matches = moduleRegex.exec(path);
  return matches && matches.length > 1 ? matches[1] : null;
}
1093120
public function writeCache($path, $packages)
    {
        $data = array();

        foreach ($packages->all() as $key => $package) {
            $properties = ($package instanceof Collection) ? $package->all() : $package;

            // Normalize to *nix paths.
            $properties['path'] = str_replace('\\', '/', $properties['path']);

            //
            ksort($properties);

            $data[] = $properties;
        }

        //
        $data = var_export($data, true);

        $content = <<<PHP
<?php

return $data;

PHP;

        $this->files->put($path, $content);
    }
895954
public function install(Environment $twig): Environment
    {
        $twig = clone $twig;

        $extension = new Extension($this->pipeline);
        $twig->addExtension($extension);

        $compiler = new PatchingCompiler($twig);
        $twig->setCompiler($compiler);

        return $twig;
    }