Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit ff8955b

Browse files
committed
Merge pull request #116 from symfony-cmf/sanity-checks
add some sanity checks in ContentAwareFactory
2 parents a0ef7e8 + 23649df commit ff8955b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ContentAwareFactory.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,16 @@ public function createItem($name, array $options = array())
224224
return null;
225225
}
226226
}
227+
unset($options['route']);
228+
break;
227229
case 'uri':
228230
unset($options['route']);
229231
break;
230232
case 'route':
231233
unset($options['uri']);
232234
break;
235+
default:
236+
throw new \RuntimeException(sprintf('Internal error: unexpected linkType "%s"', $options['linkType']));
233237
}
234238

235239
$item = parent::createItem($name, $options);
@@ -261,17 +265,20 @@ protected function determineLinkType($options)
261265
if (!empty($options['content'])) {
262266
return 'content';
263267
}
268+
269+
return 'uri';
264270
}
265271

266272
/**
267-
* Ensure that we have valid link types
273+
* Ensure that we have a valid link type.
274+
*
275+
* @param string $linkType
276+
*
277+
* @throws \InvalidArgumentException if $linkType is not one of the known
278+
* link types
268279
*/
269280
protected function validateLinkType($linkType)
270281
{
271-
if (!$linkType) {
272-
return 'uri';
273-
}
274-
275282
if (!in_array($linkType, $this->linkTypes)) {
276283
throw new \InvalidArgumentException(sprintf(
277284
'Invalid link type "%s". Valid link types are: "%s"',

0 commit comments

Comments
 (0)