Skip to content

Commit

Permalink
added mapped class name trait
Browse files Browse the repository at this point in the history
  • Loading branch information
metalagman committed Jul 21, 2017
1 parent b121717 commit 9d56762
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Traits/MappedClassNameTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @author Alexey Samoylov <[email protected]>
*/

namespace YarCode\Yii2\Traits;

use YarCode\Yii2\Services\ClassMapper;
use yii\base\Component;

/**
* Trait MappedClassNameTrait
* @package YarCode\Yii2\Traits
*
* @mixin Component
*/
trait MappedClassNameTrait
{
/**
* @return string
*/
public static function className()
{
/** @var ClassMapper $mapper */
$mapper = \Yii::$container->get(ClassMapper::class);
return $mapper->resolve(get_called_class());
}
}

0 comments on commit 9d56762

Please sign in to comment.