From d0acd8681d97c863b9b6fec9d286a0aa19abf61e Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 19 Apr 2016 13:33:29 +0200 Subject: * base class for controls, auto-registering JS scripts --- app/php/components/TemplateControl.php | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/php/components/TemplateControl.php (limited to 'app/php/components/TemplateControl.php') diff --git a/app/php/components/TemplateControl.php b/app/php/components/TemplateControl.php new file mode 100644 index 0000000..e3c9e26 --- /dev/null +++ b/app/php/components/TemplateControl.php @@ -0,0 +1,53 @@ +_getControlScriptPath(get_class($this)); + if (file_exists($scriptFile)) { + foreach ($this->getPradoScriptDependencies() as $dependency) { + $this->Page->ClientScript->registerPradoScript($dependency); + } + foreach ($this->getControlScriptDependencies() as $dependency) { + $this->Page->ClientScript->registerScriptFile( + 'TemplateControl.' . $dependency, + $this->Application->AssetManager->publishFilePath( + $this->_getControlScriptPath($dependency) + ) + ); + } + foreach ($this->getExternalScriptDependencies() as $dependency) { + $this->Page->ClientScript->registerHeadScriptFile( + $dependency, $dependency + ); + } + $this->Page->ClientScript->registerScriptFile( + 'TemplateControl.' . get_class($this), + $this->Application->AssetManager->publishFilePath($scriptFile) + ); + } + } + + protected function getPradoScriptDependencies() { + return []; + } + + protected function getControlScriptDependencies() { + return []; + } + + protected function getExternalScriptDependencies() { + return []; + } + +} + +?> -- cgit v1.2.3