Check if entity needs warming up.

@param \Drupal\groupex_form_cache\GroupexFormCacheInterface $entity
Entity.

@return bool
TRUE if needs warming up.
434312
private function needsWarmUp(GroupexFormCacheInterface $entity) {
    if (!$created = $entity->field_gfc_created->value) {
      return TRUE;
    }

    $config = $this->configFactory->get('groupex_form_cache.settings');
    if ((REQUEST_TIME - $created) > $config->get('cache_warmup_interval')) {
      return TRUE;
    }

    return FALSE;
  }
641229
public function isRegistered( $entity )
    {
        if( is_object($entity) ) {
            return isset( $this->registrations[get_class($entity)]);
        }

        return isset( $this->registrations[$entity] ) || isset( $this->names[\Bond\get_unqualified_class($entity)] );
    }
1086320
protected function checkIsCorrectEntityType(EntityInterface $entity): void
    {
        $entityFqn = $this->getEntityFqn();

        if (!$entity instanceof $entityFqn) {
            $class = \get_class($entity);
            $msg   = "[ $class ] is not an instance of [ $entityFqn ]";
            throw new DoctrineStaticMetaException($msg);
        }
    }
40808
public static boolean isFetched(final Object entity) {
        return entity == null || !isProxy(entity) || asProxy(entity).__isFetched();
    }
1191686
protected function hasChangedUsingComparisonFunction($entity)
    {
        $hashId       = $this->getHashId($entity);
        $originalData = $this->originalData[$hashId];

        return !$this->comparators[get_class($entity)]($originalData, $entity);
    }
390516
public function isOrm($entity)
    {
        $annotation = $this->getClassAnnotation($entity, 'Doctrine\ORM\Mapping\Entity');

        if ($annotation === null) {
            return false;
        }

        return true;
    }
972401
public function contains($entity)
    {
        return $this->unitOfWork->isScheduledForInsert($entity)
            || ($this->unitOfWork->isInIdentityMap($entity) && ! $this->unitOfWork->isScheduledForDelete($entity));
    }
997337
public function isNested($entity)
    {
        if ($nestedDocument = $this->getClassAnnotation($entity, self::DOCUMENT_NESTED_CLASS)) {
            return true;
        }

        return false;
    }
891851
public function refresh ($entity)
    {
        // Return if not saved and not in database.
        if (! $entity->_saved) return false;
        $structure = $this->getEntityStructure($entity);

        // ID Data.
        $idColumn = $structure->primaryColumn->name;
        $idValue = $entity->_id;

        if ($structure->primaryColumn->type === 'integer')
            $idValue = intval($idValue);

        // Clear Relationship Cache.
        $entity::clearCache();

        // Query for refreshing.
        $query = new Query($entity);
        $newEntity = $query->select()
            ->where($idColumn, $idValue)
            ->one();

        // If no entity is found (when refreshing).
        if (! $newEntity) return false;

        // Map to the old instance
        foreach ($structure->columns as $column) {
            $entity->{$column->propertyName} = $newEntity->{$column->propertyName};
        }

        return true;
    }
1101753
public function commit($entity = null)
    {
        if ($this->evm->hasListeners(Events::preFlush)) {
            $this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->sm));
        }

        //TODO: single/array entity commit handling
        $this->commitRemoved();
        $this->commitPersisted();

        //Force refresh of updated indexes
        if ($entity === true) {
            $client = $this->sm->getClient();
            foreach (array_unique($this->updatedIndexes) as $index) {
                $client->refreshIndex($index);
            }
        }

        $this->clear();

        if ($this->evm->hasListeners(Events::postFlush)) {
            $this->evm->dispatchEvent(Events::postFlush, new Event\PostFlushEventArgs($this->sm));
        }
    }
270598
public function equals(Entity $entity = null)
	{
		if ($entity === null) {
			return false;
		}

		// Equals if matches
		if ($entity === $this) {
			return true;
		}

		$id = $this->getId();

		if ( ! empty($id) && $entity->getId() === $id) {
			return true;
		}

		return false;
	}
1349436
public function saveEntity($entity)
    {
        if (!$this->entityManager->contains($entity)) {
            $this->entityManager->persist($entity);
        }

        $this->entityManager->flush();
        return true;
    }
446351
public function isEncryptable(EntityInterface $entity): bool
    {
        $enabled = $this->getConfig('enabled');
        if (is_callable($enabled)) {
            $enabled = $enabled($entity);
            if (!is_bool($enabled)) {
                throw new RuntimeException('Condition callable must return a boolean.');
            }
        }

        return $enabled;
    }
844802
public function isCached(CacheItemInterface $item = null)
    {
        if (!$item) {
            $key = $this->getCurrentKey();
            $item = $this->getItemStorage()->get($key);
        }

        return $item ? true : false;
    }
854538
public function isAttached( Base $entity )
    {
        return false !== array_search( $entity, $this->instancesPersisted, true ) ||
               false !== array_search( $entity, $this->instancesUnpersisted, true );
    }
972118
public function isValidEntity($entity) {
    if ($entity->getEntityTypeId() === 'mentions') {
      return TRUE;
    }

    // Special cases for comments and posts.
    $allowed_content_types = [
      'comment',
    ];
    if (in_array($entity->getEntityTypeId(), $allowed_content_types)) {
      $mentions = $this->getMentionsFromRelatedEntity($entity);
      if (!empty($mentions)) {
        return TRUE;
      }
    }
    return FALSE;
  }
450022
private function traverse() {
    if (!$result = $this->queryFactory->get(GroupexFormCacheManager::ENTITY_TYPE)->execute()) {
      return;
    }

    // Loop over each cache entity.
    $this->logger->info('Starting warming up %count cache entities.', ['%count' => count($result)]);
    krsort($result);
    foreach ($result as $item) {
      // Let's protect GroupEx servers.
      sleep(1);

      if (!$entity = GroupexFormCache::load($item)) {
        continue;
      }

      if (!$this->needsWarmUp($entity)) {
        continue;
      }

      $this->warmUp($entity);
    }
  }