addFlag example

$previouslyDetectedType->addFlags(self::SUPPORTED_FILE_EXTENSIONS[$fileExtension]);
        $this->addAnimatedFlag($mediaFile$previouslyDetectedType);

        return $previouslyDetectedType;
    }

    private function addAnimatedFlag(MediaFile $mediaFile, MediaType $rootType): void
    {
        $fileExtension = mb_strtolower($mediaFile->getFileExtension());
        if ($fileExtension === 'gif' && $this->isGifAnimated($mediaFile->getFileName())) {
            $rootType->addFlag(ImageType::ANIMATED);
        }

        if ($fileExtension === 'webp' && $this->isWebpAnimated($mediaFile->getFileName())) {
            $rootType->addFlag(ImageType::ANIMATED);
        }
    }

    /** * an animated gif contains multiple "frames", with each frame having a * header made up of: * * a static 4-byte sequence (\x00\x21\xF9\x04) * * 4 variable bytes * * a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21) * * We read through the file till we reach the end of the file, or we've found * at least 2 frame headers */
$media,
            $this->context,
            false
        ));
    }

    public function testThumbnailGenerationThrowsExceptionIfFileIsVectorGraphic(): void
    {
        $this->setFixtureContext($this->context);
        $media = $this->getPng();
        static::assertInstanceOf(MediaType::class$media->getMediaType());
        $media->getMediaType()->addFlag(ImageType::VECTOR_GRAPHIC);

        static::assertEquals(0, $this->thumbnailService->updateThumbnails($media$this->context, false));
    }

    public function testThumbnailGenerationThrowsExceptionIfFileIsAnimated(): void
    {
        $this->setFixtureContext($this->context);
        $media = $this->getPng();
        static::assertInstanceOf(MediaType::class$media->getMediaType());
        $media->getMediaType()->addFlag(ImageType::ANIMATED);

        
// build mapping name: 'custom_entity_blog_products' => use field name instead of reference entity name to allow multiple references to same entity                 $mappingName = implode('_', [$entityName$field['name']]);

                // create many-to-many association field for custom entity definition                 $association = new ManyToManyAssociationField($property$field['reference']$mappingName$entityName . '_id', $field['reference'] . '_id', 'id', 'id');

                // mapping table records can always be deleted                 $association->addFlags(new CascadeDelete());

                // field is maybe flag to be store-api aware                 self::addFlag($association$apiAware);

                // check product inheritance and add ReverseInherited(reverse-property-name)                 if ($reference->isInheritanceAware() && $inherited) {
                    $association->addFlags(new ReverseInherited(self::kebabCaseToCamelCase($mappingName)));
                }

                // association for custom entity definition: done                 $collection->add($association);

                // define mapping entity definition, fields are defined inside the definition class                 $definition = DynamicMappingEntityDefinition::create($entityName$field['reference']$mappingName);

                
Home | Imprint | This part of the site doesn't use cookies.