Symfony\Bridge\Twig\Form\TwigRendererEngine::loadResourcesFromTheme PHP Method

loadResourcesFromTheme() protected method

Loads the resources for all blocks in a theme.
protected loadResourcesFromTheme ( string $cacheKey, mixed &$theme )
$cacheKey string The cache key for storing the resource
$theme mixed The theme to load the block from. This parameter is passed by reference, because it might be necessary to initialize the theme first. Any changes made to this variable will be kept and be available upon further calls to this method using the same theme.
    protected function loadResourcesFromTheme($cacheKey, &$theme)
    {
        if (!$theme instanceof \Twig_Template) {
            /* @var \Twig_Template $theme */
            $theme = $this->environment->loadTemplate($theme);
        }
        if (null === $this->template) {
            // Store the first \Twig_Template instance that we find so that
            // we can call displayBlock() later on. It doesn't matter *which*
            // template we use for that, since we pass the used blocks manually
            // anyway.
            $this->template = $theme;
        }
        // Use a separate variable for the inheritance traversal, because
        // theme is a reference and we don't want to change it.
        $currentTheme = $theme;
        $context = $this->environment->mergeGlobals(array());
        // The do loop takes care of template inheritance.
        // Add blocks from all templates in the inheritance tree, but avoid
        // overriding blocks already set.
        do {
            foreach ($currentTheme->getBlocks() as $block => $blockData) {
                if (!isset($this->resources[$cacheKey][$block])) {
                    // The resource given back is the key to the bucket that
                    // contains this block.
                    $this->resources[$cacheKey][$block] = $blockData;
                }
            }
        } while (false !== ($currentTheme = $currentTheme->getParent($context)));
    }