G
G
galithr2016-08-10 09:09:45
Yii
galithr, 2016-08-10 09:09:45

How to get application component id?

How to get the application component id inside the application itself?
For example, I connect a component to the application in the config:

'components' => [
    'TestComponent' => [
         'class' => 'app\components\MyComponent'
    ],
]

where is the id of the component in the application TestComponent. How do I know inside the component itself is the ID?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2016-08-10
@bitver

You need to take all the components and look for instanceof app\components\MyComponent.
It is better to pass as a parameter what you need.

'components' => [
    'TestComponent' => [
         'class' => 'app\components\MyComponent',
         'myProp' => 'Whatever you need' //myProp - публичное свойство компонента
    ],
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question