@@ -129,11 +129,11 @@ abstract class AbstractDatatable implements DatatableInterface
129129 protected $ language ;
130130
131131 /**
132- * The unique name for this instance.
132+ * The unique id for this instance.
133133 *
134- * @var string
134+ * @var int
135135 */
136- protected $ uniqueName ;
136+ protected $ uniqueId ;
137137
138138 /**
139139 * The PropertyAccessor.
@@ -142,6 +142,15 @@ abstract class AbstractDatatable implements DatatableInterface
142142 */
143143 protected $ accessor ;
144144
145+ //-------------------------------------------------
146+
147+ /**
148+ * Used to generate unique names.
149+ *
150+ * @var array
151+ */
152+ protected static $ uniqueCounter = array ();
153+
145154 //-------------------------------------------------
146155 // Ctor.
147156 //-------------------------------------------------
@@ -167,7 +176,12 @@ public function __construct(
167176 Twig_Environment $ twig
168177 ) {
169178 $ this ->validateName ();
170- $ this ->uniqueName = uniqid ($ this ->getName ().'- ' );
179+
180+ if (isset (self ::$ uniqueCounter [$ this ->getName ()])) {
181+ $ this ->uniqueId = ++self ::$ uniqueCounter [$ this ->getName ()];
182+ } else {
183+ $ this ->uniqueId = self ::$ uniqueCounter [$ this ->getName ()] = 1 ;
184+ }
171185
172186 $ this ->authorizationChecker = $ authorizationChecker ;
173187 $ this ->securityToken = $ securityToken ;
@@ -290,12 +304,20 @@ public function getOptionsArrayFromEntities($entities, $keyFrom = 'id', $valueFr
290304 return $ options ;
291305 }
292306
307+ /**
308+ * {@inheritdoc}
309+ */
310+ public function getUniqueId ()
311+ {
312+ return $ this ->uniqueId ;
313+ }
314+
293315 /**
294316 * {@inheritdoc}
295317 */
296318 public function getUniqueName ()
297319 {
298- return $ this ->uniqueName ;
320+ return $ this ->getName ().( $ this -> getUniqueId () > 1 ? ' - ' . $ this -> getUniqueId () : '' ) ;
299321 }
300322
301323 //-------------------------------------------------
0 commit comments