本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::append方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::append方法的具体用法?PHP Filesystem::append怎么用?PHP Filesystem::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::append方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Enregistrement d'un vote
*
* @param string $nom
* @param array $inputs
* @return bool
*/
public function save($nom, $imputs)
{
// On récupère le chemin dans la configuration et on ajoute le nom du fichier
$path = config('sondage.files.path') . $nom;
// Si le fichier n'existe pas on le crée et l'initialise
if (!$this->files->exists($path)) {
// On récupère les questions
$questions = config('sondage.' . $nom . '.reponses');
// On crée un fichier avec le bon nombre de valeurs à 0
$this->files->put($path, implode(',', array_fill(0, count($questions), 0)));
// On crée aussi le fichier des Emails
$this->files->put($path . '_emails', '');
}
// On récupère les Emails déjà utilisés
$emails = $this->files->get($path . '_emails');
// Si l'Email a déjà été utilisé on renvoie une erreur
if (strpos($emails, $imputs['email']) !== false) {
return false;
}
// On mémorise l'Email
$this->files->append($path . '_emails', $imputs['email'] . "\n");
// Valeurs actuelles des scores
$score = explode(',', $this->files->get($path));
// Incrémentation de la valeur de l'option choisie
++$score[$imputs['options']];
// On enregistre les nouvelles valeurs dans le fichier
$this->files->put($path, implode(',', $score));
return true;
}
示例2: updateRoutesFile
/**
* Update routes file
*
* @param string $name
*
* @return boolean
*/
public function updateRoutesFile($routesFile, $name, $templatePath)
{
$modelVars = GeneratorsServiceProvider::getModelVars($name);
$routes = file_get_contents($routesFile);
$newRouteDefault = '\\Route::resource(\'{{models}}\', \'{{Models}}Controller\');' . "\n";
if ($this->file->exists($templatePath)) {
$newRoute = file_get_contents($templatePath);
} else {
$newRoute = $newRouteDefault;
}
$newRoute = GeneratorsServiceProvider::replaceModelVars($newRoute, $modelVars);
$newRouteDefault = GeneratorsServiceProvider::replaceModelVars($newRouteDefault, $modelVars);
$routesNoSpaces = str_replace(['\\t', ' '], '', $routes);
$newRouteNoSpaces = str_replace(['\\t', ' '], '', $newRoute);
$newRouteDefaultNoSpaces = str_replace(['\\t', ' '], '', $newRouteDefault);
if (str_contains($routesNoSpaces, $newRouteDefaultNoSpaces) && !str_contains($routesNoSpaces, $newRouteNoSpaces)) {
if (substr($newRoute, -1) === "\n") {
$newRoute = substr($newRoute, 0, -1);
}
$newRoute = '// ' . str_replace("\n", "\n// ", $newRoute) . "\n";
$newRouteNoSpaces = str_replace(['\\t', ' '], '', $newRoute);
}
if (!str_contains($routesNoSpaces, $newRouteNoSpaces)) {
if (!str_contains($routes, GeneratorsServiceProvider::GENERATOR_ROUTE_TAG)) {
$this->file->append($routesFile, "\n{$newRoute}\n" . GeneratorsServiceProvider::GENERATOR_ROUTE_TAG . "\n\n");
} else {
$routes = str_replace(GeneratorsServiceProvider::GENERATOR_ROUTE_TAG, $newRoute . GeneratorsServiceProvider::GENERATOR_ROUTE_TAG, $routes);
file_put_contents($routesFile, $routes);
}
return true;
}
return false;
}
示例3: generate
/**
* Compiles the stylesheets
*
* @param $temp Path to temp file
* @return void
*/
protected function generate($temp)
{
// @refactor
// This code doesn't make any sense.
// We need to add a validation that at least a single stylesheet is required
$this->fs->append($temp, '');
foreach ($this->stylesheets as $stylesheet) {
if (!array_get($this->inputs, strtolower($stylesheet))) {
continue;
}
$file = $this->fs->get(public_path("milligram/{$stylesheet}.css"));
$this->fs->append($temp, $file);
}
}
示例4: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->callSilent('route:clear');
$app = $this->getFreshApplication();
$this->call('route:cache');
$routes = $app['api.router']->getAdapterRoutes();
foreach ($routes as $collection) {
foreach ($collection as $route) {
$app['api.router.adapter']->prepareRouteForSerialization($route);
}
}
$stub = "app('api.router')->setAdapterRoutes(unserialize(base64_decode('{{routes}}')));";
$this->files->append($this->laravel->getCachedRoutesPath(), str_replace('{{routes}}', base64_encode(serialize($routes)), $stub));
}
示例5: addRoute
/**
* Add routes for resource
*/
protected function addRoute()
{
$line = sprintf("%sRoute::pattern('%s', '[0-9]+');%s", PHP_EOL, $this->varModelName, PHP_EOL);
$line .= sprintf("Route::resource('%s', '%sController', ['only' => ['index', 'show', 'store', 'destroy']]);%s", $this->varModelName, $this->modelName, PHP_EOL);
$line .= sprintf("Route::put('%s/{%s}', '%sController@store');%s", $this->varModelName, $this->varModelName, $this->modelName, PHP_EOL);
$this->files->append($this->getPath('route'), $line);
}
示例6: logInfo
/**
* write log
* @param string $logContent [logContent]
* @param string $logDirPath [filepath]
*/
public function logInfo($logContent, $logDirPath)
{
$filesystem = new Filesystem();
if (!$logContent || !$logDirPath) {
return false;
}
if ($this->getMailLog()) {
// log file all path
$logPath = $logDirPath . $this->getLogName();
if ($filesystem->exists($logPath)) {
// everyDay new a file
$content = $filesystem->get($logPath);
if ($logTime = substr($content, 1, 10)) {
if (Carbon::now($this->local)->toDateString() == $logTime) {
$filesystem->append($logPath, $logContent . PHP_EOL);
} else {
$new_log_path = $logDirPath . $logTime . $this->getLogName();
if (!$filesystem->exists($new_log_path)) {
$filesystem->move($logPath, $new_log_path);
}
$filesystem->put($logPath, $logContent);
}
}
} else {
$filesystem->put($logPath, $logContent);
}
}
}
示例7: addRoute
/**
* Add routes for resource
*/
protected function addRoute()
{
$line = sprintf('$app->get(\'%s\', \'%sController@index\');%s', $this->varModelName, $this->modelName, PHP_EOL);
$line .= sprintf('$app->get(\'%s/{%s}\', \'%sController@show\');%s', $this->varModelName, $this->varModelName, $this->modelName, PHP_EOL);
$line .= sprintf('$app->post(\'%s\', \'%sController@store\');%s', $this->varModelName, $this->modelName, PHP_EOL);
$line .= sprintf('$app->put(\'%s/{%s}\', \'%sController@store\');%s', $this->varModelName, $this->varModelName, $this->modelName, PHP_EOL);
$line .= sprintf('$app->delete(\'%s/{%s}\', \'%sController@destroy\');%s', $this->varModelName, $this->varModelName, $this->modelName, PHP_EOL);
$this->files->append($this->getPath('route'), $line);
}
示例8: appendRoutes
private function appendRoutes($modelName)
{
$modelTitle = ucfirst($modelName);
$modelName = strtolower($modelName);
$newRoutes = $this->files->get(__DIR__ . '/../Stubs/routes.stub');
$newRoutes = str_replace('|MODEL_TITLE|', $modelTitle, $newRoutes);
$newRoutes = str_replace('|MODEL_NAME|', $modelName, $newRoutes);
$newRoutes = str_replace('|CONTROLLER_NAME|', $modelTitle . 'Controller', $newRoutes);
$this->files->append(app_path('Http/routes.php'), $newRoutes);
$this->info('Added routes for ' . $modelTitle);
}
示例9: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->file->deleteDirectory(base_path('resources/assets/less'));
$this->file->deleteDirectory(app_path('Http/Controllers/Auth'));
$this->file->delete([app_path('Http/Controllers/HomeController.php'), app_path('Http/Controllers/WelcomController.php')]);
$this->file->put(app_path('Http/routes.php'), "<?php\n");
$this->file->append(base_path('.gitignore'), "bower_components\n.vagrant\n.idea\nnode_modules\n");
foreach ($this->ensureDirectories as $dir) {
$this->file->makeDirectory($dir, 0755, true);
}
foreach ($this->blueprintFiles as $blueprint) {
$this->copyBlueprint($blueprint);
}
passthru('cd ' . base_path() . ' && bower install && npm install && npm install gulp-concat --save-dev');
foreach ($this->bowerComponents as $src => $dest) {
$this->pullInBowerComponent($src, $dest);
}
$this->updateBootstrapImports();
$this->updateSbAdminImports();
passthru('cd ' . base_path() . ' && gulp');
}
示例10: updateRoutesFile
/**
* Function to handle updating the routes file
* for us
*
* @param string $name
* @param string $dir
* @return void
*/
public function updateRoutesFile($name, $dir)
{
$name = strtolower(Pluralizer::plural($name));
$routes = implode(DIRECTORY_SEPARATOR, [$dir, 'app', 'routes.php']);
if ($this->filesystem->exists($routes)) {
$route = "Route::resource('" . $name . "', '" . ucwords($name) . "Controller');";
$contents = $this->filesystem->get($routes);
if (str_contains($contents, $route)) {
return;
}
$this->filesystem->append($routes, "\n\n" . $route);
}
}
示例11: registerClassArguments
/**
* Registers the Api classes with the container to inject the host as the first parameter
*
* @param string $file
* @param array $classes
*/
private function registerClassArguments($file, array $classes)
{
// Only need 1 copy of the class name
$classes = array_unique($classes);
$contents = " /**" . PHP_EOL;
$contents .= " * Register the class' arguments with the container" . PHP_EOL;
$contents .= " */" . PHP_EOL;
$contents .= " public function registerApiBindings()" . PHP_EOL;
$contents .= " {" . PHP_EOL;
foreach ($classes as $class) {
$contents .= " \$this->add('" . $this->generator->generatedNamespace($class) . "')->withArgument(\$this->getHost())->withArgument(\$this->getSoapOptions());" . PHP_EOL;
}
$contents .= " }" . PHP_EOL . PHP_EOL;
$this->files->append($file, $contents);
}
示例12: append
/**
* Append to a file.
*
* @param string $path
* @param string $data
* @return int
* @static
*/
public static function append($path, $data)
{
return \Illuminate\Filesystem\Filesystem::append($path, $data);
}
示例13: updateRoutesFile
/**
* Update app/routes.php
*
* @param string $name
* @return void
*/
public function updateRoutesFile($name)
{
$name = strtolower(Pluralizer::plural($name));
$this->file->append(app_path() . '/routes.php', "\n\nRoute::resource('" . $name . "', '" . ucwords($name) . "Controller');");
}
示例14: store
/**
* Store the given pipeline and its pipes.
*
* @author Andrea Marco Sartori
* @param string $pipeline
* @param array $pipes
* @return void
*/
public function store($pipeline, array $pipes)
{
$workflow = [$pipeline => $pipes];
$yaml = $this->parser->dump($workflow);
$this->files->append($this->getSource(), $yaml);
}