Retrieve a fresh instance of service

@param string $nameOrAlias Service name
@param mixed  $invOpt      Invoke Options

@throws \Exception
@return mixed
324386
function fresh($nameOrAlias, $invOpt = array())
    {
        $orgName = $nameOrAlias;

        if (!(strpos($nameOrAlias, self::SEPARATOR) !== false))
            $nameOrAlias = $this->getExtended($nameOrAlias);

        # check if we have alias to nested service:
        if (strpos($nameOrAlias, self::SEPARATOR) !== false) {
            // shared alias for nested container
            /* @see Container::extend */

            $xService    = explode(self::SEPARATOR, $nameOrAlias);
            $nameOrAlias = array_pop($xService);

            $x = implode(self::SEPARATOR, $xService);
            if ($x === '') $x = self::SEPARATOR;

            if ( false === $nestContainer = $this->from($x) )
                throw new \Exception(sprintf('Nested Container (%s) not found.', $x));

            return $nestContainer->fresh($nameOrAlias, $invOpt);
        }


        // ..

        if (!$this->has($nameOrAlias))
            throw new exContainerNoService(sprintf(
                '%s (%s) was requested in Container@%s but no service could be found.'
                , ($nameOrAlias !== $orgName)
                ? "Service ($nameOrAlias) with alias"
                : 'Service'
                , $orgName
                , $this->getPath().'#'.get_class($this)
            ));

        # Attain Service Instance:
        $inService = $this->_attainCService($nameOrAlias);

        # Refresh Service:
        try
        {
            ## invokeOptions used to build service
            $inService = clone $inService;
            if ($invOpt) $inService->with( $inService::parseWith($invOpt) );

            $instance = $this->_createFromService($inService);
            if ($instance === null)
                throw new \Exception(sprintf(
                    'service (%s) meanwhile found but create nothing(null).'
                    , $nameOrAlias
                ));
        }
        catch(\Exception $e) {
            throw new exContainerCreateService(sprintf(
                'An exception was raised while creating (%s); no instance returned.'
                , $orgName
            ), $e->getCode(), $e);
        }

        // TODO it could be added as an initializer
        # initialize retrieved service to match with defined implementation interface
        $this->_validateImplementation($orgName, $instance);
        return $instance;
    }
197241
private function invokeFunction($function, $namedParams, $classParams)
    {
        $reflection = new \ReflectionFunction($function);
        $params = $reflection->getParameters();

        $invokeParams = $this->mapParameters($params, $namedParams, $classParams);

        return call_user_func_array($function, $invokeParams);
    }
841536
protected static function & _namespaceGet($namespace, $name = null)
    {
        if (self::$_readable === false) {
            /**
             * @see Zend_Session_Exception
             */
            require_once 'Zend/Session/Exception.php';
            throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG);
        }

        if ($name === null) {
            if (isset($_SESSION[$namespace])) { // check session first for data requested
                return $_SESSION[$namespace];
            } elseif (isset(self::$_expiringData[$namespace])) { // check expiring data for data reqeusted
                return self::$_expiringData[$namespace];
            } else {
                return $_SESSION[$namespace]; // satisfy return by reference
            }
        } else {
            if (isset($_SESSION[$namespace][$name])) { // check session first
                return $_SESSION[$namespace][$name];
            } elseif (isset(self::$_expiringData[$namespace][$name])) { // check expiring data
                return self::$_expiringData[$namespace][$name];
            } else {
                return $_SESSION[$namespace][$name]; // satisfy return by reference
            }
        }
    }
563842
public static function getInstance($name, $args = [], $forceNew = false)
    {
        $key = strtolower($name);

        $called = get_called_class();

        if (empty(static::$instances[$called][$key]) || $forceNew) {
            static::$instances[$called][$key] = static::create($name, ...$args);
        }

        return static::$instances[$called][$key];
    }
838170
public function initInvokableServices()
    {
        $config = $this->getConfig();
        if (!isset($config['service_manager'])) {
            return $this;
        }
        
        $smConfig = $config['service_manager'];
        if (!isset($smConfig['invokables'])) {
            return $this;
        }
        $invokables = $smConfig['invokables']->toArray();
        $shared     = isset($smConfig['shared']) ? $smConfig['shared']->toArray() : [];
        foreach ($invokables as $serviceName => $serviceClassName) {
            if (!is_string($serviceClassName)) {
                $msg = sprintf('Config for invokable service "%s" must be string data type', $serviceName);
                throw new Exception\UnexpectedValueException($msg);
            }
            $isShare = isset($shared[$serviceName]) ? (bool) $shared[$serviceName] : true;
            $this->diFactory->set($serviceName, $serviceClassName, $isShare);
        }
        return $this;
    }
1083547
public function getService($service, $async = true)
    {
        if ($async) {
            $group = 'async';
        } else {
            $group = 'sync';
        }

        if (!isset($this->_service[$service][$group])) {
            $obj = new Client($this->getServiceUrls($service), $async);
            $this->trigger(static::EVENT_AFTER_INIT_CLIENT, new Event([
                'sender' => &$obj
            ]));
            $this->_service[$service][$group] = $obj;
        }

        return $this->_service[$service][$group];
    }
909897
public function getDocumentService()
    {
        if (null === $this->documentService) {
            $documentServiceClass = $this->getDocumentServiceClass();
            if (!class_exists($documentServiceClass)) {
                throw new \RuntimeException("Classe $documentServiceClass inexistente!");
            }
            $this->documentService = new $documentServiceClass();
            $this->documentService->setServiceLocator($this->getServiceLocator());
        }

        return $this->documentService;
    }
1353959
function setServerName($name, $multicall = false)
    {
        if (!is_string($name)) {
            throw new InvalidArgumentException('name = ' . print_r($name, true));
        }

        return $this->execute(ucfirst(__FUNCTION__), array($name), $multicall);
    }
98449
protected function getInputFilterByName(ServiceLocatorInterface $serviceLocator, $name)
    {
        if ($serviceLocator->has('InputFilterManager')) {
            $serviceLocator = $serviceLocator->get('InputFilterManager');
        }

        $obj = $serviceLocator->get($name);
        if (!$obj instanceof InputFilterInterface) {
            throw new Exception\RuntimeException(sprintf(
                'Instance of type %s is invalid; must implement %s',
                (is_object($obj) ? get_class($obj) : gettype($obj)),
                InputFilterInterface::class
            ));
        }
        return $obj;
    }
156986
public function resolve(string $name, ?array $parameters = null)
    {
        if (isset($this->service[$name])) {
            return $this->service[$name];
        }

        if ($this->config->has($name)) {
            return $this->wrapService($name, $parameters);
        }

        if (null !== $this->parent_service) {
            $parents = array_merge([$name], class_implements($this->parent_service), class_parents($this->parent_service));

            if (in_array($name, $parents, true) && $this->parent_service instanceof $name) {
                return $this->parent_service;
            }
        }

        if (null !== $this->parent) {
            return $this->parent->resolve($name, $parameters);
        }

        throw new Exception\ServiceNotFound("service $name was not found in service tree");
    }
1164384
private function createServiceFromLazyServiceDelegator(string $name, array $options = null)
    {

        $creationCallback = $this->delegatorCallbackCache[$name] ?? null;
        if ($creationCallback) {
            $object = $creationCallback($this->creationContext, $name, $creationCallback, $options);
            return $object;
        }
        $creationCallback = function () use ($name, $options) {
            return $this->createServiceFromFactory($name, $options);
        };

        $delegatorFactory = $this->delegators[$name][0];
        if (is_string($delegatorFactory)) {
            $delegatorFactory = $this->createLazyServiceDelegatorFactory();
            $this->delegators[$name][0] = $delegatorFactory;
        }

        $creationCallback = function () use ($delegatorFactory, $name, $creationCallback, $options) {
            return $delegatorFactory($this->creationContext, $name, $creationCallback, $options);
        };

        //cache the callback for later requests
        $this->delegatorCallbackCache[$name] = $creationCallback;
        return $creationCallback($this->creationContext, $name, $creationCallback, $options);
    }
1070121
public function GetServiceTA($service, $continue = TRUE)
	{
		if (file_exists($this->TA_FOLDER.'TA-'.$this->options['CUIT'].'-'.$service.'.xml')) {
			$TA = new SimpleXMLElement(file_get_contents($this->TA_FOLDER.'TA-'.$this->options['CUIT'].'-'.$service.'.xml'));

			$actual_time 		= new DateTime(date('c',date('U')+600));
			$expiration_time 	= new DateTime($TA->header->expirationTime);

			if ($actual_time < $expiration_time) 
				return new TokenAutorization($TA->credentials->token, $TA->credentials->sign);
			else if ($continue === FALSE)
				throw new Exception("Error Getting TA", 5);
		}

		if ($this->CreateServiceTA($service)) 
			return $this->GetServiceTA($service, FALSE);
	}
254918
public static function getByName($belongsTo, $name, $defaultURL = '')
    {
        $singlePermalink = Permalink::where('belongsTo', $belongsTo)->where("name", $name)->first();
        if ($singlePermalink && $singlePermalink->custom_url) {
            return $singlePermalink->custom_url;
        }

        if(!$singlePermalink) {
            if(!$defaultURL) {
                throw new \Exception("Permalink or default url not found in '$belongsTo' '$name' ");
            }
            return $defaultURL;
        }

        return $singlePermalink->default_url;
    }
748164
protected function triggerInvoiceCreated(array &$invoice, Source $invoiceSource, Result $localResult)
    {
        JPluginHelper::importPlugin('acumulus');
        $results = JEventDispatcher::getInstance()->trigger('onAcumulusInvoiceCreated', array(&$invoice, $invoiceSource, $localResult));
        if (count(array_filter($results, function ($value) {
                return $value === false;
            })) >= 1
        ) {
            $invoice = null;
        }
    }
645139
public function getMethod($nameOrMethod): PhpMethod {
		if ($nameOrMethod instanceof PhpMethod) {
			$nameOrMethod = $nameOrMethod->getName();
		}

		if (!$this->methods->has($nameOrMethod)) {
			throw new \InvalidArgumentException(sprintf('The method "%s" does not exist.', $nameOrMethod));
		}

		return $this->methods->get($nameOrMethod);
	}
1168695
function _initializeServiceOrInstance($inService)
    {
        # Invoke Service Features:
        if ($inService instanceof iServiceFeatureDelegate)
            $inService->delegate($this);


        # initialize with all parent namespaces, from root parent to current last
        $container    = $this;
        $initializers = array();
        while($container->__nestLeft) {
            $container = $container->__nestLeft;
            array_push($initializers, $container->initializer());
        }

        array_push($initializers, $this->initializer());
        foreach($initializers as $initializer)
            $initializer->initialize($inService);

        return $inService;
    }
601318
static function get($namespace, $name = null, $isall = false)
    {
        $cacheName = 'config:'.$namespace;
        if (!Cache::has($cacheName)) {
            $data = self::setCache($namespace);
        } else {
            $data = Cache::get($cacheName, []);
            if($name) {
                if(!$isall) return isset($data[$name]['value']) ? $data[$name]['value'] : null;
                return isset($data[$name]) ? $data[$name] : [];
            }
        }
        if(!$isall) {
            $rdata = array();
            foreach ($data as $key => $value) {
                $rdata[$key] = $value['value'];
            }
            return $rdata;
        }
        return $data;
    }