Newscoop\Image\LocalImage::setStatus PHP Метод

setStatus() публичный Метод

Sets the value of status.
public setStatus ( string $status = null ) : self
$status string the status
Результат self
    public function setStatus($status = null)
    {
        $this->status = self::STATUS_UNAPPROVED;
        if ($status == self::STATUS_APPROVED) {
            $this->status = $status;
        }
        return $this;
    }

Usage Example

Пример #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;
 }