classes/Layout/Breadcrumbs.php
public function parseURL()
    {
        $breadcrumbs = [];

        // Get the segments
        $path = Request::path();
        $segments = explode('/', $path);

        // Loop through them in blocks of 2: [list, detail]
        $url = $segments[0];
        for ($i=1; $i<count($segments); $i+=2) {

            // If an action URL, you're at the end of the URL
            if (in_array($segments[$i], ['edit'])) {
                break;
            }

            // Figure out the controller given the url partial
            $url .= '/' . $segments[$i];
            $router = new Wildcard($segments[0], 'GET', $url);
            if (!($controller = $router->detectController())) {
                continue;
            }
            $controller = new $controller;

            // Add controller to breadcrumbs
            $breadcrumbs[URL::to($url)] = strip_tags($controller->title(), '<img>');

            // Add a detail if it exists
            if (!isset($segments[$i+1])) {
                break;
            }
            $id = $segments[$i+1];

            // On a "new" page
            if ($id == 'create') {
                $url .= '/' . $id;
                $breadcrumbs[URL::to($url)] = __('decoy::breadcrumbs.new');

            // On an edit page
            } elseif (is_numeric($id)) {
                $url .= '/' . $id;
                $item = $this->find($controller, $id);
                $title = $item->getAdminTitleAttribute();
                $breadcrumbs[URL::to($url.'/edit')] = $title;
            }
        }

        // Return the full list
        return $breadcrumbs;
    }
public function parseURL()
    {
        $breadcrumbs = [];

        // Get the segments
        $path = Request::path();
        $segments = explode('/', $path);

        // Loop through them in blocks of 2: [list, detail]
        $url = $segments[0];
        for ($i=1; $i<count($segments); $i+=2) {

            // If an action URL, you're at the end of the URL
            if (in_array($segments[$i], ['edit'])) {
                break;
            }

            // Figure out the controller given the url partial
            $url .= '/' . $segments[$i];
            $router = new Wildcard($segments[0], 'GET', $url);
            if (!($controller = $router->detectController())) {
                continue;
            }
            $controller = new $controller;

            // Add controller to breadcrumbs
            $breadcrumbs[URL::to($url)] = strip_tags($controller->title(), '<img>');

            // Add a detail if it exists
            if (!isset($segments[$i+1])) {
                break;
            }
            $id = $segments[$i+1];

            // On a "new" page
            if ($id == 'create') {
                $url .= '/' . $id;
                $breadcrumbs[URL::to($url)] = __('decoy::breadcrumbs.new');

            // On an edit page
            } elseif (is_numeric($id)) {
                $url .= '/' . $id;
                $item = $this->find($controller, $id);
                $title = $item->getAdminTitleAttribute();
                $breadcrumbs[URL::to($url.'/edit')] = $title;
            }
        }

        // Return the full list
        return $breadcrumbs;
    }
public function parseURL ( ) { $ breadcrumbs = [ ] ; // Get the segments $ path = Request :: path ( ) ; $ segments = explode ( '/' , $ path ) ; // Loop through them in blocks of 2: [list, detail] $ url = $ segments [ 0 ] ; for ( $ i = 1 ; $ i < count ( $ segments ) ; $ i += 2 ) { // If an action URL, you're at the end of the URL if ( in_array ( $ segments [ $ i ] , [ 'edit' ] ) ) { break ; } // Figure out the controller given the url partial $ url .= '/' . $ segments [ $ i ] ; $ router = new Wildcard ( $ segments [ 0 ] , 'GET' , $ url ) ; if ( ! ( $ controller = $ router -> detectController ( ) ) ) { continue ; } $ controller = new $ controller ; // Add controller to breadcrumbs $ breadcrumbs [ URL :: to ( $ url ) ] = strip_tags ( $ controller -> title ( ) , '<img>' ) ; // Add a detail if it exists if ( ! isset ( $ segments [ $ i + 1 ] ) ) { break ; } $ id = $ segments [ $ i + 1 ] ; // On a "new" page if ( $ id == 'create' ) { $ url .= '/' . $ id ; $ breadcrumbs [ URL :: to ( $ url ) ] = __ ( 'decoy::breadcrumbs.new' ) ; // On an edit page } elseif ( is_numeric ( $ id ) ) { $ url .= '/' . $ id ; $ item = $ this -> find ( $ controller , $ id ) ; $ title = $ item -> getAdminTitleAttribute ( ) ; $ breadcrumbs [ URL :: to ( $ url . '/edit' ) ] = $ title ; } } // Return the full list return $ breadcrumbs ; }
Step through the URL, creating controller and model objects for relevant
segments to populate richer data in the breadcrumbs, automatically

@return array
Step through the URL creating controller and model objects for relevant segments to populate richer data in the breadcrumbs automatically