Browse Source

Remove unused methods.

These methods are not used outside of their tests and have no reason to
stick around anymore.
mark_story 12 years ago
parent
commit
4e29066129

+ 0 - 69
src/Console/Command/Task/ProjectTask.php

@@ -139,75 +139,6 @@ class ProjectTask extends BakeTask {
 	}
 
 /**
- * Enables Configure::read('Routing.prefixes') in /app/Config/routes.php
- *
- * @param string $name Name to use as admin routing
- * @return bool Success
- */
-	public function cakeAdmin($name) {
-		$path = $this->appPath ?: APP;
-		$path .= 'Config/';
-		$File = new File($path . 'routes.php');
-		$contents = $File->read();
-		if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(\]\[]*\);)%', $contents, $match)) {
-			$result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', [\'' . $name . '\']);', $contents);
-			if ($File->write($result)) {
-				Configure::write('Routing.prefixes', [$name]);
-				return true;
-			}
-		}
-		return false;
-	}
-
-/**
- * Checks for Configure::read('Routing.prefixes') and forces user to input it if not enabled
- *
- * @return string Admin route to use
- */
-	public function getPrefix() {
-		$admin = '';
-		$prefixes = Configure::read('Routing.prefixes');
-		if (!empty($prefixes)) {
-			if (count($prefixes) === 1) {
-				return $prefixes[0] . '_';
-			}
-			if ($this->interactive) {
-				$this->out();
-				$this->out(__d('cake_console', 'You have more than one routing prefix configured'));
-			}
-			$options = [];
-			foreach ($prefixes as $i => $prefix) {
-				$options[] = $i + 1;
-				if ($this->interactive) {
-					$this->out($i + 1 . '. ' . $prefix);
-				}
-			}
-			$selection = $this->in(__d('cake_console', 'Please choose a prefix to bake with.'), $options, 1);
-			return $prefixes[$selection - 1] . '_';
-		}
-		if ($this->interactive) {
-			$this->hr();
-			$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
-					'Configure::write(\'Routing.prefixes\', [\'admin\'])',
-					'/app/Config/routes.php'));
-			$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
-			$this->out(__d('cake_console', 'Example: %s', 'www.example.com/admin/controller'));
-			while (!$admin) {
-				$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
-			}
-			if ($this->cakeAdmin($admin) !== true) {
-				$this->out(__d('cake_console', '<error>Unable to write to</error> %s.', '/app/Config/routes.php'));
-				$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
-					'Configure::write(\'Routing.prefixes\', [\'admin\'])',
-					'/app/Config/routes.php'));
-				return $this->_stop();
-			}
-			return $admin . '_';
-		}
-		return '';
-	}
-
-/**
  * get the option parser.
  *
  * @return \Cake\Console\ConsoleOptionParser

+ 0 - 51
tests/TestCase/Console/Command/Task/ProjectTaskTest.php

@@ -96,55 +96,4 @@ class ProjectTaskTest extends TestCase {
 		$File->write($contents);
 	}
 
-/**
- * test getPrefix method, and that it returns Routing.prefix or writes to config file.
- *
- * @return void
- */
-	public function testGetPrefix() {
-		Configure::write('Routing.prefixes', array('admin'));
-		$result = $this->Task->getPrefix();
-		$this->assertEquals('admin_', $result);
-
-		$this->_cloneRoutes();
-
-		Configure::write('Routing.prefixes', null);
-		$this->Task->appPath = TMP . 'BakeTestApp/';
-		Configure::write('Routing.prefixes', null);
-
-		$this->Task->expects($this->once())->method('in')->will($this->returnValue('super_duper_admin'));
-
-		$result = $this->Task->getPrefix();
-		$this->assertEquals('super_duper_admin_', $result);
-	}
-
-/**
- * test cakeAdmin() writing routes.php
- *
- * @return void
- */
-	public function testCakeAdmin() {
-		$this->_cloneRoutes();
-
-		Configure::write('Routing.prefixes', null);
-		$this->Task->appPath = TMP . 'BakeTestApp/';
-		$result = $this->Task->cakeAdmin('my_prefix');
-		$this->assertTrue($result);
-
-		$this->assertEquals(Configure::read('Routing.prefixes'), array('my_prefix'));
-	}
-
-/**
- * test getting the prefix with more than one prefix setup
- *
- * @return void
- */
-	public function testGetPrefixWithMultiplePrefixes() {
-		Configure::write('Routing.prefixes', array('admin', 'ninja', 'shinobi'));
-		$this->Task->appPath = $this->Task->path . 'BakeTestApp/';
-		$this->Task->expects($this->once())->method('in')->will($this->returnValue(2));
-
-		$result = $this->Task->getPrefix();
-		$this->assertEquals('ninja_', $result);
-	}
 }