Skip to content

Commit

Permalink
toActionClass method
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Apr 26, 2014
1 parent 6ca92fb commit 4b59ca4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ActionKit/ActionRunner.php
Expand Up @@ -89,13 +89,12 @@ public function __construct($options = array()) {
* */
public function run($actionName, $arguments = array() )
{
if ( $this->isInvalidActionName( $actionName ) ) {
if ( ! Utils::validateActionName( $actionName ) ) {
throw new Exception( "Invalid action name: $actionName." );
}

/* translate :: into php namespace */
$class = $this->getActionClass( $actionName );

$class = Utils::toActionClass($actionName);

/* register results into hash */
if ( $action = $this->createAction( $class , $arguments ) ) {
Expand Down
5 changes: 5 additions & 0 deletions src/ActionKit/Utils.php
Expand Up @@ -9,6 +9,11 @@ class Utils
public static function validateActionName($actionName) {
return ! preg_match( '/[^A-Za-z0-9:]/i' , $actionName );
}

public static function toActionClass( $sig ) {
// replace :: with '\'
return str_replace( '::' , '\\' , $sig );
}
}


Expand Down

0 comments on commit 4b59ca4

Please sign in to comment.