New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confused with "use Yii;" in view file #2154

Closed
mitalcoi opened this Issue Jan 25, 2014 · 7 comments

Comments

Projects
None yet
4 participants
@mitalcoi
Contributor

mitalcoi commented Jan 25, 2014

I faced with strange problem. In view file i write:

use Yii;
$this->title = Yii::t('cabinet', 'Info');

And at first page reload i have an error:
2014-01-25 19 58 49
After second reload error escapes.
If i remove "use Yii;" all will work without any error. How could it be?

@dilip-vishwa

This comment has been minimized.

Show comment
Hide comment
@dilip-vishwa

dilip-vishwa Jan 25, 2014

Contributor

use Yii; is the correct way. You may have error somewhere else

Contributor

dilip-vishwa commented Jan 25, 2014

use Yii; is the correct way. You may have error somewhere else

@vova07

This comment has been minimized.

Show comment
Hide comment
@vova07

vova07 Jan 25, 2014

Contributor

You don't need use Yii in view files.

Contributor

vova07 commented Jan 25, 2014

You don't need use Yii in view files.

@mitalcoi

This comment has been minimized.

Show comment
Hide comment
@mitalcoi

mitalcoi Jan 25, 2014

Contributor

@vova07, is it documented? how is it possible? Is the same situations in controllers?

Contributor

mitalcoi commented Jan 25, 2014

@vova07, is it documented? how is it possible? Is the same situations in controllers?

@vova07

This comment has been minimized.

Show comment
Hide comment
@vova07

vova07 Jan 25, 2014

Contributor

@mitalcoi I'm not sure about documentation, but in view file you don't need to import Yii class. In controller you must import it. Just try without use Yii;.

Contributor

vova07 commented Jan 25, 2014

@mitalcoi I'm not sure about documentation, but in view file you don't need to import Yii class. In controller you must import it. Just try without use Yii;.

@mitalcoi

This comment has been minimized.

Show comment
Hide comment
@mitalcoi

mitalcoi Jan 25, 2014

Contributor

it is undocumented. i'm got rid use Yii; and it works good. but i don't understand internal mechanism

Contributor

mitalcoi commented Jan 25, 2014

it is undocumented. i'm got rid use Yii; and it works good. but i don't understand internal mechanism

@vova07

This comment has been minimized.

Show comment
Hide comment
@vova07

vova07 Jan 25, 2014

Contributor

Perhaps it's really misunderstanding.

Contributor

vova07 commented Jan 25, 2014

Perhaps it's really misunderstanding.

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Jan 25, 2014

Member

use Yii; is to import Yii class into the current namespace. As the view file is already in the root namespace where also the Yii class lives there is not sense of importing it. Thus the error.

Member

cebe commented Jan 25, 2014

use Yii; is to import Yii class into the current namespace. As the view file is already in the root namespace where also the Yii class lives there is not sense of importing it. Thus the error.

@cebe cebe closed this Jan 25, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment