openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit e6c1e35f70d766a568d5c025efc18ed3ef8f96d7
parent 2e02cf1c5c9b70bf498d06e4b3bbeebfcf615d73
Author: Jan Dankert <develop@jandankert.de>
Date:   Sat,  9 Nov 2019 02:04:41 +0100

Refactoring: Extract the name calculation.

Diffstat:
modules/cms-core/action/TreeAction.class.php | 27++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/modules/cms-core/action/TreeAction.class.php b/modules/cms-core/action/TreeAction.class.php @@ -127,17 +127,9 @@ class TreeAction extends BaseAction $id = $this->getRequestVar('id',OR_FILTER_ALPHANUM); $result = $this->calculatePath( $type, $id ); - $this->setTemplateVar('path' ,$result ); - $name = ''; - $o = ModelFactory::create($type,$id); - - if ( $o ) { - $o->load(); - $name = $o->getName(); - } - + $name = $this->calculateName($type, $id); $this->setTemplateVar('actual',$this->pathItem($type,$id,$name) ); } @@ -340,6 +332,23 @@ class TreeAction extends BaseAction } + /** + * @param $type + * @param $id + * @return string + */ + protected function calculateName($type, $id) + { + $name = ''; + $o = ModelFactory::create($type, $id); + + if ($o) { + $o->load(); + $name = $o->getName(); + } + return $name; + } + }