setSource() public method

Sets the value of source.
public setSource ( string $source ) : self
$source string the source
return self
Exemplo n.º 1
0
 /**
  * Fill image with custom/default arttributes
  *
  * @param LocalImage $image
  * @param array      $attributes
  *
  * @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;
 }