From 9d56762a373bdf9d039e536a9bd0b7e6d6501cbb Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 21 Jul 2017 16:46:51 +0700 Subject: [PATCH] added mapped class name trait --- src/Traits/MappedClassNameTrait.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Traits/MappedClassNameTrait.php diff --git a/src/Traits/MappedClassNameTrait.php b/src/Traits/MappedClassNameTrait.php new file mode 100644 index 0000000..862a123 --- /dev/null +++ b/src/Traits/MappedClassNameTrait.php @@ -0,0 +1,28 @@ + + */ + +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()); + } +} \ No newline at end of file