Skip to content

Commit 4efda55

Browse files
committed
🚧 boilerplating functionality
1 parent a2bf9e8 commit 4efda55

7 files changed

Lines changed: 52 additions & 12 deletions

File tree

src/Exporter.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace TapestryCloud\Database;
4+
5+
use Tapestry\Entities\Project;
6+
7+
class Exporter {
8+
public function export(Project $project) {
9+
$n = 1;
10+
}
11+
}

src/ServiceProvider.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
use League\Container\ServiceProvider\AbstractServiceProvider;
55
use League\Container\ServiceProvider\BootableServiceProviderInterface;
66
use Tapestry\Entities\Configuration;
7+
use Tapestry\Entities\Project;
8+
use Tapestry\Tapestry;
9+
710
class ServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface
811
{
912
/** @var array */
10-
protected $provides = [];
13+
protected $provides = [
14+
Exporter::class
15+
];
1116
/**
1217
* Use the register method to register items with the container via the
1318
* protected $this->container property or the `getContainer` method
@@ -17,7 +22,9 @@ class ServiceProvider extends AbstractServiceProvider implements BootableService
1722
*/
1823
public function register()
1924
{
20-
// ...
25+
$this->getContainer()->add(Exporter::class, function() {
26+
return new Exporter();
27+
});
2128
}
2229
/**
2330
* Method will be invoked on registration of a service provider implementing
@@ -28,10 +35,15 @@ public function register()
2835
*/
2936
public function boot()
3037
{
31-
/** @var Engine $engine */
32-
$engine = $this->getContainer()->get(Engine::class);
33-
/** @var Configuration $configuration */
34-
$configuration = $this->getContainer()->get(Configuration::class);
35-
// Place your plugin bootstrapping here...
38+
/** @var Tapestry $tapestry */
39+
$tapestry = $this->getContainer()->get(Tapestry::class);
40+
/** @var Project $project */
41+
$project = $this->getContainer()->get(Project::class);
42+
43+
$tapestry->getEventEmitter()->addListener('loadsourcefiles.after', function () use ($project) {
44+
/** @var Exporter $exporter */
45+
$exporter = $this->getContainer()->get(Exporter::class);
46+
$exporter->export($project);
47+
});
3648
}
3749
}

tests/PluginTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
namespace TapestryCloud\Asset\Tests;
33
use Symfony\Component\Console\Input\ArrayInput;
44
use Tapestry\Console\DefaultInputDefinition;
5+
use Tapestry\Entities\Project;
56
use Tapestry\Tapestry;
67
class PluginTest extends \PHPUnit_Framework_TestCase
78
{
89
public function testPlugin(){
9-
//
10-
// The asset helper makes use of the `use` helper function which needs Tapestry loading
11-
// for it to work. Therefore we init Tapestry with a mock project folder.
12-
//
1310
$definitions = new DefaultInputDefinition();
1411
$tapestry = new Tapestry(new ArrayInput([
1512
'--site-dir' => __DIR__ . DIRECTORY_SEPARATOR . 'mock_project',
1613
'--env' => 'testing'
1714
], $definitions));
1815

16+
17+
18+
/** @var Project $project */
19+
$project = $tapestry->getContainer()->get(Project::class);
20+
1921
$n = 1;
2022
}
2123
}

tests/mock_project/kernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\MockProject;
44

55
use Tapestry\Modules\Kernel\KernelInterface;
6+
use TapestryCloud\Database\ServiceProvider;
67
use Tapestry\Tapestry;
78

89
class Kernel implements KernelInterface
@@ -38,6 +39,6 @@ public function register()
3839
*/
3940
public function boot()
4041
{
41-
// TODO: Implement boot() method.
42+
$this->tapestry->register(ServiceProvider::class);
4243
}
4344
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Benefits of static site generation
3+
tags:
4+
- development
5+
- website
6+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Tapestry the static site generator
3+
tags:
4+
- php
5+
- open source
6+
---
7+
8+
Hello world...

tests/mock_project/source/index.phtml

Whitespace-only changes.

0 commit comments

Comments
 (0)