diff options
author | David <ottodavid@gmx.net> | 2015-08-10 17:58:59 +0200 |
---|---|---|
committer | David <ottodavid@gmx.net> | 2015-08-10 18:10:37 +0200 |
commit | ac81ab6d556ce52e98acf636bbcd8ad4d60ecf4e (patch) | |
tree | 72e4966047795a6beccc35f3e323ed10fbdd8c80 /framework/Web/Services | |
parent | 2bf1a517f3edc1bd43b8e3340f0f6fd31b1ba94a (diff) |
First support for pages with namespaced page class files
Diffstat (limited to 'framework/Web/Services')
-rw-r--r-- | framework/Web/Services/TPageService.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php index be865d89..a52efd13 100644 --- a/framework/Web/Services/TPageService.php +++ b/framework/Web/Services/TPageService.php @@ -102,6 +102,10 @@ class TPageService extends \Prado\TService */ const PAGE_FILE_EXT='.page'; /** + * Prefix of Pages used for instantiating new pages + */ + const PAGE_NAMESPACE_PREFIX = 'Application\\Pages\\'; + /** * @var string root path of pages */ private $_basePath=null; @@ -490,21 +494,22 @@ class TPageService extends \Prado\TService if($hasClassFile) { $className=basename($path); - if(!class_exists($className,false)) + $namespacedClassName = static::PAGE_NAMESPACE_PREFIX .str_replace('.', '\\', $pagePath); + if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) include_once($path.Prado::CLASS_FILE_EXT); + + if(!class_exists($className,false)) + $className = $namespacedClassName; } else { $className=$this->getBasePageClass(); - Prado::using($className); - if(($pos=strrpos($className,'.'))!==false) - $className=substr($className,$pos+1); } if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) throw new THttpException(404,'pageservice_page_unknown',$pagePath); - $page=new $className; + $page=Prado::createComponent($className); $page->setPagePath($pagePath); if($hasTemplateFile) |