Last active
December 15, 2015 07:59
-
-
Save polidog/5227909 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
App::uses('Shell', 'Console'); | |
/** | |
* Application Shell | |
* | |
* Add your application-wide methods in the class below, your shells | |
* will inherit them. | |
* | |
* @package app.Console.Command | |
*/ | |
class AppShell extends Shell { | |
public function loadModel($modelName) { | |
App::uses('ClassRegistry', 'Utility'); | |
$uses = array($modelName); | |
$modelClassName = $uses[0]; | |
if (strpos($uses[0], '.') !== false) { | |
list($plugin, $modelClassName) = explode('.', $uses[0]); | |
} | |
$this->modelClass = $modelClassName; | |
foreach ($uses as $modelClass) { | |
list($plugin, $modelClass) = pluginSplit($modelClass, true); | |
$this->{$modelClass} = ClassRegistry::init($plugin . $modelClass); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment