<commit_before><?php
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\AdminBundle\View\WidgetGenerator\LogEntry;

use Darvin\AdminBundle\Entity\LogEntry;
use Darvin\AdminBundle\Security\Permissions\Permission;
use Darvin\AdminBundle\View\WidgetGenerator\AbstractWidgetGenerator;
use Darvin\Utils\Strings\StringsUtil;

/**
 * Log entry entity name view widget generator
 */
class EntityNameGenerator extends AbstractWidgetGenerator
{
    /**
     * {@inheritdoc}
     */
    public function generate($entity, array $options = array())
    {
        /** @var \Darvin\AdminBundle\Entity\LogEntry $entity */
        $this->validate($entity, $options);

        if (!$this->isGranted(Permission::VIEW, $entity)) {
            return '';
        }

        return 'log.entity.object_names.'.$this->getEntityName($entity->getObjectClass());
    }

    /**
     * {@inheritdoc}
     */
    public function getAlias()
    {
        return 'log_entry_entity_name';
    }

    /**
     * {@inheritdoc}
     */
    protected function getRequiredEntityClass()
    {
        return LogEntry::LOG_ENTRY_CLASS;
    }

    /**
     * @param string $entityClass Entity class
     *
     * @return string
     */
    private function getEntityName($entityClass)
    {
        if ($this->metadataManager->hasMetadataForEntityClass($entityClass)) {
            return $this->metadataManager->getByEntityClass($entityClass)->getEntityName();
        }

        $parts = explode('\\', $entityClass);
        $offset = array_search('Entity', $parts);

        if ($offset) {
            $parts = array_slice($parts, $offset + 1);
        }

        return StringsUtil::toUnderscore(implode('_', $parts));
    }
}
<commit_msg>Change log entry entity name prefix.<commit_after><?php
/**
 * @author    <NAME> <ig<EMAIL>>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\AdminBundle\View\WidgetGenerator\LogEntry;

use Darvin\AdminBundle\Entity\LogEntry;
use Darvin\AdminBundle\Security\Permissions\Permission;
use Darvin\AdminBundle\View\WidgetGenerator\AbstractWidgetGenerator;
use Darvin\Utils\Strings\StringsUtil;

/**
 * Log entry entity name view widget generator
 */
class EntityNameGenerator extends AbstractWidgetGenerator
{
    /**
     * {@inheritdoc}
     */
    public function generate($entity, array $options = array())
    {
        /** @var \Darvin\AdminBundle\Entity\LogEntry $entity */
        $this->validate($entity, $options);

        if (!$this->isGranted(Permission::VIEW, $entity)) {
            return '';
        }

        return 'log.object.'.$this->getEntityName($entity->getObjectClass());
    }

    /**
     * {@inheritdoc}
     */
    public function getAlias()
    {
        return 'log_entry_entity_name';
    }

    /**
     * {@inheritdoc}
     */
    protected function getRequiredEntityClass()
    {
        return LogEntry::LOG_ENTRY_CLASS;
    }

    /**
     * @param string $entityClass Entity class
     *
     * @return string
     */
    private function getEntityName($entityClass)
    {
        if ($this->metadataManager->hasMetadataForEntityClass($entityClass)) {
            return $this->metadataManager->getByEntityClass($entityClass)->getEntityName();
        }

        $parts = explode('\\', $entityClass);
        $offset = array_search('Entity', $parts);

        if ($offset) {
            $parts = array_slice($parts, $offset + 1);
        }

        return StringsUtil::toUnderscore(implode('_', $parts));
    }
}

{'fraction_non_alphanumeric': 0.13326446280991736, 'fraction_numerical': 0.0025826446280991736, 'mean_word_length': 2.7970588235294116, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4665055', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1077, 'n_words': 227}