20.11.2014 Views

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

class PostController extends CController<br />

{<br />

public function actions()<br />

{<br />

return array(<br />

'service'=>array(<br />

'class'=>'CWebServiceAction',<br />

'classMap'=>array(<br />

'Post'=>'Post', // or simply 'Post'<br />

),<br />

),<br />

);<br />

}<br />

......<br />

}<br />

Intercepting Remote Method Invocation<br />

By implementing the [IWebServiceProvider] interface, a service provider can intercept<br />

remote method invocations. In [IWebServiceProvider::beforeWebMethod], the provider<br />

may retrieve the current CWebService instance and obtain the the name of the method<br />

currently being requested via CWebService::methodName. It can return false if the remote<br />

method should not be invoked for some reason (e.g. unauthorized access).<br />

Internacionalização (i18n)<br />

Internationalization (I18N) refers to the process of designing a software application so that<br />

it can be adapted to various languages and regions without engineering changes. For Web<br />

applications, this is of particular importance because the potential users may be from<br />

worldwide.<br />

<strong>Yii</strong> provides support for I18N in several aspects.<br />

• It provides the locale data for each possible language and variant.<br />

• It provides message and file translation service.<br />

• It provides locale-dependent date and time formatting.<br />

• It provides locale-dependent number formatting.<br />

In the following subsections, we will elaborate each of the above aspects.<br />

Locale and Language<br />

Locale is a set of parameters that defines the user's language, country and any special<br />

variant preferences that the user wants to see in their user interface. It is usually identified<br />

by an ID consisting of a language ID and a region ID. For example, the ID en_US stands<br />

for the locale of English and United States. For consistency, all locale IDs in <strong>Yii</strong> are

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!