Skip to content

Commit

Permalink
Enhanced PHPDocs, minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Apr 25, 2017
1 parent e0fa86a commit c9cdc9d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/Module.php
Expand Up @@ -17,12 +17,22 @@

class Module extends \yii\base\Module
{
const FLAG_APPLICATION = 'app';
const FLAG_DOMAIN = 'domain';

public $error = [];

public $feedback = [];

public $targets;

/**
* @var string Flag that will be prepended to the message title
* Special values that will be processed in a special way:
* - `hiqdev\yii2\monitoring\Module::FLAG_APPLICATION` - will prefix `Yii::$app->id`
* - `hiqdev\yii2\monitoring\Module::FLAG_DOMAIN` - will prefix `Yii::$app->request->getHostName()`
*
*/
public $flag;

public function getTarget($name)
Expand Down Expand Up @@ -50,12 +60,13 @@ public function getFlagText()

public function detectFlagText($flag)
{
if ($flag === 'app') {
return Yii::$app->id;
} elseif ($flag === 'domain') {
return Yii::$app->request->getHostName();
} else {
return $flag;
switch ($flag) {
case self::FLAG_APPLICATION:
return Yii::$app->id;
case self::FLAG_DOMAIN:
return Yii::$app->id;
default:
return $flag;
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/targets/RedirectTarget.php
Expand Up @@ -11,9 +11,10 @@
namespace hiqdev\yii2\monitoring\targets;

use hiqdev\yii2\monitoring\Module;
use yii\log\Target;

/**
* RedirectTarget redierects output to listed targets.
* RedirectTarget redirects output to listed targets.
*/
class RedirectTarget extends \yii\log\Target
{
Expand All @@ -39,6 +40,10 @@ public function export()
}
}

/**
* @param $name
* @return Target
*/
public function getTarget($name)
{
return $this->getModule()->getTarget($name);
Expand Down

0 comments on commit c9cdc9d

Please sign in to comment.