Improved contentcontainer base record lookup when contentcontainer_id is available

This commit is contained in:
Lucas Bartholemy 2017-11-05 21:39:11 +01:00
parent 6d19c7fce7
commit ba569e3cea

View File

@ -192,6 +192,10 @@ abstract class ContentContainerActiveRecord extends ActiveRecord
*/
public function getContentContainerRecord()
{
if ($this->hasAttribute('contentcontainer_id')) {
return $this->hasOne(ContentContainer::className(), ['id' => 'contentcontainer_id']);
}
return $this->hasOne(ContentContainer::className(), ['pk' => 'id'])
->andOnCondition(['class' => $this->className()]);
}