@param $source

@return DataSourceInterface
548134
protected function findDataSource($source)
    {
        foreach ($this->dataSources as $dataSource) {
            if ($dataSource->supports($source)) {
                return $dataSource;
            }
        }

        throw new \RuntimeException('Unknown source type');
    }
653725
protected function getPdoConnection($datasource)
    {
        $buildConnection = $this->getConnection($datasource);
        $dsn = str_replace("@DB@", $datasource, $buildConnection['dsn']);

        // Set user + password to null if they are empty strings or missing
        $username = isset($buildConnection['user']) && $buildConnection['user'] ? $buildConnection['user'] : null;
        $password = isset($buildConnection['password']) && $buildConnection['password'] ? $buildConnection['password'] : null;

        $pdo = new PDO($dsn, $username, $password);
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        return $pdo;
    }
185030
protected function castStream($source): StreamInterface
    {
        if ($source instanceof UploadedFileInterface || $source instanceof StreamableInterface) {
            $source = $source->getStream();
        }

        if ($source instanceof StreamInterface) {
            //This step is important to prevent user errors
            $source->rewind();

            return $source;
        }

        if (is_resource($source)) {
            return stream_for($source);
        }

        if (empty($source)) {
            //Guzzle?
            return stream_for('');
        }

        if ($this->isFilename($source)) {
            //Must never pass user string in here, use Stream
            return stream_for(fopen($source, 'rb'));
        }

        //We do not allow source names in a string form
        throw new BucketException(
            "Source must be a valid resource, stream or filename, invalid value given"
        );
    }
1082990
public static function load($source) {

		if(false === is_string($source) && false === $source instanceof Viewmodel) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or instance of sFire\MVC\Viewmodel, "%s" given', __METHOD__, gettype($source)), E_USER_ERROR);
		}

		$file = $source;

		if($source instanceof Viewmodel) {

			$path 			= Path :: get('modules') . Router :: getRoute() -> getModule() . DIRECTORY_SEPARATOR;
			$views 			= $path . Application :: get(['directory', 'view']);
			$translations 	= $path . Application :: get(['directory', 'translation']);
			$extension 		= Application :: get(['extensions', 'view']);
			$file  			= preg_replace('#^'. preg_quote($views) .'#', '', $source -> getFile());
			$file  			= preg_replace('#'. preg_quote($extension) .'$#', '', $file);
		}

		$module 	= Router :: getRoute() -> getModule();
		$extension 	= Application :: get(['extensions', 'translation']);
		$file 		= str_replace('.', DIRECTORY_SEPARATOR, $file);
		$file 		= Path :: get('modules') . $module . DIRECTORY_SEPARATOR . Application :: get(['directory', 'translation']) . $file . $extension;
		$file 		= new File($file);
		$identifier = md5($file -> entity() -> getBasepath());
		$cache 		= new File(Path :: get('cache-translation') . $identifier);

		if(false === $file -> exists() && false === $source instanceof Viewmodel) {
			return trigger_error(sprintf('Translation file "%s" used in %s() does not exists', $file -> entity() -> getBasepath(), __METHOD__), E_USER_ERROR);
		}

		static :: cache($cache, $file);

		return $identifier;
	}
1267817
public function updateSource(Common\ISource $source)
    {
        return $this->update($source, $this->isGroupJoin, $this->filter, $this->hasDefault);
    }
398470
public function models(Source $source = null) {
		if ($source) {
			$this->applyStrategy($source);
		}
		return $this->_models;
	}
546862
protected static function makeSource($source): SourceInterface
    {
        if (is_array($source) || $source instanceof \ArrayAccess) {
            return new ArraySource($source);
        }

        if (is_object($source)) {
            return new ObjectSource($source);
        }

        throw new InvalidSourceException(
            sprintf('Source type "%s" cannot be recognized as suitable storage', gettype($source))
        );
    }
1055600
public function setSource($source)
    {
        $controller = Controller::curr();
        $code = $controller->data()->Code;
        $updated = [];
        if (is_array($source) && !empty($source)) {
            foreach ($source as $key => $val) {
                $updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val;
            }
        }
        $this->source = $updated;

        return $this;
    }
802187
public function addOrder($source)
    {
        $orders   = $this->getOrders();
        $orders[] = $source;

        $this->setData('orders', $orders);

        return $this;
    }
205461
protected function makeReadResource($source)
    {
        if (is_resource($source)) {
            return $source;
        }

        if (is_string($source)) {
            $resource = @fopen($source, 'r');

            if ($resource) {
                return $resource;
            }

            $errorInfo = error_get_last();
            throw new FileException(sprintf(
                'Unable to open the file `%s` for reading%s',
                $source,
                $errorInfo ? ': '.$errorInfo['message'] : ''
            ));
        }

        throw new InvalidArgumentException(sprintf(
            'The given source expected to be a file path of a resource, a %s given',
            is_object($source) ? get_class($source).' instance' : gettype($source)
        ));
    }
696192
public function getDataProvider($source = null)
    {
        if (null === $source) {
            $source = $this->getDataDefinition()->getBasicDefinition()->getDataProvider();
        }

        if (isset($this->arrDataProvider[$source])) {
            return $this->arrDataProvider[$source];
        }

        throw new DcGeneralRuntimeException(\sprintf('Data provider %s not defined', $source));
    }
962146
public function loadSource($source)
    {
        $parser = new Parser();

        list($this->headers, $this->content) = $parser->parsePart($source);
    }
764166
protected function determineLoader($source): LoaderInterface
    {
        expect_type($source, ['object', 'string']);

        return is_object($source)
            ? $this->determineLoaderFromClass($source)
            : $this->determineLoaderFromPath($source);
    }
972026
private function loadWithSource($Source)
    {
        if (empty ($Source)) {
            return array();
        }
        if ($this->settingUseSyckIsPossible && function_exists ('syck_load')) {
            $array = syck_load (implode ('', $Source));

            return is_array($array) ? $array : array();
        }

        $this->path = array();
        $this->result = array();
        $cnt = count($Source);

        for ($i = 0; $i < $cnt; $i++) {
            $line = $Source[$i];

            $this->indent = strlen($line) - strlen(ltrim($line));
            $tempPath = $this->getParentPathByIndent($this->indent);
            $line = self::stripIndent($line, $this->indent);

            if (self::isComment($line)) {
                continue;
            }
            if (self::isEmpty($line)) {
                continue;
            }

            $this->path = $tempPath;
            $literalBlockStyle = self::startsLiteralBlock($line);

            if ($literalBlockStyle) {
                $line = rtrim ($line, $literalBlockStyle . " \n");
                $literalBlock = '';
                $line .= $this->LiteralPlaceHolder;
                $literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1]));

                while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) {
                    $literalBlock = $this->addLiteralLine(
                        $literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent
                    );
                }

                $i--;
            }

            while (++$i < $cnt && self::greedilyNeedNextLine($line)) {
                $line = rtrim($line, " \n\t\r") . ' ' . ltrim($Source[$i], " \t");
            }

            $i--;

            if (strpos($line, '#')) {
                if (strpos($line, '"') === false && strpos($line, "'") === false) {
                    $line = preg_replace('/\s+#(.+)$/','',$line);
                }
            }

            $lineArray = $this->parseLine($line);

            if ($literalBlockStyle) {
                $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock);
            }

            $this->addArray($lineArray, $this->indent);

            foreach ($this->delayedPath as $indent => $delayedPath) {
                $this->path[$indent] = $delayedPath;
            }

            $this->delayedPath = array();

        }

        return $this->result;
    }
1101773
public function databaseConnection($dataSource = 'default')
    {
        try {
            $connection = ConnectionManager::get($dataSource);
            $connected = $connection->connect();
        } catch (MissingConnectionException $connectionError) {
            $connected = false;
        }
        return $connected;
    }
1210486
static public function create($source): DataSet
    {
        if (is_array($source)) {
            $processorType = 'Array';
        } else if (is_file($source)) {
            $processorType = pathinfo($source, PATHINFO_EXTENSION);
        }

        $processor = sprintf("%s\\Processor\\%sProcessor",
            __NAMESPACE__,
            ucfirst(strtolower($processorType ?? ''))
        );

        if (! class_exists($processor)) {
            throw new WrongUsageException('Can not handle data from given source : ' . (is_string($source) ? $source : gettype($source)));
        }

        try {
            return new DataSet(new $processor($source));
        } catch (\Throwable $e) {
            throw new WrongUsageException('The dataSet could not be created : ' . $e->getMessage());
        }
    }
179467
abstract public function __construct(DataAccessInterface $dataSource);
    
    /**
     * Returns an array with all entities for the given data request.
     * 
     * @param \Zepi\DataSource\Core\DataRequest $dataRequest
     * @return false|array
     */
    public function find(DataRequest $dataRequest)
    {
        return $this->dataSource->find($dataRequest);
    }