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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

yiic sitemap index --type=News --limit=5<br />

// $limit takes default value<br />

yiic sitemap index --type=News<br />

// $limit takes default value<br />

// because 'index' is a default action, we can omit the action name<br />

yiic sitemap --type=News<br />

// the order of options <strong>do</strong>es not matter<br />

yiic sitemap index --limit=5 --type=News<br />

If an option is given without value (e.g. --type instead of --type=News), the corresponding<br />

action parameter value will be assumed to be boolean true.<br />

Note: The feature of console command action has been available since version <strong>1.1</strong>.5.<br />

A parameter can take an array value by declaring it with array type hinting:<br />

public function actionIndex(array $types) { ... }<br />

To supply the array value, we simply repeat the same option in the command line as<br />

needed:<br />

yiic sitemap index --types=News --types=Article<br />

The above command will call actionIndex(array('News', 'Article')) ultimately.<br />

Starting from version <strong>1.1</strong>.6, <strong>Yii</strong> also supports using anonymous action parameters and<br />

global options.<br />

Anonymous parameters refer to those command line parameters not in the format of<br />

options. For example, in a command yiic sitemap index --limit=5 News, we have an<br />

anonymous parameter whose value isNews while the named parameter limit is taking the<br />

value 5.<br />

To use anonymous parameters, a command action must declare a parameter named as<br />

$args. For example,<br />

public function actionIndex($limit=10, $args=array()) {...}<br />

The $args array will hold all available anonymous parameter values.

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

Saved successfully!

Ooh no, something went wrong!