Files
firefly-iii/app/Http/Controllers/Json/IntroController.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2017-07-16 07:35:08 +02:00
<?php
/**
* IntroController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
2017-07-16 18:28:46 +02:00
use Preferences;
2017-07-16 07:35:08 +02:00
use Response;
/**
* Class IntroController
*
* @package FireflyIII\Http\Controllers\Json
*/
class IntroController
{
/**
* @param string $route
*
* @return \Illuminate\Http\JsonResponse
*/
public function getIntroSteps(string $route)
{
2017-07-16 18:14:29 +02:00
$route = str_replace('.', '_', $route);
2017-07-16 07:35:08 +02:00
$elements = config(sprintf('intro.%s', $route));
$steps = [];
if (is_array($elements) && count($elements) > 0) {
foreach ($elements as $key => $options) {
$currentStep = $options;
// point to HTML element when not an intro or outro:
if (!in_array($key, ['intro', 'outro'])) {
2017-07-16 18:14:29 +02:00
$currentStep['element'] = $options['selector'];
2017-07-16 07:35:08 +02:00
}
// get the text:
$currentStep['intro'] = trans('intro.' . $route . '_' . $key);
2017-07-16 18:14:29 +02:00
2017-07-16 07:35:08 +02:00
// save in array:
$steps[] = $currentStep;
}
}
return Response::json($steps);
}
/**
* @param string $route
*
* @return \Illuminate\Http\JsonResponse
*/
public function postFinished(string $route)
{
$key = 'shown_demo_' . $route;
2017-07-16 18:28:46 +02:00
Preferences::set($key, true);
2017-07-16 07:35:08 +02:00
return Response::json(['result' => sprintf('Reported demo watched for route "%s".', $route)]);
}
}