Get a connected API using the NEM node configured
at the current `poolIndex`

@param   boolean     $forceNew
@return  \NEM\API
500019
public function getEndpoint($forceNew = false)
    {
        $index = $forceNew === true ? ++$this->poolIndex : $this->poolIndex;
        if ($index == count($this->nodes)) {
            $index = 0;
        }

        if (!isset($this->endpoints[$this->network][$index])) {
            $api = new API([
                "use_ssl"  => false,
                "protocol" => "http",
                "host" => $this->nodes[$this->network][$index],
                "port" => 7890,
                "endpoint" => "/",
            ]);

            $this->endpoints[$this->network][$index] = $api;
        }

        $this->poolIndex = $index;
        return $this->endpoints[$this->network][$index];
    }
182502
public function listing($forceUpdate = false, array $params = [])
    {
        if (empty($this->users) || $forceUpdate) {
            $this->all($params);
        }
        $ret = [];
        if (is_array($this->users) && isset($this->users['users'])) {
            foreach ($this->users['users'] as $e) {
                $ret[$e['login']] = (int) $e['id'];
            }
        }

        return $ret;
    }
974863
public function get($container, $forceNew = false)
    {
        if ($this->shared) {
            if (empty($this->instances) || $forceNew) {
                $this->instances = call_user_func($this->callback, $container);
            }

            return $this->instances;
        }

        return call_user_func($this->callback, $container);
    }
1206567
public function getNextFeed()
    {
        $nextLink = $this->getNextLink();
        if (!$nextLink) {
            require_once 'Zend/Gdata/App/HttpException.php';
            throw new Zend_Gdata_App_Exception('No link to next set ' .
            'of results found.');
        }
        $nextLinkHref = $nextLink->getHref();
        $service = new Zend_Gdata_App($this->getHttpClient());

        return $service->getFeed($nextLinkHref, get_class($this));
    }
329321
public function getData ($forceRefresh = false) {
        if ($forceRefresh || $this->_data === null) {
            $this->_data = $this->getConnection ()->getSlave ()->zrange ($this->name , 0 , -1 , true);
        }
        return $this->_data;
    }
689553
public function getActiveServices(bool $force = false) : CNabuMessagingServiceList
    {
        if ($this->nb_messaging_service_list->isEmpty() || $force) {
            $this->nb_messaging_service_list->clear();
            if (($nb_messaging = $this->getMessaging()) instanceof CNabuMessaging &&
                !($nb_services_list = $nb_messaging->getActiveServices())->isEmpty()
            ) {
                $nb_services_list->iterate(function($key, CNabuMessagingService $nb_service) {
                    if ($nb_service->isTemplateConnected($this->getId())) {
                        $this->nb_messaging_service_list->addItem($nb_service);
                    }
                    return true;
                });
            }
        }

        return $this->nb_messaging_service_list;
    }
348058
public function getToken($forceNew = false)
    {
        /** @var Session $session */
        $session = $this->session;

        $token = $session->get(static::TOKEN_KEY);

        // Create a token
        if ($token === null || $forceNew) {
            $token = $this->createToken(12);

            $session->set(static::TOKEN_KEY, $token);
        }

        return $token;
    }
1294819
public function download(array $elements, $forceArchive = false)
    {
        $data = [];

        if (0 === count($elements)) {
            throw new ExportResourceException('No resources were selected.');
        }

        $pathArch = $this->container->get('claroline.manager.temp_file')->generate();

        $archive = new \ZipArchive();
        $archive->open($pathArch, \ZipArchive::CREATE);

        $nodes = $this->expandResources($elements);
        if (!$forceArchive && 1 === count($nodes)) {
            $event = $this->dispatcher->dispatch(
                "download_{$nodes[0]->getResourceType()->getName()}",
                'Resource\DownloadResource',
                [$this->getResourceFromNode($this->getRealTarget($nodes[0]))]
            );
            $extension = $event->getExtension();
            $hasExtension = '' !== pathinfo($nodes[0]->getName(), PATHINFO_EXTENSION);

            $extGuesser = ExtensionGuesser::getInstance();
            $mimeGuesser = MimeTypeGuesser::getInstance();

            if (!$hasExtension) {
                $extension = $extGuesser->guess($nodes[0]->getMimeType());
            }

            $data['name'] = $hasExtension ?
                $nodes[0]->getName() :
                $nodes[0]->getName().'.'.$extension;
            $data['file'] = $event->getItem();
            $data['mimeType'] = $nodes[0]->getMimeType() ? $nodes[0]->getMimeType() : $mimeGuesser->guess($extension);

            return $data;
        }

        if (isset($elements[0])) {
            $currentDir = $elements[0];
        } else {
            $archive->addEmptyDir($elements[0]->getName());
        }

        foreach ($nodes as $node) {
            //we only download is we can...
            if ($this->container->get('security.authorization_checker')->isGranted('EXPORT', $node)) {
                $resource = $this->getResourceFromNode($node);

                if ($resource) {
                    $filename = $this->getRelativePath($currentDir, $node).$node->getName();
                    $resource = $this->getResourceFromNode($node);

                    //if it's a file, we may have to add the extension back in case someone removed it from the name
                    if ('file' === $node->getResourceType()->getName()) {
                        $extension = '.'.pathinfo($resource->getHashName(), PATHINFO_EXTENSION);
                        if (!preg_match("#$extension#", $filename)) {
                            $filename .= $extension;
                        }
                    }

                    if ('directory' !== $node->getResourceType()->getName()) {
                        $event = $this->dispatcher->dispatch(
                            "download_{$node->getResourceType()->getName()}",
                            'Resource\DownloadResource',
                            [$resource]
                        );

                        $obj = $event->getItem();

                        if (null !== $obj) {
                            $archive->addFile($obj, iconv($this->ut->detectEncoding($filename), $this->getEncoding(), $filename));
                        } else {
                            $archive->addFromString(iconv($this->ut->detectEncoding($filename), $this->getEncoding(), $filename), '');
                        }
                    } else {
                        $archive->addEmptyDir(iconv($this->ut->detectEncoding($filename), $this->getEncoding(), $filename));
                    }

                    $this->dispatcher->dispatch('log', 'Log\LogResourceExport', [$node]);
                }
            }
        }

        $archive->close();

        $data['name'] = 'archive.zip';
        $data['file'] = $pathArch;
        $data['mimeType'] = 'application/zip';

        return $data;
    }
786491
public function replace($oldItem, $newItem, $forceAdd = true)
    {
        $this->emitOnChange(__METHOD__);
        $keys = array_keys($this->items(), $oldItem, true);
        if (count($keys) === 0) {
            if ($forceAdd) {
                $this->add($newItem);
            }
        } else {
            $this->remove($oldItem);
            foreach ($keys as $key) {
                $this->add($newItem);
                // move to old item position
                $newKeys = array_keys($this->items(), $newItem, true);
                $lastAddedKey = array_pop($newKeys);
                $this->items()[$key] = $this->items()[$lastAddedKey];
                unset($this->items()[$lastAddedKey]);
            }
        }
        $this->endEmitOnChange(__METHOD__);
        return $this;
    }
952165
public function getModel($name = null, $source = null, $forceNew = false)
    {
        return $this->getRepository($name, $source, $forceNew);
    }
647156
public function getToken($forceRefresh = false)
    {
        $cacheKey = $this->cacheKey;

        $cached = $this->cache->get($cacheKey);

        if ($forceRefresh || !$cached) {
            $token = $this->getTokenFromServer();

            $this->cache->set($cacheKey, $token['access_token'], $token['expires_in'] - 800);

            return $token['access_token'];
        }

        return $cached;
    }
1197832
static function getInstance($databaseNameOrResource = '*LOCAL', $userOrI5NamingFlag = '', $password = '', $extensionPrefix = '', $isPersistent = false, $forceNew = false)
    {
        // if we're forcing a new instance, close db conn first if exists.
        if ($forceNew && self::hasInstance() && isset(self::$instance->conn))
        {
            self::$instance->disconnect();
        }

        // if we're forcing a new instance, or an instance hasn't been created yet, create one
        if ($forceNew || self::$instance == NULL) {
            $toolkitService = __CLASS__;
            self::$instance = new $toolkitService($databaseNameOrResource, $userOrI5NamingFlag, $password, $extensionPrefix, $isPersistent);
        }

        if (self::$instance) {
            // instance exists
            return self::$instance;
        } else {
            // some problem
            return false;
        }
    }
1174705
public function getTemplates($force = false)
    {
        if ($this->nb_messaging_template_list === null) {
            $this->nb_messaging_template_list = new CNabuMessagingTemplateList();
        }

        if ($this->nb_messaging_template_list->isEmpty() || $force) {
            $this->nb_messaging_template_list->clear();
            $this->nb_messaging_template_list->merge(CNabuMessagingTemplate::getAllMessagingTemplates($this));
            $this->nb_messaging_template_list->iterate(function($key, CNabuMessagingTemplate $nb_template) {
                $nb_template->setMessaging($this);
                return true;
            });
        }

        return $this->nb_messaging_template_list;
    }
767051
protected function getObjectOr404($createOnNoId = false)
    {
        /** @var integer|null $objectId */
        $objectId = static::getObjectId();

        /** @var ObjectWrapperInterface $object */
        $object = null;

        if ($objectId !== null) {
            $object = $this->getQuery()->findOneByPrimaryKey($objectId);
        } elseif ($createOnNoId === true) {
            $object = $this->getQuery()->createObject();
        }

        if ($object === null) {
            http_response_code(404);
            throw new \Exception('Object not found.');
        }

        return $object;
    }
1012854
public function getNode(NodeRef $nodeRef): Node
    {
        if (!$this->hasNode($nodeRef)) {
            if ($this->lazyLoader->hasNodeRef($nodeRef)) {
                $this->lazyLoader->flush();
                if (!$this->hasNode($nodeRef)) {
                    throw NodeNotFound::forNodeRef($nodeRef);
                }
            } else {
                throw NodeNotFound::forNodeRef($nodeRef);
            }
        }

        $node = $this->nodes[$nodeRef->toString()];
        if ($node->isFrozen()) {
            $node = $this->nodes[$nodeRef->toString()] = clone $node;
        }

        return $node;
    }
1356387
public function getRow($index,$force=true){
		if($index<sizeof($this->rows)){
			$result=$this->rows[$index-1];
		}else if ($force){
			$this->setNumRows($index);
			$result=$this->rows[$index-1];
		}
		return $result;
	}
1125355
public function getNextNavItemOf(NavItem $current)
    {
        $siblings = $current->parent ? $current->parent->children : $this->navItems;
        $found    = false;

        foreach ($siblings as $sibling) {
            if ($found) {
                return $sibling;
            }

            if ($sibling->id === $current->id) {
                $found = true;
            }
        }

        return null;
    }