149 public function add( $template, $userData ) {
150 $parts = explode(
'/', $template );
151 $length = count( $parts );
152 if ( !isset( $this->treesByLength[$length] ) ) {
153 $this->treesByLength[$length] = [];
155 $tree =& $this->treesByLength[$length];
156 $conflict = $this->findConflict( $tree, $parts );
157 if ( $conflict !==
false ) {
158 throw new PathConflict( $template, $userData, $conflict );
162 foreach ( $parts as $index => $part ) {
163 $paramName = $this->getParamName( $part );
164 if ( $paramName !==
false ) {
165 $params[] = $paramName;
170 if ( $index === $length - 1 ) {
172 'template' => $template,
173 'paramNames' => $params,
174 'userData' => $userData
176 } elseif ( !isset( $tree[$key] ) ) {
179 $tree =& $tree[$key];