Skip to content

Commit 1e0f29d

Browse files
committed
Initial work for big migration to fully supporting Symfony Kernel.
0 parents  commit 1e0f29d

20 files changed

+1783
-0
lines changed

Bundle/AbstractBundle.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is a part of Sculpin.
5+
*
6+
* (c) Dragonfly Development Inc.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Sculpin\Core\Bundle;
13+
14+
use Sculpin\Core\Configuration\Configuration;
15+
use Sculpin\Core\Sculpin;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
18+
use Symfony\Component\HttpKernel\Bundle\Bundle;
19+
20+
/**
21+
* Abstract Sculpin Bundle.
22+
*
23+
* @author Beau Simensen <[email protected]>
24+
*/
25+
abstract class AbstractBundle extends Bundle implements EventSubscriberInterface
26+
{
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
public static function getSubscribedEvents()
31+
{
32+
return array();
33+
}
34+
}

Configuration/Configuration.php

+280
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
<?php
2+
3+
/*
4+
* This file is a part of Sculpin.
5+
*
6+
* (c) Dragonfly Development Inc.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Sculpin\Core\Configuration;
13+
14+
use Dflydev\DotAccessConfiguration\Configuration as BaseConfiguration;
15+
16+
/**
17+
* Configuration.
18+
*
19+
* @author Beau Simensen <[email protected]>
20+
*/
21+
class Configuration extends BaseConfiguration
22+
{
23+
/**
24+
* Exclusion patterns
25+
*
26+
* @var array
27+
*/
28+
private $exclusions = array();
29+
30+
/**
31+
* Ignore patterns
32+
*
33+
* @var array
34+
*/
35+
private $ignores = array();
36+
37+
/**
38+
* Raw patterns
39+
*
40+
* @var array
41+
*/
42+
private $raws = array();
43+
44+
/**
45+
* Source directory
46+
*
47+
* @var string
48+
*/
49+
private $sourceDir;
50+
51+
/**
52+
* Output directory
53+
*
54+
* @var string
55+
*/
56+
private $outputDir;
57+
58+
/**
59+
* Default permalink
60+
*
61+
* @var string
62+
*/
63+
private $permalink;
64+
65+
/**
66+
* Default formatter
67+
*
68+
* @var string
69+
*/
70+
private $defaultFormatter;
71+
72+
/**
73+
* Set excludes
74+
*
75+
* NOTE: Does not clear existing values first.
76+
*
77+
* @param array $excludes Excludes.
78+
*
79+
* @return Configuration
80+
*/
81+
public function setExcludes(array $excludes = array())
82+
{
83+
foreach ($excludes as $exclude) {
84+
$this->addExclude($exclude);
85+
}
86+
87+
return $this;
88+
}
89+
90+
/**
91+
* Add an exclude pattern
92+
*
93+
* @param string $pattern
94+
*
95+
* @return Configuration
96+
*/
97+
public function addExclude($pattern)
98+
{
99+
if (substr($pattern, 0, 2)=='./') {
100+
$pattern = substr($pattern, 2);
101+
}
102+
103+
if (!in_array($pattern, $this->exclusions)) {
104+
$this->exclusions[] = $pattern;
105+
}
106+
107+
return $this;
108+
}
109+
110+
/**
111+
* Set ignores
112+
*
113+
* NOTE: Does not clear existing values first.
114+
*
115+
* @param array $ignores Ignores.
116+
*
117+
* @return Configuration
118+
*/
119+
public function setIgnores(array $ignores = array())
120+
{
121+
foreach ($ignores as $ignore) {
122+
$this->addIgnore($ignore);
123+
}
124+
125+
return $this;
126+
}
127+
128+
/**
129+
* Add an ignore pattern
130+
*
131+
* @param string $pattern
132+
*
133+
* @return Configuration
134+
*/
135+
public function addIgnore($pattern)
136+
{
137+
if (substr($pattern, 0, 2)=='./') {
138+
$pattern = substr($pattern, 2);
139+
}
140+
141+
if (!in_array($pattern, $this->ignores)) {
142+
$this->ignores[] = $pattern;
143+
}
144+
145+
return $this;
146+
}
147+
148+
/**
149+
* Set raws
150+
*
151+
* NOTE: Does not clear existing values first.
152+
*
153+
* @param array $raws Raws.
154+
*
155+
* @return Configuration
156+
*/
157+
public function setRaws(array $raws = array())
158+
{
159+
foreach ($raws as $raw) {
160+
$this->addRaw($raw);
161+
}
162+
163+
return $this;
164+
}
165+
166+
/**
167+
* Add a raw pattern
168+
*
169+
* @param string $pattern
170+
*
171+
* @return Configuration
172+
*/
173+
public function addRaw($pattern)
174+
{
175+
if (substr($pattern, 0, 2)=='./') {
176+
$pattern = substr($pattern, 2);
177+
}
178+
if (!in_array($pattern, $this->raws)) {
179+
$this->raws[] = $pattern;
180+
}
181+
182+
return $this;
183+
}
184+
185+
/**
186+
* Set source directory
187+
*
188+
* @param string $sourceDir Source directory
189+
*
190+
* @return Configuration
191+
*/
192+
public function setSourceDir($sourceDir)
193+
{
194+
$this->sourceDir = $sourceDir;
195+
196+
return $this;
197+
}
198+
199+
/**
200+
* Source directory
201+
*
202+
* @return string
203+
*/
204+
public function sourceDir()
205+
{
206+
return $this->sourceDir;
207+
}
208+
209+
/**
210+
* Set output directory
211+
*
212+
* @param string $outputDir Output directory
213+
*
214+
* @return $this
215+
*/
216+
public function setOutputDir($outputDir)
217+
{
218+
$this->outputDir = $outputDir;
219+
220+
return $this;
221+
}
222+
223+
/**
224+
* Output directory
225+
*
226+
* @return string
227+
*/
228+
public function outputDir()
229+
{
230+
return $this->outputDir;
231+
}
232+
233+
/**
234+
* Set permalink
235+
*
236+
* @param string $permalink Permalink
237+
*
238+
* @return $this
239+
*/
240+
public function setPermalink($permalink)
241+
{
242+
$this->permalink = $permalink;
243+
244+
return $this;
245+
}
246+
247+
/**
248+
* Permalink
249+
*
250+
* @return string
251+
*/
252+
public function permalink()
253+
{
254+
return $this->permalink;
255+
}
256+
257+
/**
258+
* Set default formatter
259+
*
260+
* @param string $defaultFormatter Default formatter
261+
*
262+
* @return Configuration
263+
*/
264+
public function setDefaultFormatter($defaultFormatter)
265+
{
266+
$this->defaultFormatter = $defaultFormatter;
267+
268+
return $this;
269+
}
270+
271+
/**
272+
* Default formatter
273+
*
274+
* @return string
275+
*/
276+
public function defaultFormatter()
277+
{
278+
return $this->defaultFormatter;
279+
}
280+
}
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Sculpin\Core\Console\Command;
13+
14+
use Symfony\Component\Console\Command\Command;
15+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
16+
use Symfony\Component\DependencyInjection\ContainerInterface;
17+
18+
/**
19+
* Command.
20+
*
21+
* @author Fabien Potencier <[email protected]>
22+
*/
23+
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
24+
{
25+
/**
26+
* @var ContainerInterface
27+
*/
28+
private $container;
29+
30+
/**
31+
* @return ContainerInterface
32+
*/
33+
protected function getContainer()
34+
{
35+
if (null === $this->container) {
36+
$this->container = $this->getApplication()->getKernel()->getContainer();
37+
}
38+
39+
return $this->container;
40+
}
41+
42+
/**
43+
* Set Container.
44+
*
45+
* @param ContainerInterface $container Container
46+
*
47+
* @see ContainerAwareInterface::setContainer()
48+
*/
49+
public function setContainer(ContainerInterface $container = null)
50+
{
51+
$this->container = $container;
52+
}
53+
}

0 commit comments

Comments
 (0)