Skip to content

Instantly share code, notes, and snippets.

@polidog
Last active December 15, 2015 07:59
Show Gist options
  • Save polidog/5227909 to your computer and use it in GitHub Desktop.
Save polidog/5227909 to your computer and use it in GitHub Desktop.
<?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