<commit_before><?php

namespace OpenOrchestra\ApiBundle\Mapping;

use OpenOrchestra\Mapping\Annotations\Search;
use OpenOrchestra\ModelInterface\Model\FieldTypeInterface;
use OpenOrchestra\ModelInterface\Model\ContentTypeInterface;
use OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface;

/**
 * Class MappingContentAttribute
 */
class MappingContentAttribute
{
    /**
     * @var ContentTypeRepositoryInterface
     */
    protected $contentTypeRepository;

    /***
     * @param ContentTypeRepositoryInterface $contentTypeRepository
     */
    public function __construct(ContentTypeRepositoryInterface $contentTypeRepository)
    {
        $this->contentTypeRepository = $contentTypeRepository;
    }

    /**
     * @param string $contentTypeId
     *
     * @return array
     */
    public function getMapping($contentTypeId)
    {
        $mapping = array();

        /**
         * @var ContentTypeInterface
         */
        $contentType  = $this->contentTypeRepository->findOneByContentTypeIdInLastVersion($contentTypeId);
        if (null !== $contentType) {
            /**
             * @var $field FieldTypeInterface
             */
            foreach ($contentType->getFields() as $field) {
                $fieldId = $field->getFieldId();
                $key = 'attributes.'.$fieldId.'.string_value';
                $mapping[$key] = new Search(array(
                    'field' => 'attributes.'.$fieldId.'.stringValue',
                    'key' => $key
                ));<commit_msg>fix search in attributes context<commit_after><?php

namespace OpenOrchestra\ApiBundle\Mapping;

use OpenOrchestra\Mapping\Annotations\Search;
use OpenOrchestra\ModelInterface\Model\FieldTypeInterface;
use OpenOrchestra\ModelInterface\Model\ContentTypeInterface;
use OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface;

/**
 * Class MappingContentAttribute
 */
class MappingContentAttribute
{
    /**
     * @var ContentTypeRepositoryInterface
     */
    protected $contentTypeRepository;

    /***
     * @param ContentTypeRepositoryInterface $contentTypeRepository
     */
    public function __construct(ContentTypeRepositoryInterface $contentTypeRepository)
    {
        $this->contentTypeRepository = $contentTypeRepository;
    }

    /**
     * @param string $contentTypeId
     *
     * @return array
     */
    public function getMapping($contentTypeId)
    {
        $mapping = array();

        /**
         * @var ContentTypeInterface
         */
        $contentType  = $this->contentTypeRepository->findOneByContentTypeIdInLastVersion($contentTypeId);
        if (null !== $contentType) {
            /**
             * @var $field FieldTypeInterface
             */
            foreach ($contentType->getFields() as $field) {
                $fieldId = $field->getFieldId();
                $key = 'attributes.'.$fieldId.'.string_value';
                $mapping[$key] = array(
                    'field' => 'attributes.'.$fieldId.'.stringValue',
                    'key' => $key,
                    'type' => 'string'
                );
{'fraction_non_alphanumeric': 0.11161145062721133, 'fraction_numerical': 0.0, 'mean_word_length': 2.474860335195531, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2357855', 'n_tokens_mistral': 792, 'n_tokens_neox': 785, 'n_words': 131}