mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
Plugin::GetDelegationChain() added
Multi inheritance of ORM reltions fix
This commit is contained in:
parent
34af19a723
commit
a80d99fdeb
|
@ -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)) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает делегирующий объект по имени делегата
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue