AppserverIo\Appserver\Core\GenericDeployment::prepareDatasourceFiles PHP Method

prepareDatasourceFiles() protected method

Prepares the datasource files by adding the found context name and the webapp path, if available.
protected prepareDatasourceFiles ( array $datasourceFiles ) : array
$datasourceFiles array The array with the datasource files to prepare
return array The prepared array
    protected function prepareDatasourceFiles(array $datasourceFiles)
    {
        // initialize the array for the prepared datasources
        $ds = array();
        // prepare the datasources
        foreach ($datasourceFiles as $datasourceFile) {
            // explode the directoriy names from the app base path
            $contextPath = explode(DIRECTORY_SEPARATOR, ltrim(str_replace(sprintf('%s', $this->getAppBase()), '', $datasourceFile), DIRECTORY_SEPARATOR));
            // the first element IS the context name
            $contextName = reset($contextPath);
            // create the path to the web application
            $webappPath = $this->getDatasourceService()->getWebappsDir($this->getContainer()->getContainerNode(), $contextName);
            // append it to the array with the prepared datasources
            $ds[] = array($datasourceFile, $webappPath, $contextName);
        }
        // return the array with the prepared datasources
        return $ds;
    }