src/Twig/Extension/NetworkingHelperExtension.php
public function getCurrentAdminLocale(\Sonata\AdminBundle\Admin\AdminInterface $admin)
    {
        $locale = '';

        if (!$admin->hasRequest()) {
            $admin->setRequest($this->requestStack->getCurrentRequest());
        }

        if ($subject = $admin->getSubject()) {
            return $this->getFieldValue($subject, 'locale');
        } elseif ($filter = $admin->getDatagrid()->getFilter('locale')) {
            /** @var \Sonata\AdminBundle\Filter\Filter $filter */
            $data = $filter->getValue();
            if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
                $locale = $this->getCurrentLocale();
            }

            $data['value'] = trim($data['value']);

            if (strlen($data['value']) > 0) {
                $locale = $data['value'];
            }

            if (!$locale && method_exists($admin, 'getDefaultLocale')) {
                $locale = $admin->getDefaultLocale();
            }
        }

        return $locale;
    }
public function getCurrentAdminLocale(\Sonata\AdminBundle\Admin\AdminInterface $admin)
    {
        $locale = '';

        if (!$admin->hasRequest()) {
            $admin->setRequest($this->requestStack->getCurrentRequest());
        }

        if ($subject = $admin->getSubject()) {
            return $this->getFieldValue($subject, 'locale');
        } elseif ($filter = $admin->getDatagrid()->getFilter('locale')) {
            /** @var \Sonata\AdminBundle\Filter\Filter $filter */
            $data = $filter->getValue();
            if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
                $locale = $this->getCurrentLocale();
            }

            $data['value'] = trim($data['value']);

            if (strlen($data['value']) > 0) {
                $locale = $data['value'];
            }

            if (!$locale && method_exists($admin, 'getDefaultLocale')) {
                $locale = $admin->getDefaultLocale();
            }
        }

        return $locale;
    }
public function getCurrentAdminLocale ( \ Sonata \ AdminBundle \ Admin \ AdminInterface $ admin ) { $ locale = '' ; if ( ! $ admin -> hasRequest ( ) ) { $ admin -> setRequest ( $ this -> requestStack -> getCurrentRequest ( ) ) ; } if ( $ subject = $ admin -> getSubject ( ) ) { return $ this -> getFieldValue ( $ subject , 'locale' ) ; } elseif ( $ filter = $ admin -> getDatagrid ( ) -> getFilter ( 'locale' ) ) { /** @var \Sonata\AdminBundle\Filter\Filter $filter */ $ data = $ filter -> getValue ( ) ; if ( ! $ data || ! is_array ( $ data ) || ! array_key_exists ( 'value' , $ data ) ) { $ locale = $ this -> getCurrentLocale ( ) ; } $ data [ 'value' ] = trim ( $ data [ 'value' ] ) ; if ( strlen ( $ data [ 'value' ] ) > 0 ) { $ locale = $ data [ 'value' ] ; } if ( ! $ locale && method_exists ( $ admin , 'getDefaultLocale' ) ) { $ locale = $ admin -> getDefaultLocale ( ) ; } } return $ locale ; }
returns the locale of the current admin user.

@param AdminInterface $admin

@return mixed|string
returns the locale of the current admin user .