Adds a source with an associated name.

@param string                               $sourceName The unique source name
@param \Niirrty\Translation\Sources\ISource $source
@return \Niirrty\Translation\Translator
172464
public function addSource( string $sourceName, ISource $source ) : Translator
   {

      $source->setLocale( $this->_locale );

      $this->_sources[ $sourceName ] = $source;

      return $this;

   }
1025978
public static function staticToStatic(string $sourceName, string $targetName): void
  {
    $source      = file_get_contents($sourceName);
    $sourceClass = basename($sourceName, '.php');
    $targetClass = basename($targetName, '.php');

    $source = NonStatic::nonStatic($source, $sourceClass, $targetClass);

    file_put_contents($targetName, $source);
  }
46499
public static function addTo( &$source, $key, $subKey, $value = null )
    {
        $_target = static::clean( static::get( $source, $key, array() ) );
        static::set( $_target, $subKey, $value );
        static::set( $source, $key, $_target );

        return $_target;
    }
904833
public static function setSource($source = null)
    {
        if (! is_resource($source) && ! is_null($source)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid source provided; must be a null or an resource, "%s" given.',
                is_object($source) ? get_class($source) : gettype($source)
            ));
        }
        static::$source = $source;
    }
106917
public SourceUnit addSource(SourceUnit source) {
        String name = source.getName();
        source.setClassLoader(this.classLoader);
        for (SourceUnit su : queuedSources) {
            if (name.equals(su.getName())) return su;
        }
        queuedSources.add(source);
        return source;
    }
1263189
public function addDependency(Source $source)
    {
        if ($this->parent !== null) {
            $this->parent->addDependency($source);
        }
        $tplId = $source->tplId;
        if ($source->type == 'string' || $source->type == 'base64') {
            $this->property['dependency'][$tplId] = $source->type;
            return;
        }
        $this->property['dependency'][$tplId] = [
            0 => $source->type,
            1 => $source->tplname,
            2 => $source->timestamp,
        ];
    }
1097175
public function add($name, $source = null, $dependencies = array(), $attributes = array())
    {
        if(!is_array($name)) {
            if(!isset($source)) throw new \ErrorException("Missing argument 2 for Facuz\Theme\AssetContainer::add()", 1);
            
            return $this->added($name, $source, $dependencies, $attributes);
        }

        foreach ($name as $array) {
            if(count($array) < 2) throw new \ErrorException("Missing value 2 of the array for Facuz\Theme\AssetContainer::add()", 1);
            $container = $array[0];
            $source = $array[1]; 
            $dependencies = isset($array[2]) ? $array[2] : [];
            $attributes = isset($array[3]) ? $array[3] : [];

            $this->add($container, $source, $dependencies, $attributes);
        }

        $this->usePath(false);
    }
1350272
public function hasInSource( $key, $source )
	{
		$source	= strtolower( $source );
		return isset( $this->sources[$source][$key] );
	}
749094
public function setDataSource($source)
	{
		$this->dataModel = new DataModel($source, $this->primary_key);

		$this->dataModel->onBeforeFilter[] = [$this, 'beforeDataModelFilter'];
		$this->dataModel->onAfterFilter[] = [$this, 'afterDataModelFilter'];
		$this->dataModel->onAfterPaginated[] = [$this, 'afterDataModelPaginated'];

		return $this;
	}
1337623
public function addSource($key, $value) {
		Validator::checkMemberName($key);
		
		$this->source[$key] = $value;
	}
549163
public function setSource($source)
    {
        $this->source = $source;
        $this->length = mb_strlen($source);
        $this->head = 0;
        $this->last= 0;
        $this->captures = array();
        $this->match = null;
        $this->reset();

        return $this;
    }
231873
public static function create($source)
    {
        if (is_array($source)) {
            $source = new Collection($source);
        }

        return parent::create($source);
    }
584259
public function setSource($sourceIso, $sourcePath, $sourceLanguagePath)
	{
		$this->sourceIso = $sourceIso;
		$this->sourcePath = $sourcePath;
		$this->sourceLanguagePath = $sourceLanguagePath;
		$this->langkeyValidator->setSource($sourceIso, $sourcePath, $sourceLanguagePath);
		return $this;
	}
673412
private function buildDatasourceInstance($sourceName, Logger $logger) {
        $parser = new YAMLParser($logger);
        $ymlFilePath = __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'credentials.yml';
        $parser->setFilePath($ymlFilePath);
        $dsConfig = $parser->loadConfig();
        $sourceName = trim($sourceName, "<br>");

        $datasourceClass = $dsConfig['database'][$sourceName]['class'];

        $datasource = new $datasourceClass($dsConfig['database'][$sourceName]['credentials']);
        $datasource->setLogger($logger);
   
        unset($parser);
        
        return $datasource;
    }
1274398
public function getResourcesBySourceName($sourceName)
    {
        // Getting source object first
        $source = $this->getSourceByName($sourceName);

        // Getting the data
        if ($source instanceof SourceInterface) {
            // Getting result iterator
            try {
                return $source->getContentIterator();
            } catch (\Exception $e) {
                throw new Exception\SourceGetDataException(
                    sprintf(
                        'Exception caught while getting the content for the following source object: %s',
                        $source->toString()
                    )
                );
            }
        }
        return null;
    }
585092
public function addDirectory($source) {
        $source = str_replace('\\', '/', realpath($source));

        if (is_dir($source) === true) {
            $files = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);

            foreach ($files as $file) {
                $file = str_replace('\\', '/', $file);

                // Ignore "." and ".." folders
                if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) )
                    continue;

                if (!is_link($file)) {
                    $file = realpath($file);
                }

                if (!is_link($file) && is_dir($file)) {
                    $this->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                } else if (is_link($file)) {
                    // @fixme This actually does not work. It will create a file in the zip, but it
                    // won't be a link pointing somewhere.
                    // I have not found a way to add a working symlink to a zip archive.
                    $this->addFile($file, str_replace($source . '/', '', $file));
                } else if (is_file($file)) {
                    $this->addFromString(str_replace($source . '/', '', $file),
                        file_get_contents($file));
                }
            }
        } else if (is_file($source) === true) {
            $this->addFromString(basename($source), file_get_contents($source));
        }
    }
976382
protected function compile($source, $filename = null)
    {
        $tokens = $this->lexer->tokenize($source, $filename);
        $source = $this->parser->parse($tokens, $filename);

        return $source;
    }