Example #1
0
File: index.php Project: pasls/tdk
<?php

require 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
use Pasls\TDK\TDK;
$tdk = new TDK(array('theme.dir' => dirname(__FILE__) . '/theme', 'root.dir' => dirname(__FILE__)));
$app = $tdk->getApp();
$faker = $tdk->getFaker();
$categories = [];
for ($i = 0; $i < 10; $i++) {
    $categories[] = ['name' => $faker->word, 'slug' => $faker->slug];
}
$pages = [];
for ($i = 0; $i < 5; $i++) {
    $pages[] = ["title" => $faker->sentence(), "body" => $faker->text(), "created" => $faker->date()];
}
//$view->set('categories', $categories);
//$view->set('pages', $pages);
// global config
/* routes */
// home route
$app->get('/(:page)', function ($page = 1) use($tdk, $app) {
    $app->render("index.html.twig", ['products' => $tdk->makeProducts($page)]);
})->name("home");
//category route
$app->get('/category/:slug(/:page)', function ($slug, $page = 1) use($tdk, $app) {
    $products = $tdk->makeProducts($page);
    $app->render("category.html.twig", ['products' => $products, 'category' => ["name" => $tdk->getFaker()->word, "slug" => $slug]]);
})->name("category");
// product detail route
$app->get('/product/:slug', function ($slug) use($tdk, $app) {
Example #2
0
 public function __construct(TDK $app)
 {
     $this->app = $app;
     $this->faker = $app->getFaker();
 }