1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-29 04:55:02 +03:00

Plugin::GetDelegationChain() added

Multi inheritance of ORM reltions fix
This commit is contained in:
Alexander Zinchuk 2010-11-16 16:24:57 +00:00
parent 34af19a723
commit a80d99fdeb
3 changed files with 27 additions and 15 deletions

View file

@ -215,16 +215,7 @@ abstract class Action extends Object {
* @param string $sTemplate Путь до шаблона относительно каталога шаблонов экшена
*/
protected function SetTemplateAction($sTemplate) {
$sAction = $this->GetActionClass();
$sActionDelegater = $this->Plugin_GetDelegater('action',$this->GetActionClass());
while(empty($sRootDelegater)) {
if($sAction==$sActionDelegater) {
$sRootDelegater = $sAction;
}
$sAction = $sActionDelegater;
$sActionDelegater = $this->Plugin_GetDelegater('action',$sActionDelegater);
}
$aDelegates = $this->Plugin_collectAllDelegatesRecursive(array($sRootDelegater),'action');
$aDelegates = $this->Plugin_GetDelegationChain('action',$this->GetActionClass());
$sActionTemplatePath = $sTemplate.'.tpl';
foreach($aDelegates as $sAction) {
if(preg_match('/^(Plugin([\w]+)_)?Action([\w]+)$/i',$sAction,$aMatches)) {

View file

@ -38,6 +38,7 @@ abstract class EntityORM extends Entity {
public function __construct($aParam=false) {
parent::__construct($aParam);
$this->aRelations=$this->_getRelations();
}
public function _GetPrimaryKey() {
@ -200,7 +201,9 @@ abstract class EntityORM extends Entity {
}
public function _getRelations() {
return $this->aRelations;
$sParentName=get_parent_class($this);
$oEntityParent=new $sParentName();
return array_merge($oEntityParent->_getRelations(),$this->aRelations);
}
public function _getRelationsData() {

View file

@ -436,15 +436,33 @@ class ModulePlugin extends Module {
return null;
}
public function collectAllDelegatesRecursive($aDelegates,$sType) {
public function GetDelegationChain($sType,$sTo) {
$sRootDelegater = $this->GetRootDelegater($sType,$sTo);
return $this->collectAllDelegatesRecursive($sType,array($sRootDelegater));
}
public function GetRootDelegater($sType,$sTo) {
$sItem = $sTo;
$sItemDelegater = $this->GetDelegater($sType,$sTo);
while(empty($sRootDelegater)) {
if($sItem==$sItemDelegater) {
$sRootDelegater = $sItem;
}
$sItem = $sItemDelegater;
$sItemDelegater = $this->GetDelegater($sType,$sItemDelegater);
}
return $sRootDelegater;
}
public function collectAllDelegatesRecursive($sType,$aDelegates) {
foreach($aDelegates as $sClass) {
if($aNewDelegates=$this->GetDelegates($sType,$sClass)) {
$aDelegates = array_merge($this->collectAllDelegatesRecursive($aNewDelegates,$sType),$aDelegates);
$aDelegates = array_merge($this->collectAllDelegatesRecursive($sType,$aNewDelegates),$aDelegates);
}
}
return $aDelegates;
}
}
/**
* Возвращает делегирующий объект по имени делегата
*