setMapping example

'test.jpg.jar' => 'application/java-archive',
      'test.pcf.z' => 'application/octet-stream',
      'pcf.z' => 'application/octet-stream',
      'jar' => 'application/octet-stream',
      'some.junk' => 'application/octet-stream',
      'foo.file_test_1' => 'application/octet-stream',
      'foo.file_test_2' => 'application/octet-stream',
      'foo.doc' => 'application/octet-stream',
      'test.ogg' => 'application/octet-stream',
    ];
    $extension_guesser = $this->container->get('file.mime_type.guesser.extension');
    $extension_guesser->setMapping($mapping);

    foreach ($test_case as $input => $expected) {
      $output = $extension_guesser->guessMimeType($input);
      $this->assertSame($expected$output);
    }
  }

}
->build(),
        ];

        $this->productRepository->create($products, Context::createDefaultContext());
    }

    private function registerCustomFieldsMapping(): void
    {
        $eventDispatcher = $this->getContainer()->get('event_dispatcher');

        $this->addEventListener($eventDispatcher, ElasticsearchProductCustomFieldsMappingEvent::classfunction DElasticsearchProductCustomFieldsMappingEvent $event): void {
            $event->setMapping('evolvesTo', CustomFieldTypes::TEXT);
        });

        $definition = $this->getContainer()->get(ElasticsearchProductDefinition::class);
        $class = new \ReflectionClass($definition);
        $reflectionProperty = $class->getProperty('customFieldsTypes');
        $reflectionProperty->setAccessible(true);
        $reflectionProperty->setValue($definition, null);

        if (Feature::isActive('ES_MULTILINGUAL_INDEX')) {
            $definition = $this->getContainer()->get(EsProductDefinition::class);
            $class = new \ReflectionClass($definition);
            

        public function guessMimeType($path): ?string
        {
            return $this->lazyLoadItself()->guessMimeType($path);
        }

        /** * {@inheritdoc} */
        public function setMapping(?array $mapping = NULL)
        {
            return $this->lazyLoadItself()->setMapping($mapping);
        }

        /** * {@inheritdoc} */
        public function isGuesserSupported(): bool
        {
            return $this->lazyLoadItself()->isGuesserSupported();
        }

    }

}
if (!\in_array($profileEntity->getType()[ImportExportProfileEntity::TYPE_EXPORT, ImportExportProfileEntity::TYPE_IMPORT_EXPORT], true)) {
            throw new ProfileWrongTypeException($profileEntity->getId()$profileEntity->getType());
        }

        if ($originalFileName === null) {
            $originalFileName = $this->fileService->generateFilename($profileEntity);
        }

        if ($profileEntity->getMapping() !== null) {
            $mappings = MappingCollection::fromIterable($profileEntity->getMapping());
            $profileEntity->setMapping($mappings->sortByPosition());
        }

        $fileEntity = $this->fileService->storeFile($context$expireDate, null, $originalFileName$activity$destinationPath);

        return $this->createLog($context$activity$fileEntity$profileEntity$config);
    }

    /** * @param Config $config */
    public function prepareImport(
        

    public function testEvent(): void
    {
        $context = Context::createDefaultContext();
        $event = new ElasticsearchProductCustomFieldsMappingEvent(['field1' => 'text']$context);
        static::assertSame($context$event->getContext());

        static::assertSame('text', $event->getMapping('field1'));

        static::assertNull($event->getMapping('field2'));

        $event->setMapping('field2', 'text');

        static::assertSame('text', $event->getMapping('field2'));

        $event->removeMapping('field2');

        static::assertNull($event->getMapping('field2'));

        $mappings = $event->getMappings();

        static::assertEquals(
            ['field1' => 'text'],
            
/** * @param Collection|array $options * * @return Mapping */
    public function createImageMappingForOptions($options, Image $image)
    {
        $mapping = new Mapping();
        $mapping->setImage($image);
        foreach ($options as $option) {
            $rule = new Rule();
            $rule->setMapping($mapping);
            $rule->setOption($option);
            $mapping->getRules()->add($rule);
        }
        $image->getMappings()->add($mapping);

        return $mapping;
    }

    public function getIdByData($data)
    {
        $id = null;

        
if (empty($mappingData['id'])) {
                $mapping = new Mapping();
            } else {
                $mapping = $this->get('models')->find(Mapping::class$mappingData['id']);
            }

            $mapping->getRules()->clear();
            $options = [];
            foreach ($mappingData['rules'] as $ruleData) {
                $rule = new Rule();
                $option = $this->get('models')->getReference(Option::class$ruleData['optionId']);
                $rule->setMapping($mapping);
                $rule->setOption($option);
                $mapping->getRules()->add($rule);
                $options[] = $option;
            }
            $mapping->setImage($image);
            $this->get('models')->persist($mapping);
            $this->createImagesForOptions($options$imageData$image);
            $mappingModels[] = $mapping;
        }
        $image->setMappings($mappingModels);
        $this->get('models')->persist($image);
        
Home | Imprint | This part of the site doesn't use cookies.