PHP code example of rollerworks / breadcrumbs-bundle
1. Go to this page and download the library: Download rollerworks/breadcrumbs-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rollerworks / breadcrumbs-bundle example snippets
// in AppKernel::registerBundles()
$bundles = [
// ...
new Rollerworks\Bundle\BreadcrumbsBundle\RollerworksBreadcrumbsBundle(),
// ...
];
namespace Acme\Customer;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\Breadcrumb;
use Symfony\Component\HttpFoundation\Request;
class CustomerBreadcrumbsProvider
{
/**
* @Breadcrumb(name="acme_customer_home", route="acme_customer_home")
*/
public function home(Request $request, array $breadcrumb)
{
return [
'label' => 'Account',
'route' => $breadcrumb['route'],
];
}
}
namespace Acme\Customer;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\BreadcrumbProvider;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\Breadcrumb;
use Symfony\Component\HttpFoundation\Request;
/**
* @BreadcrumbProvider(namePrefix="acme_customer.", routePrefix="acme_customer_", parent="app_homepage")
*/
class CustomerBreadcrumbsProvider
{
/**
* @Breadcrumb(name="home", route="home")
*/
public function home(Request $request, array $breadcrumb)
{
return [
'label' => 'Account',
'route' => $breadcrumb['route'],
];
}
/**
* @Breadcrumb(name="edit", route="edit")
*/
public function edit(Request $request, array $breadcrumb)
{
return [
'label' => 'Account',
'route' => $breadcrumb['route'],
];
}
}
namespace Acme\Customer;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\BreadcrumbProvider;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\Breadcrumb;
use Symfony\Component\HttpFoundation\Request;
/**
* @BreadcrumbProvider(namePrefix="acme_customer.", routePrefix="acme_customer_", parent="app_homepage")
*/
class CustomerBreadcrumbsProvider
{
/**
* @Breadcrumb(name="home", route="home")
*/
public function home(Request $request, array $breadcrumb)
{
return [
'label' => 'Account',
'route' => $breadcrumb['route'],
];
}
/**
* @Breadcrumb(name="edit", route="edit")
*/
public function edit(Request $request, array $breadcrumb)
{
return [
'label' => 'Account',
'route' => $breadcrumb['route'],
];
}
/**
* @Breadcrumb(fullName="acme_customer.group_list", fullRoute="acme_group_list", parent="")
*/
public function listGroups(Request $request, array $breadcrumb)
{
return [
'label' => 'Account',
'route' => $breadcrumb['route'],
];
}
}
namespace Acme\Customer;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\BreadcrumbProvider;
use Rollerworks\Bundle\BreadcrumbsBundle\Annotation\Breadcrumb;
use Symfony\Component\HttpFoundation\Request;
/**
* @BreadcrumbProvider(namePrefix="acme_customer.", routePrefix="acme_customer_", parent="app_homepage")
*/
class CustomerBreadcrumbsProvider
{
/**
* @Breadcrumb(name="acme_customer.home", route="home", label="Account")
* @Breadcrumb(name="acme_customer.edit", route="edit", label="Edit", parent="acme_customer.home")
*/
public function action(Request $request, array $breadcrumb)
{
return [
'label' => $breadcrumb['extra']['label'],
'route' => $breadcrumb['route'],
];
}
}
bash
$ php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.