Breaded Sonata Admin Icon

I have a little problem with the sonata administrator on symfony I would change the default admin label to breadcrumb

enter image description here

but I can’t find a solution, can someone help me?

I found this function, but it doesn’t work, it looks like this function is not called

public function buildBreadcrumbs($action, MenuItemInterface $menu = null) {
    $breadCrumb =  parent::buildBreadcrumbs($action, $menu);

    return $breadCrumb;
}

ps. i am using symfony 2.8 thanks

+4
source share
2 answers

Try overriding the classNameLabel property in your admin class

// in your ProductAdmin class
public function configure()
{
    parent::configure();
    $this->classnameLabel = "Products";
}
+8
source

The easiest way to achieve what you want is to change the translations of the messages.

If you really want to change the labels, you can implement your own label generation strategy.

namespace Blast\CoreBundle\Translator;

use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;

/**
 * Class LibrinfoLabelTranslatorStrategy.
 *
 * Provides a specific label translation strategy for Librinfo.
 * It is based on UnderscoreLabelTranslatorStrategy, but without the context,
 * and labels are prefixed by "librinfo.label."
 *
 * i.e. isValid => librinfo.label.is_valid
 */
class LibrinfoLabelTranslatorStrategy implements LabelTranslatorStrategyInterface
{
    /**
     * {@inheritdoc}
     */
    public function getLabel($label, $context = '', $type = '')
    {
        $label = str_replace('.', '_', $label);

        return sprintf('%s.%s.%s', "librinfo", $type, strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $label)));
    }
}

blast_core.label.strategy.librinfo:
        class: Blast\CoreBundle\Translator\LibrinfoLabelTranslatorStrategy

:

crm.organism:
        class: Librinfo\CRMBundle\Admin\OrganismAdmin
        arguments: [~, Librinfo\CRMBundle\Entity\Organism, LibrinfoCRMBundle:OrganismAdmin]
        tags:
            -   name: sonata.admin
                manager_type: orm
                group: Customers Relationship Management
                label_translator_strategy: blast_core.label.strategy.librinfo

admin

.: SonataAdmin:

0

Source: https://habr.com/ru/post/1664616/


All Articles