-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compatible
AssetVariable::offsetGet()
between different PHP ver…
…sions
- Loading branch information
1 parent
b5f45ae
commit 304fc28
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace humhub\modules\custom_pages\modules\template\models; | ||
|
||
use Yii; | ||
|
||
/** | ||
* This is the model class for table "custom_pages_template_content". | ||
* | ||
* A OwnerContent instance is used to assign a TemplateElement to a specific | ||
* Content of a specific type. | ||
* | ||
* @deprecated Use this only for PHP7.4 and older versions | ||
*/ | ||
class AssetVariablePhp74 implements \ArrayAccess | ||
{ | ||
|
||
private $module; | ||
|
||
public function get($name) | ||
{ | ||
$path = '/'.$name; | ||
|
||
$module = $this->getModule(); | ||
if($module->isPublished($path)) { | ||
return $this->getModule()->getPublishedUrl($path); | ||
} | ||
return ''; | ||
} | ||
|
||
private function getModule() | ||
{ | ||
if($this->module == null) { | ||
$this->module = Yii::$app->getModule('custom_pages'); | ||
} | ||
return $this->module; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return ''; | ||
} | ||
|
||
public function offsetExists($offset): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function offsetGet($offset) | ||
{ | ||
return $this->get($offset); | ||
} | ||
|
||
public function offsetSet($offset, $value): void | ||
{ | ||
} | ||
|
||
public function offsetUnset($offset): void | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters