|
|
@ -25,6 +25,17 @@ use ReflectionClass; |
|
|
|
class Widget extends Component implements ViewContextInterface |
|
|
|
class Widget extends Component implements ViewContextInterface |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* @var integer a counter used to generate [[id]] for widgets. |
|
|
|
|
|
|
|
* @internal |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static $counter = 0; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var string the prefix to the automatically generated widget IDs. |
|
|
|
|
|
|
|
* @see [[getId()]] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static $autoIdPrefix = 'w'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @var Widget[] the widgets that are currently being rendered (not ended). This property |
|
|
|
* @var Widget[] the widgets that are currently being rendered (not ended). This property |
|
|
|
* is maintained by [[begin()]] and [[end()]] methods. |
|
|
|
* is maintained by [[begin()]] and [[end()]] methods. |
|
|
|
* @internal |
|
|
|
* @internal |
|
|
@ -96,7 +107,7 @@ class Widget extends Component implements ViewContextInterface |
|
|
|
public function getId($autoGenerate = true) |
|
|
|
public function getId($autoGenerate = true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($autoGenerate && $this->_id === null) { |
|
|
|
if ($autoGenerate && $this->_id === null) { |
|
|
|
$this->_id = 'w-' . str_replace('.', '-', uniqid('', true)); |
|
|
|
$this->_id = self::$autoIdPrefix . self::$counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
return $this->_id; |
|
|
|
return $this->_id; |
|
|
|
} |
|
|
|
} |
|
|
|