Skip to content

Commit

Permalink
Rename registerRecordAction methods
Browse files Browse the repository at this point in the history
since the registerCRUD does not register CRUD actions only.
  • Loading branch information
c9s committed Apr 26, 2014
1 parent 03a5c73 commit 458b0b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/ActionKit/ActionRunner.php
Expand Up @@ -144,7 +144,7 @@ public function loadClass($class)
// \FB::info('Generate action class: ' . $class);
// Generate the crud action
//
// @see registerCRUD method
// @see registerRecordAction method
$args = $this->crudActions[$class];
$template = $this->generator->generateRecordActionNs( $args['ns'] , $args['model_name'], $args['type'] );
return $this->loadClassTemplate($class, $template);
Expand Down Expand Up @@ -177,9 +177,9 @@ public function registerAction($targetActionClass, $templateName, $variables = a


/**
* $this->registerAction2('App\Action\SortProductType',[
* 'extends' => '....',
* 'properties' => [ 'recordClass' => .... ]
* $this->register('App\Action\SortProductType',[
* 'extends' => '....',
* 'properties' => [ 'recordClass' => .... ]
* ]);
*/
public function register($targetActionClass, $options = array() ) {
Expand All @@ -190,7 +190,7 @@ public function register($targetActionClass, $options = array() ) {
* Add CRUD action class to pool, so we can generate these class later
* if needed. (lazy)
*
* - registerCRUD( 'News' , 'News' , array('Create','Update') );
* - registerRecordAction( 'News' , 'News' , array('Create','Update') );
*
* Which generates:
*
Expand All @@ -201,7 +201,7 @@ public function register($targetActionClass, $options = array() ) {
* @param string $modelName model name
* @param array $types action types
*/
public function registerCRUD( $ns , $modelName , $types )
public function registerRecordAction( $ns , $modelName , $types )
{
foreach ( (array) $types as $type ) {
$class = $ns . '\\Action\\' . $type . $modelName;
Expand All @@ -219,6 +219,12 @@ public function registerCRUD( $ns , $modelName , $types )
}
}

public function registerCRUD( $ns , $modelName , $types )
{
$this->registerRecordAction( $ns, $modelName, $types );
}


public function isInvalidActionName( $actionName )
{
return preg_match( '/[^A-Za-z0-9:]/i' , $actionName );
Expand Down
2 changes: 1 addition & 1 deletion tests/ActionKit/ActionRunnerTest.php
Expand Up @@ -35,7 +35,7 @@ public function test()
$runner = ActionKit\ActionRunner::getInstance();
ok($runner);
$runner->registerAutoloader();
$runner->registerCRUD('User','User',array('Create','Update','Delete'));
$runner->registerRecordAction('User','User',array('Create','Update','Delete'));

$result = $runner->run('User::Action::CreateUser',[
'email' => 'foo@foo'
Expand Down

0 comments on commit 458b0b6

Please sign in to comment.