src/Entity/ImageSet.php
public function set($key, ImageInterface $image, $check = true)
    {
        $images = $this->getImages();
        if ($check && ($img = $this->get($key))) {
            $images->removeElement($img);
        }

        $image->setBelongsTo($this->id);
        $image->setKey($key);

        $images->add($image);

        return $this;
    }
public function set($key, ImageInterface $image, $check = true)
    {
        $images = $this->getImages();
        if ($check && ($img = $this->get($key))) {
            $images->removeElement($img);
        }

        $image->setBelongsTo($this->id);
        $image->setKey($key);

        $images->add($image);

        return $this;
    }
public function set ( $ key , ImageInterface $ image , $ check = true ) { $ images = $ this -> getImages ( ) ; if ( $ check && ( $ img = $ this -> get ( $ key ) ) ) { $ images -> removeElement ( $ img ) ; } $ image -> setBelongsTo ( $ this -> id ) ; $ image -> setKey ( $ key ) ; $ images -> add ( $ image ) ; return $ this ; }
Set an image.

Replaces any image with the same $key, unless $check is false.

@param string         $key
@param ImageInterface $image
@param bool           $check

@return self
Set an image .