Enh: Added scheme paramter to Content::getUrl method

This commit is contained in:
Lucas Bartholemy 2018-08-31 21:38:52 +02:00
parent eb24ee630a
commit 02727686fe
4 changed files with 22 additions and 10 deletions

View File

@ -37,7 +37,7 @@ HumHub Change Log
- Enh: Added `humhub\modules\content\widgets\richtext\ProsemirrorRichText::parseOutput` for pre render parsing
- Enh: Added `humhub.modules.file.getFileUrl` and `humhub.modules.file.filterFileUrl` for file guid based url handling
- Fix: `humhub\modules\space\modules\manage\components\Controller` only accessible by system admins
- Enh: Added scheme paramter to Content::getUrl method
1.3.1 (August 7, 2018)

View File

@ -194,7 +194,7 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner
* @param $id
* @param int $limit
*
* @return array|mixed|\yii\db\ActiveRecord[]
* @return Comment[] the comments
*/
public static function GetCommentsLimited($model, $id, $limit = 2)
{

View File

@ -25,6 +25,7 @@ use humhub\modules\user\models\User;
use Yii;
use yii\base\Exception;
use yii\base\InvalidArgumentException;
use yii\db\IntegrityException;
use yii\helpers\Url;
/**
@ -502,7 +503,10 @@ class Content extends ContentDeprecated implements Movable, ContentOwner
/**
* {@inheritdoc}
*/
public function afterMove(ContentContainerActiveRecord $container = null){/* Nothing to do */}
public function afterMove(ContentContainerActiveRecord $container = null)
{
// Nothing to do
}
/**
* Unarchives the content object
@ -526,14 +530,20 @@ class Content extends ContentDeprecated implements Movable, ContentOwner
* e.g. in case there is no wall entry available for this content.
*
* @since 0.11.1
* @param boolean $scheme
* @return string the URL
*/
public function getUrl()
public function getUrl($scheme = false)
{
try {
if (method_exists($this->getPolymorphicRelation(), 'getUrl')) {
return $this->getPolymorphicRelation()->getUrl();
return $this->getPolymorphicRelation()->getUrl($scheme);
}
} catch (IntegrityException $e) {
Yii::error($e->getMessage(), 'content');
}
return Url::toRoute(['/content/perma', 'id' => $this->id]);
return Url::toRoute(['/content/perma', 'id' => $this->id], $scheme);
}
/**

View File

@ -53,6 +53,8 @@ use yii\base\Exception;
* @property integer $visibility
* @property integer $contentcontainer_id
* @property Profile $profile
*
* @property string $displayName
*/
class User extends ContentContainerActiveRecord implements IdentityInterface, Searchable
{