Returns the a valid instance from Ioc.

@throws NoCollectionNameException throws exception when has no collection filled

@return mixed
331979
private static function getDataMapperInstance()
    {
        $instance = Ioc::make(get_called_class());

        if (!$instance->getCollectionName()) {
            throw new NoCollectionNameException();
        }

        return $instance->getDataMapper();
    }
3050
private function newViewHelperCollectionInstance()
    {
        $viewHelperCollection = $this->getPrototype(
                $this->viewHelperCollectionClass,
                ['umi\templating\extension\helper\collection\IHelperCollection']
            )
            ->createInstance();

        if ($viewHelperCollection instanceof IHelperFactoryAware) {
            $viewHelperCollection->setTemplatingHelperFactory($this->getViewHelperFactory());
        }

        return $viewHelperCollection;
    }
373848
public function instance()
    {
        $settings = $this->getValidatedSettings();

        $objectManager = $this->createObjectManager($settings);
        $logger = isset($settings['logger']) ? isset($settings['logger']) : null;

        $this->initializeRegistry($objectManager, $logger);

        return new DataMapper($objectManager);
    }
1326963
public static function instance(): self
    {
        if (!self::$instance) {
            self::$instance = new self(
                MatcherFactory::instance(),
                MatcherVerifier::instance(),
                GeneratorVerifierFactory::instance(),
                IterableVerifierFactory::instance(),
                ExceptionAssertionRecorder::instance(),
                AssertionRenderer::instance()
            );
        }

        return self::$instance;
    }
410339
protected function getCollection()
    {
        $collection = [];

        $class = $this->getCollectionClassName();
        if ($class) {
            /** @var Collection $collection */
            $collection = new $class();
            $collection->setModel($this->class);
            $collection->setFormatter($this);
        }

        return $collection;
    }
816662
public function getJSONObject()
    {
        $r = new \stdClass();
        $r->name = $this->getCollectionName();
        $r->cID = $this->getCollectionID();

        return $r;
    }
457453
public static function instance($name = 'default')
	{
		if (\array_key_exists($name, static::$instances))
		{
			return static::$instances[$name];
		}

		if (empty(static::$instances))
		{
			\Config::load('db', true);
		}

		if ( ! ($config = \Config::get('db.mongo.'.$name)))
		{
			throw new \Mongo_DbException('Invalid instance name given.');
		}

		static::$instances[$name] = new static($config);

		return static::$instances[$name];
	}
1338694
public function getObjectInstanceById(ICollection $collection, $objectId)
    {
        $collectionName = $collection->getName();
        if (isset($this->objectsById[$collectionName][$objectId])) {
            return $this->objectsById[$collectionName][$objectId];
        } else {
            return null;
        }
    }
955890
public function getByName($name, $throwException = true)
    {
        foreach ($this as $element) {

            if (!$element instanceof Element\NamedElement) {
                throw new Exception\CollectionException();
            }

            if ($element->getName() === $name) {
                return $element;
            }
        }

        if ($throwException) {
            throw new Exception\NotFoundException();
        }

        return null;
    }
203787
protected function get_collection_from() {
        if ($this->collectionfrom === null) {
            $this->collectionfrom = api::search_competencies('', $this->from);
        }
        return $this->collectionfrom;
    }
393562
public function collection()
    {
        if ($this->collection) {
            return $this->collection;
        }

        if (!$this->collectionConfig()) {
            throw new Exception(sprintf(
                'Collection Config required for "%s"',
                get_class($this)
            ));
        }

        $collection = new CollectionLoader([
            'logger'  => $this->logger,
            'factory' => $this->modelFactory()
        ]);

        $collection->setModel($this->proto());
        $collection->setData($this->collectionConfig());

        $this->collection = $collection->load();

        return $this->collection;
    }
138249
public static function getInstance()
    {
        if (self::$instance == null)
        {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
    }
487621
public function get()
    {
        return $this->isCollection($this->data)
            ? new Collection($this->data)
            : $this->data;
    }
1070956
public static function getInstance()
    {
        $configuration = Configuration::getConfig(self::CONFIG_FILE_NAME);
        $idpListServiceType = $configuration->getString(self::PROPNAME_IDP_LIST_SERVICE_TYPE, self::CSV);
        if ($idpListServiceType === self::CSV) {
            return new IdpListsServiceCsv();
        } elseif ($idpListServiceType === self::DB) {
            return new IdpListsServiceDB();
        } else {
            throw new Exception(
                'Unknown idpListService type. Hint: try ' . self::CSV . ' or ' . self::DB
            );
        }
    }
1230330
public function create()
    {
        $instance = self::createCollection($this);
        $this->setId($instance->getId());
        return $instance;
    }
7359
protected function collectionLoader()
    {
        if ($this->collectionLoader === null) {
            throw new RuntimeException(sprintf(
                'Collection Loader is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->collectionLoader;
    }
38503
private function getCollection() {
        if ($this->collection === null) {
            try {
                $this->collection = $this->getMongoClient()->selectCollection(
                    $this->params['databaseName'],
                    'imagevariation'
                );
            } catch (MongoException $e) {
                throw new DatabaseException('Could not select collection', 500, $e);
            }
        }

        return $this->collection;
    }