|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Bdf\Prime\Entity\InitializableInterface; |
|
4
|
|
|
use Bdf\Prime\Entity\Model; |
|
5
|
|
|
use Bdf\Prime\Mapper\Mapper; |
|
6
|
|
|
use Bdf\Prime\Query\Custom\KeyValue\KeyValueQuery; |
|
7
|
|
|
use Bdf\Prime\Repository\EntityRepository; |
|
8
|
|
|
use Bdf\Prime\TestEmbeddedEntity; |
|
9
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; |
|
12
|
|
|
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; |
|
13
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
|
14
|
|
|
|
|
15
|
|
|
class TestKernel extends \Symfony\Component\HttpKernel\Kernel |
|
16
|
|
|
{ |
|
17
|
|
|
use \Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
public function registerBundles(): iterable |
|
20
|
|
|
{ |
|
21
|
|
|
return [ |
|
22
|
|
|
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
|
23
|
|
|
new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(), |
|
24
|
|
|
new \Symfony\Bundle\TwigBundle\TwigBundle(), |
|
25
|
|
|
new \Bdf\PrimeBundle\PrimeBundle(), |
|
26
|
|
|
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), |
|
27
|
|
|
]; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
protected function configureRoutes($routes) |
|
31
|
|
|
{ |
|
32
|
|
|
//$routes->add('index', '/')->controller([$this, 'indexAction']); |
|
33
|
|
|
if ($routes instanceof RouteCollectionBuilder) { |
|
34
|
|
|
$routes->add('/', 'kernel::indexAction'); |
|
35
|
|
|
$routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt'); |
|
36
|
|
|
$routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler'); |
|
37
|
|
|
} else { |
|
38
|
|
|
$routes->add('index', '/')->controller([$this, 'indexAction']); |
|
39
|
|
|
$routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml'); |
|
40
|
|
|
$routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml'); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
$loader->load(__DIR__.'/conf.yaml'); |
|
47
|
|
|
//$c->import(__DIR__.'/conf.yaml'); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function indexAction() |
|
51
|
|
|
{ |
|
52
|
|
|
TestEntity::repository()->schema()->migrate(); |
|
53
|
|
|
TestEntity::findById(5); |
|
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
return new \Symfony\Component\HttpFoundation\Response(<<<HTML |
|
56
|
|
|
<!DOCTYPE html> |
|
57
|
|
|
<html> |
|
58
|
|
|
<body>Hello World !</body> |
|
59
|
|
|
</html> |
|
60
|
|
|
HTML |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
class TestEntity extends Model |
|
67
|
|
|
{ |
|
68
|
|
|
public $id; |
|
69
|
|
|
public $name; |
|
70
|
|
|
public $dateInsert; |
|
71
|
|
|
public $parentId; |
|
72
|
|
|
public $parent; |
|
73
|
|
|
|
|
74
|
|
|
public function __construct(array $attributes = []) |
|
75
|
|
|
{ |
|
76
|
|
|
$this->import($attributes); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
class TestEntityMapper extends Mapper |
|
81
|
|
|
{ |
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritdoc} |
|
84
|
|
|
*/ |
|
85
|
|
|
public function schema() |
|
86
|
|
|
{ |
|
87
|
|
|
return [ |
|
88
|
|
|
'connection' => 'test', |
|
89
|
|
|
'database' => 'test', |
|
90
|
|
|
'table' => 'test_', |
|
91
|
|
|
]; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* {@inheritdoc} |
|
96
|
|
|
*/ |
|
97
|
|
|
public function buildFields($builder) |
|
98
|
|
|
{ |
|
99
|
|
|
$builder |
|
100
|
|
|
->integer('id')->autoincrement() |
|
101
|
|
|
->string('name') |
|
102
|
|
|
->datetime('dateInsert')->alias('date_insert')->nillable() |
|
103
|
|
|
; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|