Newscoop\Installer\Services\DatabaseService::renderFile PHP Метод

renderFile() публичный Метод

Save TWIG template to file
public renderFile ( string $template, string $target, array $parameters ) : boolean
$template string
$target string
$parameters array
Результат boolean
    public function renderFile($template, $target, $parameters)
    {
        if (!is_dir(dirname($target))) {
            mkdir(dirname($target), 0777, true);
        }
        return file_put_contents($target, $this->renderTwigTemplate($template, $parameters));
    }

Usage Example

Пример #1
0
            }
        }
    }
}
$foldersToBeRemovedCompletely = array($newscoopDir . 'admin-files/lang');
foreach ($foldersToBeRemovedCompletely as $folder) {
    if (is_dir($folder)) {
        try {
            // Remove parent directory
            $filesystem->remove(array($folder));
        } catch (\Exception $e) {
            $msg = 'Could not remove folder ' . str_replace($newscoopDir, '', $folder) . ', please remove it and it\'s contents manually.';
            $logger->addError($msg);
            $upgradeErrors[] = $msg;
        }
    }
}
try {
    $configFile = realpath(__DIR__ . '/../../../../../../conf/configuration.php');
    $databaseService = new DatabaseService($logger);
    $databaseService->renderFile('_configuration.twig', $configFile, array());
} catch (\Exception $e) {
    $msg = "Could not update '" . $configFile . "', please update it manually." . " Copy content of '" . realpath(__DIR__ . '/../../../../../Resources/templates/_configuration.twig') . "' file to '" . $configFile . "' and save.\n";
    $logger->addError($msg);
    array_splice($upgradeErrors, 0, 0, array($msg));
}
if (count($upgradeErrors) > 0) {
    $msg = "Some files or directories could not automatically be removed. This is " . "most likely caused by permissions. \n" . "You can either remove the files manually (see {$newscoopDir}install/Resources/sql/upgrade/4.3.x/2014.09.22/delete_diff.txt) " . "or execute this file with root permissions, e.g.: \n" . "sudo php {$newscoopDir}install/Resources/sql/upgrade/4.3.x/2014.09.22/upgrade.php";
    $logger->addError($msg);
    array_splice($upgradeErrors, 0, 0, array($msg));
}