Skip to content

Commit d6e3547

Browse files
committed
Emoji aimeos test store
1 parent 5fde412 commit d6e3547

File tree

402 files changed

+40399
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

402 files changed

+40399
-77
lines changed

app/Composer.php

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
<?php
2+
3+
/**
4+
* @license MIT, https://opensource.org/licenses/MIT
5+
* @copyright Aimeos (aimeos.org), 2017
6+
* @package aimeos
7+
*/
8+
9+
10+
namespace App;
11+
12+
use Composer\Script\Event;
13+
use Composer\Util\ProcessExecutor;
14+
use Symfony\Component\Process\PhpExecutableFinder;
15+
use Symfony\Component\Filesystem\Filesystem;
16+
17+
18+
/**
19+
* Performs setup during composer installs
20+
*
21+
* @package aimeos
22+
*/
23+
class Composer
24+
{
25+
private static $template = '
26+
<fg=blue>
27+
___ _
28+
/ | (_)___ ___ ___ ____ _____
29+
/ /| | / / __ __ \/ _ \/ __ \/ ___/
30+
/ __ |/ / / / / / / ___/ /_/ /\__ \
31+
/_/ |_/_/_/ /_/ /_/\___/\____/_____/
32+
</>
33+
Congratulations! You successfully set up your <fg=green>Aimeos</> shop!
34+
<fg=cyan>Video tutorials</>: https://www.youtube.com/c/aimeos
35+
<fg=cyan>Documentation</>: https://aimeos.org/docs
36+
<fg=cyan>Get help</>: https://aimeos.org/help
37+
<fg=cyan>Contribute</>: https://github.com/aimeos
38+
<fg=cyan>Give a star</>: https://github.com/aimeos/aimeos
39+
Made with <fg=green>love</> by the Aimeos community. Be a part of it!
40+
41+
<fg=cyan>Setup cronjobs:</> https://aimeos.org/docs/latest/laravel/setup/#cronjobs
42+
';
43+
44+
45+
/**
46+
* Creates a new admin account.
47+
*
48+
* @param Event $event Event instance
49+
* @throws \RuntimeException If an error occured
50+
*/
51+
public static function account( Event $event )
52+
{
53+
$io = $event->getIO();
54+
55+
$io->write( 'Create admin account' );
56+
flush(); // Enforce order of messages
57+
58+
$email = $io->ask( '- E-Mail: ' );
59+
$passwd = $io->askAndHideAnswer( '- Password: ' );
60+
61+
if( $email && $passwd )
62+
{
63+
$options = [
64+
escapeshellarg( $email ),
65+
'--password=' . escapeshellarg( $passwd ),
66+
'--super',
67+
'--admin'
68+
];
69+
70+
self::executeCommand( $event, 'aimeos:account', $options );
71+
}
72+
else
73+
{
74+
$io->write( 'No e-mail and password, skipped creating admin account' );
75+
}
76+
}
77+
78+
79+
/**
80+
* Configures the .env file.
81+
*
82+
* @param Event $event Event instance
83+
* @throws \RuntimeException If an error occured
84+
*/
85+
public static function configure( Event $event )
86+
{
87+
$io = $event->getIO();
88+
$filename = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . '.env';
89+
90+
if( ( $content = file_get_contents( $filename ) ) === false ) {
91+
throw \RuntimeException( sprintf( 'Can not read file "%1$s"', $filename ) );
92+
}
93+
94+
$matches = [];
95+
if( preg_match( "/^APP_KEY\=(.*)$/m", $content, $matches ) === 1 ) {
96+
$content = preg_replace( "/^APP_KEY\=.*$/m", 'APP_KEY="' . trim( $matches[1], '"' ) . '"', $content );
97+
}
98+
99+
if( ( $config = parse_ini_string( $content ) ) === false ) {
100+
throw \RuntimeException( sprintf( 'Can not parse file "%1$s"', $filename ) );
101+
}
102+
103+
104+
$io->write( 'Database setup' );
105+
flush(); // Enforce order of messages
106+
107+
foreach( ['DB_CONNECTION', 'DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USERNAME'] as $key ) {
108+
$config[$key] = $io->ask( '- ' . $key . ' (' . $config[$key] . '): ', $config[$key] );
109+
}
110+
$config['DB_PASSWORD'] = $io->askAndHideAnswer( '- DB_PASSWORD: ', $config['DB_PASSWORD'] );
111+
112+
$io->write( 'Mail setup' );
113+
flush(); // Enforce order of messages
114+
115+
foreach( ['MAIL_MAILER', 'MAIL_HOST', 'MAIL_PORT', 'MAIL_USERNAME', 'MAIL_ENCRYPTION'] as $key ) {
116+
$config[$key] = $io->ask( '- ' . $key . ' (' . $config[$key] . '): ', $config[$key] );
117+
}
118+
$config['MAIL_PASSWORD'] = $io->askAndHideAnswer( '- MAIL_PASSWORD: ', $config['MAIL_PASSWORD'] );
119+
120+
if( file_put_contents( $filename, self::createIniString( $config ) ) === false ) {
121+
throw \RuntimeException( sprintf( 'Can not write file "%1$s"', $filename ) );
122+
}
123+
}
124+
125+
126+
/**
127+
* @param Event $event Event instance
128+
* @throws \RuntimeException If an error occured
129+
*/
130+
public static function success( Event $event )
131+
{
132+
$event->getIO()->write( self::$template );
133+
134+
if( !$event->getIO()->hasAuthentication( 'github.com' ) ) {
135+
return;
136+
}
137+
138+
try
139+
{
140+
$options = [
141+
'http' => [
142+
'method' => 'POST',
143+
'header' => ['Content-Type: application/json'],
144+
'content' => json_encode( ['query' => 'mutation{
145+
_1: addStar(input:{clientMutationId:"_1",starrableId:"MDEwOlJlcG9zaXRvcnkxMDMwMTUwNzA="}){clientMutationId}
146+
_2: addStar(input:{clientMutationId:"_2",starrableId:"MDEwOlJlcG9zaXRvcnkzMTU0MTIxMA=="}){clientMutationId}
147+
_3: addStar(input:{clientMutationId:"_3",starrableId:"MDEwOlJlcG9zaXRvcnkyNjg4MTc2NQ=="}){clientMutationId}
148+
_4: addStar(input:{clientMutationId:"_4",starrableId:"MDEwOlJlcG9zaXRvcnkyMjIzNTY4OTA="}){clientMutationId}
149+
_5: addStar(input:{clientMutationId:"_5",starrableId:"MDEwOlJlcG9zaXRvcnkyNDYxMDMzNTY="}){clientMutationId}
150+
_6: addStar(input:{clientMutationId:"_6",starrableId:"R_kgDOGcKL7A"}){clientMutationId}
151+
_7: addStar(input:{clientMutationId:"_7",starrableId:"R_kgDOGeAkvw"}){clientMutationId}
152+
_8: addStar(input:{clientMutationId:"_8",starrableId:"R_kgDOG1PAJw"}){clientMutationId}
153+
}'
154+
] )
155+
]
156+
];
157+
$config = $event->getComposer()->getConfig();
158+
159+
if( method_exists( '\Composer\Factory', 'createHttpDownloader' ) )
160+
{
161+
\Composer\Factory::createHttpDownloader( $event->getIO(), $config )
162+
->get( 'https://api.github.com/graphql', $options );
163+
}
164+
else
165+
{
166+
\Composer\Factory::createRemoteFilesystem( $event->getIO(), $config )
167+
->getContents( 'github.com', 'https://api.github.com/graphql', false, $options );
168+
}
169+
}
170+
catch( \Exception $e ) {}
171+
}
172+
173+
174+
/**
175+
* Sets up the shop database.
176+
*
177+
* @param Event $event Event instance
178+
* @throws \RuntimeException If an error occured
179+
*/
180+
public static function setup( Event $event )
181+
{
182+
$options = [];
183+
184+
if( $event->isDevMode() ) {
185+
$options[] = '--option=setup/default/demo:1';
186+
}
187+
188+
self::executeCommand( $event, 'aimeos:setup', $options );
189+
}
190+
191+
192+
/**
193+
* Creates a INI file compatible string from key/value pairs
194+
*
195+
* @param array $config Associative list of key/value pairs
196+
* @return string INI file compatible string
197+
*/
198+
protected static function createIniString( array $config )
199+
{
200+
$content = '';
201+
202+
foreach( $config as $key => $value ) {
203+
$content .= $key . '=' . ( is_bool( $value ) ? (int) $value : $value ) . "\n";
204+
}
205+
206+
return $content . "\n";
207+
}
208+
209+
210+
/**
211+
* Executes a Symphony command.
212+
*
213+
* @param Event $event Command event object
214+
* @param string $cmd Command name to execute, e.g. "aimeos:update"
215+
* @param array List of configuration options for the given command
216+
* @throws \RuntimeException If the command couldn't be executed
217+
*/
218+
protected static function executeCommand( Event $event, $cmd, array $options = array() )
219+
{
220+
$process = new ProcessExecutor();
221+
$process->execute( '"' . self::getPhp() . '" artisan ' . $cmd . ' ' . implode( ' ', $options ) );
222+
}
223+
224+
225+
/**
226+
* Returns the path to the PHP interpreter.
227+
*
228+
* @return string Path to the PHP command
229+
* @throws \RuntimeException If PHP interpreter couldn't be found
230+
*/
231+
protected static function getPhp()
232+
{
233+
$phpFinder = new PhpExecutableFinder;
234+
235+
if( !( $phpPath = $phpFinder->find() ) ) {
236+
throw new \RuntimeException( 'The php executable could not be found, add it to your PATH environment variable and try again' );
237+
}
238+
239+
return $phpPath;
240+
}
241+
}

app/Console/Kernel.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*
13+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
14+
* @return void
15+
*/
16+
protected function schedule(Schedule $schedule)
17+
{
18+
// $schedule->command('inspire')->hourly();
19+
}
20+
21+
/**
22+
* Register the commands for the application.
23+
*
24+
* @return void
25+
*/
26+
protected function commands()
27+
{
28+
$this->load(__DIR__.'/Commands');
29+
30+
require base_path('routes/console.php');
31+
}
32+
}

app/Exceptions/Handler.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array<int, class-string<Throwable>>
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array<int, string>
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Auth\LoginRequest;
7+
use App\Providers\RouteServiceProvider;
8+
use Illuminate\Http\RedirectResponse;
9+
use Illuminate\Http\Request;
10+
use Illuminate\Support\Facades\Auth;
11+
use Illuminate\View\View;
12+
13+
class AuthenticatedSessionController extends Controller
14+
{
15+
/**
16+
* Display the login view.
17+
*/
18+
public function create(): View
19+
{
20+
session()->put('url.intended', url()->previous());
21+
return view('auth.login');
22+
}
23+
24+
/**
25+
* Handle an incoming authentication request.
26+
*/
27+
public function store(LoginRequest $request): RedirectResponse
28+
{
29+
$request->authenticate();
30+
31+
$request->session()->regenerate();
32+
33+
return redirect()->intended(airoute( 'aimeos_home' ));
34+
}
35+
36+
/**
37+
* Destroy an authenticated session.
38+
*/
39+
public function destroy(Request $request): RedirectResponse
40+
{
41+
Auth::guard('web')->logout();
42+
43+
$request->session()->invalidate();
44+
45+
$request->session()->regenerateToken();
46+
47+
return redirect(airoute( 'aimeos_home' ));
48+
}
49+
}

0 commit comments

Comments
 (0)