Skip to content

Commit 01fca69

Browse files
committed
Fixed some issues with gears and allow gears to be disabled.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
1 parent 442bb58 commit 01fca69

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

components/gear/manager.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Feather\Components\Gear;
22

3+
use Event;
34
use FilesystemIterator;
45
use Feather\Models\Gear;
56
use InvalidArgumentException;
@@ -102,7 +103,7 @@ public function start($gear)
102103
{
103104
if(ends_with($file->getFilename(), '.gear.php'))
104105
{
105-
require $file->getPathname();
106+
require_once $file->getPathname();
106107

107108
$name = str_replace('.gear.php', null, $file->getFilename());
108109

@@ -129,6 +130,20 @@ public function started($gear)
129130
return isset($this->started[$gear]);
130131
}
131132

133+
/**
134+
* Disable a gear for this run only.
135+
*
136+
* @param string $gear
137+
* @return void
138+
*/
139+
public function disable($gear)
140+
{
141+
if($this->registered($gear))
142+
{
143+
unset($this->gears[$gear]);
144+
}
145+
}
146+
132147
/**
133148
* Gets a Gears container.
134149
*
@@ -145,4 +160,28 @@ public function get($gear)
145160
return $this->started[$gear];
146161
}
147162

163+
/**
164+
* Fire an event and implodes the returned results.
165+
*
166+
* @param string $event
167+
* @param array $parameters
168+
* @return string
169+
*/
170+
public function fire($event, $parameters = array())
171+
{
172+
return implode(PHP_EOL, array_filter(Event::fire($event, array($parameters))));
173+
}
174+
175+
/**
176+
* Fire the first event in the queue.
177+
*
178+
* @param string $event
179+
* @param array $parameters
180+
* @return string
181+
*/
182+
public function first($event, $parameters = array())
183+
{
184+
return Event::first($event, $parameters);
185+
}
186+
148187
}

0 commit comments

Comments
 (0)