Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Boskovic
committed
Jun 25, 2012
1 parent
1de176c
commit fa072e4
Showing
4 changed files
with
218 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Bundles\Events; | ||
use Exception; | ||
use stack; | ||
use e; | ||
|
||
class Result { | ||
private $type; | ||
public function __construct($type) { | ||
$this->type = $type; | ||
} | ||
|
||
public function __call($method, $args) { | ||
$result = call_user_func_array(array(e::$events,$method), $args); | ||
switch($this->type) { | ||
case 'first': | ||
if(empty($result)) | ||
return null; | ||
return current($result); | ||
break; | ||
case 'last': | ||
if(empty($result)) | ||
return null; | ||
return end($result); | ||
break; | ||
case 'single': | ||
if(empty($result)) | ||
return null; | ||
elseif(count($result) > 1) | ||
throw new Exception("You are running an event that only wants one result, multiple bundles are responding."); | ||
return current($result); | ||
break; | ||
case 'all': | ||
return $result; | ||
break; | ||
} | ||
} | ||
} |
Oops, something went wrong.