Returns true if a collection is available given a configuration.

@param \collection $collection

@return bool
962507
public function isCollectionAvailable(\collection $collection)
    {
        if (!$this->isRestricted()) {
            return true;
        }

        $availableCollections = isset($this->availableCollections[$collection->get_sbas_id()])
            ? $this->availableCollections[$collection->get_sbas_id()] : [];

        return in_array($collection->get_base_id(), $availableCollections, true);
    }
751375
private function isCollectionDynamic(Collection $collection): bool
    {
        try {
            $this->loadCollectionQuery($collection);
        } catch (NotFoundException $e) {
            return false;
        }

        return true;
    }
1227304
public static function dropCollection($collection)
  {
    static::checkConnexion();
    $collection = self::$db->$collection;
    $r = $collection->drop();
    if ($r['ok']) {
      return true;
    }
    return false;
  }
502419
public function count($collection)
    {
        $collection = $this->makeCollection($collection);
        $url        = UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collection, self::OPTION_COUNT]);
        $response   = $this->getConnection()->get($url);

        $data  = $response->getJson();
        $count = $data[self::OPTION_COUNT];

        return (int) $count;
    }
665069
protected function doCanFilterWithRepository(
        Collection $collection,
        Repository $repository
    ){
        /**
         * @var Filter[] $filters
         */
        $filters = $this->getFilters();

        foreach ($filters as $filter) {
            if (!$filter->canFilterWithRepository($collection, $repository)){
                return false;
            }
        }

        return true;
    }
561338
public function filterModelCollectionAsContainer(Collection $collection)
    {
        parent::filterModelCollectionAsContainer($collection);

        $collection->filter(new Equals("Accepted", false));
    }
10288
public function configSet($collection, $key, $value) {
    $value = base64_encode(Yaml::dump($value));

    if ($index = array_search('--format=json', $this->options)) {
      unset($this->options[$index]);
    }
    $this->options[] = '--format=yaml';
    $this->options[] = '-y';

    $pipe = "echo '$value' | base64 --decode |";

    $this->runCommand('config-set', [
      $collection, $key, '-'
    ], $pipe);

    return TRUE;
  }
681756
public static boolean contains(Collection<?> collection, Object value) {
		return isNotEmpty(collection) && collection.contains(value);
	}
81435
public static function isCollectionType(string $type): bool
    {
        if (in_array($type, self::$collectionTypes, true)) {
            return true;
        }

        if (class_exists($type) === true || interface_exists($type) === true) {
            foreach (self::$collectionTypes as $collectionType) {
                if (is_subclass_of($type, $collectionType) === true) {
                    return true;
                }
            }
        }

        return false;
    }
522466
public function isSubsetOf($collection)
    {
        /** @var ModelInterface $localModel */
        foreach ($this as $localModel) {
            /** @var ModelInterface $otherModel */
            foreach ($collection as $otherModel) {
                if (($localModel->getProviderName() === $otherModel->getProviderName())
                    && ($localModel->getId() === $otherModel->getId())
                ) {
                    continue;
                }
                return false;
            }
        }
        return true;
    }
859883
public static boolean hasUniqueObject(Collection<?> collection) {
        if (isEmpty(collection)) {
            return false;
        }
        boolean hasCandidate = false;
        Object candidate = null;
        for (Object elem : collection) {
            if (!hasCandidate) {
                hasCandidate = true;
                candidate = elem;
            } else if (candidate != elem) {
                return false;
            }
        }
        return true;
    }
457854
protected function verifyContainsEntitiesOnly(Collection $collection) {
			$check = $collection->forAll(function($key, $element) {
				return $element instanceof EntityInterface;
			});

			if (!$check)
				throw new \InvalidArgumentException('Items in the collection must all implement ' .
					EntityInterface::class);
		}
1135369
public function collection(Collection $collection)
    {
        $entries = new Entries();

        foreach ($collection as $group) {
            $entry = new Entry($group);

            $entry
                ->conditionalField('id', function () {
                    return Subbly::api('subbly.user')->hasAccess('subbly.backend.auth');
                })

                ->field('name')
                ->field('permissions')

                ->dateField('created_at')
                ->dateField('updated_at')
            ;

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
778073
public function any(array $collection, Closure $iterator)
    {
        foreach ($collection as $node)
        {
            if ($iterator($node))
            {
                return true;
            }
        }

        return false;
    }
153237
public function getCollectionName($collection)
    {
        if ($collection instanceof Collection) {
            $collectionId = $collection->getName();

            return $collectionId;
        }

        $collectionId = $collection;

        return $collectionId;
    }
355947
public function factory($collection)
    {
        if ($collection instanceof Collection) {
            $collectionName = $collection->getName();
        } else {
            $collectionName = $collection;
        }

        if (!isset($this->collections[$collectionName])) {
            if (!($collection instanceof Collection)) {
                $collection = Norm::createCollection(array(
                    'name' => $collection,
                    'connection' => $this,
                ));

                $this->applyHook('norm.after.factory', $collection);
            }

            $this->collections[$collectionName] = $collection;
        }

        return $this->collections[$collectionName];
    }
438916
public function updateCollection(Collection $collection): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_collection')
            ->set('start', ':start')
            ->set('length', ':length')
            ->set('translatable', ':translatable')
            ->set('main_locale', ':main_locale')
            ->set('always_available', ':always_available')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $collection->id, Type::INTEGER)
            ->setParameter('start', $collection->offset, Type::INTEGER)
            ->setParameter('length', $collection->limit, Type::INTEGER)
            ->setParameter('translatable', $collection->isTranslatable, Type::BOOLEAN)
            ->setParameter('main_locale', $collection->mainLocale, Type::STRING)
            ->setParameter('always_available', $collection->alwaysAvailable, Type::BOOLEAN);

        $this->applyStatusCondition($query, $collection->status);

        $query->execute();
    }