populate Source Object with timestamp and exists from Resource

@param Smarty_Template_Source $source source object
326408
public function populateTimestamp(Smarty_Template_Source $source)
    {
        $source->exists = true;
        /* @var \Smarty_Template_Source $_s */
        foreach ($source->components as $_s) {
            $source->exists = $source->exists && $_s->exists;
        }
        $source->timestamp = $source->exists ? $_s->getTimeStamp() : false;
    }
1304394
public function setSource($source): void
    {
        if (!\is_string($source)) {
            throw new Grid\GridException('Source of `SqlSource` should be string with SQL query');
        }
        parent::setSource($source);
    }
798957
public function addSource(Source $source)
    {
        $sources = array_map('strval', $this->sources->toArray());
        if (!in_array($source->getUrl(), $sources)) {
            $this->sources->add($source);
            $source->setItem($this);
        }

        return $this;
    }
952990
public function getBasename(Smarty_Template_Source $source)
    {
        $_file = $source->name;
        if (($_pos = strpos($_file, ']')) !== false) {
            $_file = substr($_file, $_pos + 1);
        }

        return basename($_file);
    }
102685
public function populateTimestamp(Smarty_Template_Source $source)
    {
        $source->exists = true;
        foreach ($source->components as $s) {
            $source->exists = $source->exists && $s->exists;
        }
        $source->timestamp = $s->timestamp;
    }
466394
public function update($source=null) {
        $this->timemodified = time();

        $result = parent::update($source);
        if ($result) {
            // Trigger the scale updated event.
            if (!empty($this->standard)) {
                $eventcontext = context_system::instance();
            } else {
                if (!empty($this->courseid)) {
                    $eventcontext = context_course::instance($this->courseid);
                } else {
                    $eventcontext = context_system::instance();
                }
            }
            $event = \core\event\scale_updated::create(array(
                'objectid' => $this->id,
                'context' => $eventcontext
            ));
            $event->trigger();
        }
        return $result;
    }
203523
public function render($source, array $data = array())
    {
        parent::render($source, $data);

        //Load the template
        if($this->getObject('filter.path')->validate($source))
        {
            $source_file = $this->locateSource($source);

            if(!$cache_file = $this->isCached($source_file))
            {
                $source     = $this->loadSource($source_file);
                $source     = $this->compileSource($source);
                $cache_file = $this->cacheSource($source_file, $source);
            }
        }
        else
        {
            $name        = crc32($source);
            $source_file = '';

            if(!$cache_file = $this->isCached($name))
            {
                $source     = $this->compileSource($source);
                $cache_file = $this->cacheSource($name, $source);
            }
        }

        //Include the template
        $result = include $cache_file;

        //Render the debug information
        return  $this->renderDebug($result);
    }
493269
public function getContent(Smarty_Template_Source $source)
    {
        $t = '';
        // the availability of the stream has already been checked in Smarty_Resource::fetch()
        $fp = fopen($source->filepath, 'r+');
        if ($fp) {
            while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
                $t .= $current_line;
            }
            fclose($fp);

            return $t;
        } else {
            return false;
        }
    }
204700
public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
    {
        $compiled->filepath = false;
        $compiled->timestamp = false;
        $compiled->exists = false;
    }
185864
public function prepareSource(&$source = null, $reference = false)
    {
        $headers = [];

        foreach ((array) $source as $key => $value) {
            $headers[HeaderHelper::normalizeHeaderName($key)] = implode(', ', $value);
        }

        parent::prepareSource($headers, $reference);
    }
1055600
public function setSource($source)
    {
        $controller = Controller::curr();
        $code = $controller->data()->Code;
        $updated = [];
        if (is_array($source) && !empty($source)) {
            foreach ($source as $key => $val) {
                $updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val;
            }
        }
        $this->source = $updated;

        return $this;
    }
1195727
protected function fileExists(Smarty_Template_Source $source, $file)
    {
        $source->timestamp = @filemtime($file);
        return $source->exists = !!$source->timestamp;

    }
1087587
private function initSource($source)
    {
        if (empty($this->source)) {
            $this->source = new Source();
        }

        if (!empty($source)) {
            if (is_array($source)) {
                $this->source->setLines($source);
            } elseif (is_string($source)) {
                $this->source->setString($source);
            }
        }
    }
172464
public function addSource( string $sourceName, ISource $source ) : Translator
   {

      $source->setLocale( $this->_locale );

      $this->_sources[ $sourceName ] = $source;

      return $this;

   }
1208790
public function setSource($source)
    {
        $array = $this->castToArray($source);

        foreach ($array as $item) {
            $this->append($item);
        }

        return $this;
    }
608594
protected function getAssetSourceUrlWithModifiedTime(string $source, string $file): string
    {
        if ($this->isLocalPath($source) && $this->useVersioning) {
            // We can only append mtime to locally defined path since we need
            // to extract the file.

            if (! empty($modified = $this->files->lastModified($file))) {
                $source = $source."?{$modified}";
            }
        }

        return $source;
    }
1238632
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
    {
        $uid = '';
        $sources = array();
        $components = explode('|', $source->name);
        $exists = true;
        foreach ($components as $component) {
            $s = Smarty_Resource::source(null, $source->smarty, $component);
            if ($s->type == 'php') {
                throw new SmartyException("Resource type {$s->type} cannot be used with the extends resource type");
            }
            $sources[$s->uid] = $s;
            $uid .= $s->filepath;
            if ($_template && $_template->smarty->compile_check) {
                $exists = $exists && $s->exists;
            }
        }
        $source->components = $sources;
        $source->filepath = $s->filepath;
        $source->uid = sha1($uid);
        if ($_template && $_template->smarty->compile_check) {
            $source->timestamp = $s->timestamp;
            $source->exists = $exists;
        }
        // need the template at getContent()
        $source->template = $_template;
    }