Newscoop\Image\ImageService::fillImage PHP Method

fillImage() public method

Fill image with custom/default arttributes
public fillImage ( LocalImage $image, array $attributes ) : LocalImage
$image LocalImage
$attributes array
return LocalImage
    public function fillImage($image, $attributes)
    {
        $attributes = array_merge(array('date' => date('Y-m-d'), 'content_type' => 'image/jpeg', 'user' => null, 'updated' => new \DateTime(), 'status' => 'unapproved', 'source' => 'local', 'description' => ''), $attributes);
        if (isset($attributes['description'])) {
            $image->setDescription($attributes['description']);
        }
        if (isset($attributes['photographer'])) {
            $image->setPhotographer($attributes['photographer']);
        }
        if (isset($attributes['photographer_url'])) {
            $image->setPhotographerUrl($attributes['photographer_url']);
        }
        if (isset($attributes['place'])) {
            $image->setPlace($attributes['place']);
        }
        $image->setDate($attributes['date']);
        $image->setContentType($attributes['content_type']);
        $image->setUser($attributes['user']);
        $image->setUpdated($attributes['updated']);
        $image->setSource($attributes['source']);
        if (isset($attributes['url'])) {
            $image->setUrl($attributes['url']);
        }
        if ($image->getUser() && $image->getUser()->isAdmin() == true) {
            $image->setStatus('approved');
        } else {
            $image->setStatus($attributes['status']);
        }
        return $image;
    }