compileSource example

if (!class_exists($cls, false)) {
            $key = $this->cache->generateKey($name$mainCls);

            if (!$this->isAutoReload() || $this->isTemplateFresh($name$this->cache->getTimestamp($key))) {
                $this->cache->load($key);
            }

            $source = null;
            if (!class_exists($cls, false)) {
                $source = $this->getLoader()->getSourceContext($name);
                $content = $this->compileSource($source);
                $this->cache->write($key$content);
                $this->cache->load($key);

                if (!class_exists($mainCls, false)) {
                    /* Last line of defense if either $this->bcWriteCacheFile was used, * $this->cache is implemented as a no-op or we have a race condition * where the cache was cleared between the above calls to write to and load from * the cache. */
                    eval('?>'.$content);
                }

                
$content = "{% line $line %}" . $frontMatter->getContent();
        $source = new Source($content$source->getName()$source->getPath());
      }
    }
    catch (FrontMatterParseException $exception) {
      // Convert parse exception into a syntax exception for Twig and append       // the path/name of the source to help further identify where it occurred.       $message = sprintf($exception->getMessage() . ' in %s', $source->getPath() ?: $source->getName());
      throw new SyntaxError($message$exception->getSourceLine()$source$exception);
    }

    return parent::compileSource($source);
  }

  /** * Invalidates all compiled Twig templates. * * @see \drupal_flush_all_caches */
  public function invalidate() {
    PhpStorageFactory::get('twig')->deleteAll();
    $this->templateClasses = [];
    $this->state->delete(static::CACHE_PREFIX_METADATA_KEY);
  }
// load compiler             $this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty);
        }
        // compile locking         if ($this->smarty->compile_locking) {
            if ($saved_timestamp = $this->getCompiledTimestamp()) {
                touch($this->getCompiledFilepath());
            }
        }
        // call compiler         try {
            $this->compiler_object->compileSource($this);
        } catch (Exception $e) {
            // restore old timestamp in case of error             if ($this->smarty->compile_locking && $saved_timestamp) {
                touch($this->getCompiledFilepath()$saved_timestamp);
            }
            throw $e;
        }
        // compiling succeded         // write compiled template         Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath()$this->getCompiledConfig()$this->smarty);
    }

    
Home | Imprint | This part of the site doesn't use cookies.