diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php
index 4c002cb19..7f18b24e0 100644
--- a/lib/Cake/View/Helper/HtmlHelper.php
+++ b/lib/Cake/View/Helper/HtmlHelper.php
@@ -684,21 +684,8 @@ class HtmlHelper extends AppHelper {
public function getCrumbs($separator = '»', $startText = false) {
if (!empty($this->_crumbs)) {
$out = array();
- if ($startText) {
- if (!is_array($startText)) {
- $startText = array(
- 'url' => '/',
- 'text' => $startText
- );
- }
- $startText += array('url' => '/', 'text' => __('Home'));
- list($url, $text) = array($startText['url'], $startText['text']);
- unset($startText['url'], $startText['text']);
-
- $out[] = $this->link($text, $url, $startText);
- }
-
- foreach ($this->_crumbs as $crumb) {
+ $crumbs = $this->_prepareCrumbs($startText);
+ foreach ($crumbs as $crumb) {
if (!empty($crumb[1])) {
$out[] = $this->link($crumb[0], $crumb[1], $crumb[2]);
} else {
@@ -727,19 +714,7 @@ class HtmlHelper extends AppHelper {
public function getCrumbList($options = array(), $startText = false) {
if (!empty($this->_crumbs)) {
$result = '';
- $crumbs = $this->_crumbs;
- if ($startText) {
- if (!is_array($startText)) {
- $startText = array(
- 'url' => '/',
- 'text' => $startText
- );
- }
- $startText += array('url' => '/', 'text' => __('Home'));
- list($url, $text) = array($startText['url'], $startText['text']);
- unset($startText['url'], $startText['text']);
- array_unshift($crumbs, array($text, $url, $startText));
- }
+ $crumbs = $this->_prepareCrumbs($startText);
$crumbCount = count($crumbs);
$ulOptions = $options;
foreach ($crumbs as $which => $crumb) {
@@ -762,6 +737,29 @@ class HtmlHelper extends AppHelper {
}
}
+/**
+ * Prepends startText to crumbs array if set
+ *
+ * @param $startText
+ * @return array Crumb list including startText (if provided)
+ */
+ protected function _prepareCrumbs($startText) {
+ $crumbs = $this->_crumbs;
+ if ($startText) {
+ if (!is_array($startText)) {
+ $startText = array(
+ 'url' => '/',
+ 'text' => $startText
+ );
+ }
+ $startText += array('url' => '/', 'text' => __('Home'));
+ list($url, $text) = array($startText['url'], $startText['text']);
+ unset($startText['url'], $startText['text']);
+ array_unshift($crumbs, array($text, $url, $startText));
+ }
+ return $crumbs;
+ }
+
/**
* Creates a formatted IMG element.
*