Skip to content
Permalink
Browse files

Remove leftovers from Controller cleanup.

Refs #2375
  • Loading branch information...
markstory committed Nov 23, 2013
1 parent 5cc2aad commit 236760a371692b7a4fa3f83684311bd2349e9f78
@@ -150,7 +150,6 @@ protected function _interactive() {
$helpers = $components = [];
$actions = '';
$wannaUseSession = 'y';
$wannaBakeAdminCrud = 'n';
$useDynamicScaffold = 'n';
$wannaBakeCrud = 'y';
@@ -175,21 +174,17 @@ protected function _interactive() {
$helpers = $this->doHelpers();
$components = $this->doComponents();
$wannaUseSession = $this->in(
__d('cake_console', "Would you like to use Session flash messages?"), ['y', 'n'], 'y'
);
}
} else {
list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods();
}
if (strtolower($wannaBakeCrud) === 'y') {
$actions = $this->bakeActions($controllerName, null, strtolower($wannaUseSession) === 'y');
$actions = $this->bakeActions($controllerName, null);
}
if (strtolower($wannaBakeAdminCrud) === 'y') {
$admin = $this->Project->getPrefix();
$actions .= $this->bakeActions($controllerName, $admin, strtolower($wannaUseSession) === 'y');
$actions .= $this->bakeActions($controllerName, $admin);
}
$baked = false;
@@ -276,10 +271,9 @@ protected function _askAboutMethods() {
*
* @param string $controllerName Controller name
* @param string $admin Admin route to use
* @param boolean $wannaUseSession Set to true to use sessions, false otherwise
* @return string Baked actions
*/
public function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
public function bakeActions($controllerName, $admin = null) {
$currentModelName = $modelImport = $this->_modelName($controllerName);
$plugin = $this->plugin;
if ($plugin) {
@@ -302,7 +296,7 @@ public function bakeActions($controllerName, $admin = null, $wannaUseSession = t
$this->Template->set(compact(
'plugin', 'admin', 'controllerPath', 'pluralName', 'singularName',
'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName',
'singularHumanName', 'pluralHumanName', 'modelObj', 'currentModelName',
'displayField', 'primaryKey'
));
$actions = $this->Template->generate('actions', 'controller_actions');
@@ -51,14 +51,10 @@
if ($this->request->is('post')) {
$this-><?php echo $currentModelName; ?>->create();
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), ['action' => 'index']);
<?php endif; ?>
}
}
<?php
@@ -92,14 +88,10 @@
}
if ($this->request->is(['post', 'put'])) {
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), ['action' => 'index']);
<?php endif; ?>
}
} else {
$options = ['conditions' => ['<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id]];
@@ -136,16 +128,9 @@
}
$this->request->onlyAllow('post', 'delete');
if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'));
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
<?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'), ['action' => 'index']);
} else {
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'), ['action' => 'index']);
}
<?php endif; ?>
}

This file was deleted.

Oops, something went wrong.
@@ -1,7 +1,5 @@
<?php
/**
* ControllerTask Test Case
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -331,17 +329,6 @@ public function testBakeActionsUsingSessions() {
$this->assertContains('function admin_delete($id = null)', $result);
}
/**
* Test baking with Controller::flash() or no sessions.
*
* @return void
*/
public function testBakeActionsWithNoSessions() {
$result = $this->Task->bakeActions('BakeArticles', null, false);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsWithNoSessions.ctp');
$this->assertTextEquals($expected, $result);
}
/**
* test baking a test
*
@@ -1003,19 +1003,6 @@ public function testRender() {
$this->assertTrue(isset($View->viewVars['content_for_layout']), 'content_for_layout should be a view var');
$this->assertTrue(isset($View->viewVars['scripts_for_layout']), 'scripts_for_layout should be a view var');
$this->PostsController->set('url', 'flash');
$this->PostsController->set('message', 'yo what up');
$this->PostsController->set('pause', 3);
$this->PostsController->set('page_title', 'yo what up');
$View = new TestView($this->PostsController);
$result = $View->render(false, 'flash');
$this->assertRegExp("/<title>yo what up<\/title>/", $result);
$this->assertRegExp("/<p><a href=\"flash\">yo what up<\/a><\/p>/", $result);
$this->assertTrue($View->render(false, 'flash'));
$this->PostsController->helpers = array('Session', 'Cache', 'Html');
$this->PostsController->constructClasses();
$this->PostsController->cacheAction = array('index' => 3600);
@@ -1027,7 +1014,6 @@ public function testRender() {
$this->assertRegExp("/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\s*<title>/", $result);
$this->assertRegExp("/<div id=\"content\">\s*posts index\s*<\/div>/", $result);
$this->assertRegExp("/<div id=\"content\">\s*posts index\s*<\/div>/", $result);
}
/**

This file was deleted.

Oops, something went wrong.

0 comments on commit 236760a

Please sign in to comment.
You can’t perform that action at this time.