If the classified is >= 6 months old is expired

@param Document $document
@return boolean
181063
protected function getIsExpired(Document $document) 
	{
		$date = null === $document->getDateEdit() ? $document->getDateInsert() : $document->getDateEdit();
		$now = new \Datetime("now");
		$interval = $date->diff($now);
		
		if ($interval->y > 0) {
			return true;
		}
		
		return $interval->m >= 6;
	}
974786
private function isExpired(RiakObject $object) : bool
    {
        $metadataMap = $object->getMetadataMap();

        return isset($metadataMap[self::EXPIRES_HEADER])
            && $metadataMap[self::EXPIRES_HEADER] < time();
    }
58784
protected function expired($lastUpdate, $now = null)
    {
        if ($now === null) {
            $now = time();
        }

        return ($now - ($lastUpdate + ($this->cacheTimeout * 3600)) > 0);
    }
271257
public function isExpired($time = null)
    {
        $time = ((null === $time) ? time() : $time);
        return (($this->_options['expire'] - $time) > 0);
    }
198962
public function getExpiredAfter()
    {
        if (!is_string($this->expiredAfterAttribute) || empty($this->expiredAfterAttribute)) {
            return false;
        }
        return (int)($this->{$this->expiredAfterAttribute});
    }
720248
public function init(Document $document)
	{
		$this->hashId = $this->getHashId($document, $this->serviceLocator);
		$this->title = $document->getTitle();
		$this->price = $this->getPrice($document);
		$this->priceFormatted = $this->getPriceFormatted($document);
		$this->meta = $this->getMeta($document);
		$this->date = $this->getDateFormatted($document);
		$this->image = $this->getImage($document, $this->serviceLocator); // rimuovere
		$this->images = $this->getImages($document, $this->serviceLocator); 
		$this->content = $document->getContent();
		$this->nl2brContent = nl2br($document->getContent());
		$this->dateInsert = $document->getDateInsert()->format('Y/m/d H:i:s');
		$this->visited = $document->getVisited();

		$this->state = $document->getState();
		$this->stateFormatted = $this->getStateFormatted($document);
		
		$state = $document->getState();
		$this->isActive = Document::DOCUMENT_STATE_ACTIVE == $state;
		$this->isDeactive = Document::DOCUMENT_STATE_DEACTIVE == $state;
		$this->isDeleted = Document::DOCUMENT_STATE_DELETED == $state;
		$this->isExpired = $this->getIsExpired($document);
		$this->cssClass = $this->isActive && !$this->isExpired ? '' : 'warning';
		$this->purpose = $this->getPurpose($document); 
		$this->mobile = $this->getMobile($document); 
		$this->hidemobile = $this->getHideMobile($document); 

		$this->location = $this->getLocation($document, $this->serviceLocator);
		$this->locationFormatted = $this->getLocationFormatted($document, $this->serviceLocator); 
		
		$this->categories = $this->getCategories($document); 
		$this->category = $this->getCategory($document); 
		$this->slug = $this->getSlug($document); 
		$this->address = $this->getAddress($document, $this->serviceLocator);
		$this->editaddress = $this->getEditAddress($document);
		$this->insert = $this->getInsertDate($document);
		
		// Some user data
		$user = $document->getUser();
		$this->userId = $this->getUserHashId($document, $this->serviceLocator);
		$this->fullname = $user->getName() . ' ' . $user->getSurname();
		
		// Some location data
		$geoname = $document->getGeoname();
		$this->longitude = null !== $geoname ? $geoname->getLongitude() : null;
		$this->latitude = null !== $geoname ? $geoname->getLatitude() : null;
		
		$this->breadcrumbs = $this->getBreadcrumbs($document);
		
		return $this;
	}
875819
public function isExpired()
    {
        if (is_object($this->ExpireAtDate)) {
            $this->ExpireAtDate = $this->ExpireAtDate->Value;
        }

        $expired = false;

        if (!empty($this->ExpireAtDate)) {
            if (SS_Datetime::now()->Value >= $this->ExpireAtDate) {
                $expired = true;
            }
        }

        return $expired;
    }
1274937
public function unlock($document)
    {
        $id = $this->uow->getDocumentIdentifier($document);
        $criteria = array('_id' => $this->class->getDatabaseIdentifierValue($id));
        $lockMapping = $this->class->fieldMappings[$this->class->lockField];
        $this->collection->update($criteria, array('$unset' => array($lockMapping['name'] => true)));
        $this->class->reflFields[$this->class->lockField]->setValue($document, null);
    }
136156
public function expired($limit = 10) 
    {
		$main = $this->getServiceLocator()->get('neobazaar.service.main');
		$em = $main->getEntityManager();
		$cache = $this->getServiceLocator()->get('ClassifiedCache');
		$documentRepository = $main->getDocumentEntityRepository();
		$documents = $documentRepository->getExpiredElegibleToMailSend($limit); 
        $url = $this->getServiceLocator()->get('ControllerPluginManager')->get('Url');

		$ids = array();
		foreach ($documents as $document) {
    	    $classifiedModel = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
    	    $classifiedModel->init($document, $this->getServiceLocator());
		    $event = new ClassifiedExpiredEvent(__FUNCTION__, null, array(
    		    'to' => $classifiedModel->email, 
    		    'siteurl' => $url->fromRoute('home', array(), array('force_canonical' => true)),
    		    'fullname' => $classifiedModel->fullname,
		        'title' => $classifiedModel->title, 
		        'hash' => $classifiedModel->hashId, 
		        'content' => $classifiedModel->content,
		        'hits' => $classifiedModel->visited
    		));
		    
		    $this->getEventManager()->trigger(ClassifiedExpiredEvent::EVENT_CLASSIFIED_EXPIRED_PRE, $this, $event);
			
			$document->setState(Document::DOCUMENT_STATE_DEACTIVE);
			$document->setVisited($document->getVisited() + 1); // this is a trick to make it not update edit date
			$em->persist($document);
			$em->flush();
			$ids[] = $document->getDocumentId();		
			$key = $documentRepository->getEncryptedId($document->getDocumentId());
			if ($cache->hasItem($key)) {
				$cache->removeItem($key);
			}
			
		    $this->getEventManager()->trigger(ClassifiedExpiredEvent::EVENT_CLASSIFIED_EXPIRED_POST, $this, $event);
		}
		
		return $ids;
    }
861073
public function unlock($document)
    {
        $qb          = $this->dm->createQueryBuilder($this->class->name);
        $identifier  = $this->uow->getDocumentIdentifier($document);
        $lockMapping = $this->class->lockMetadata;

        $qb->update();
        $qb->setIdentifier($identifier);
        $qb->attr($lockMapping->name)->remove();

        $qb->getQuery()->execute();

        $lockMapping->setValue($document, null);
    }
1187892
public function isPendingForPersist(Document $document)
    {
        return isset($this->persist[get_class($document)][spl_object_hash($document)]);
    }
709055
protected function getPurpose(Document $document) 
	{
		$value = '';
		foreach($document->getMetadata() as $meta) {
			if('finalita' == $meta->getKey()) {
				$value = $meta->getValue();
				break;
			}
		}
		
		return $value;
	}
1286618
private function isExpired($timestamp, $expiration)
    {
        $result = false;
        if ($expiration !== 0) {
            $timeDiff = time() - $timestamp;
            $result = ($timeDiff > $expiration) ? true : false;
        }

        return $result;
    }
566512
public function isExpired(DateTime $date = null)
    {
        // Here we'll determine if the account expires by checking is expiration date.
        if ($expirationDate = $this->expirationDate()) {
            $date = $date ?: new DateTime();

            return $expirationDate <= $date;
        }

        // The account has no expiry date.
        return false;
    }
127030
public function deleteDocument(Document $document)
    {
        $options = $document->getOptions(
            [
                'version',
                'version_type',
                'routing',
                'parent',
                'replication',
                'consistency',
                'refresh',
                'timeout',
            ]
        );

        return $this->deleteById($document->getId(), $options);
    }
568883
public function insert(&$document) {

        if (isset($document[0])) {

            $this->database->connection->beginTransaction();

            foreach ($document as &$doc) {

                if (!\is_array($doc)) continue;

                $res = $this->_insert($doc);

                if (!$res) {
                    $this->database->connection->rollBack();
                    return $res;
                }
            }
            $this->database->connection->commit();
            return \count($document);
        } else {
            return $this->_insert($document);
        }
    }
730410
protected function isReservedButExpired($query)
    {
        $expiration = Carbon::now()->subSeconds($this->expire)->getTimestamp();

        $query->orWhere(function ($query) use ($expiration) {
            $query->where('reserved_at', '<=', $expiration);
        });
    }