|
@@ -36,15 +36,10 @@ class OrmCacheShell extends Shell {
|
|
|
* @return boolean
|
|
* @return boolean
|
|
|
*/
|
|
*/
|
|
|
public function build($name = null) {
|
|
public function build($name = null) {
|
|
|
- $source = ConnectionManager::get($this->params['connection']);
|
|
|
|
|
- if (!method_exists($source, 'schemaCollection')) {
|
|
|
|
|
- $msg = sprintf('The "%s" connection is not compatible with orm caching, ' .
|
|
|
|
|
- 'as it does not implement a "schemaCollection()" method.',
|
|
|
|
|
- $this->params['connection']);
|
|
|
|
|
- $this->error($msg);
|
|
|
|
|
|
|
+ $schema = $this->_getSchema();
|
|
|
|
|
+ if (!$schema) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- $schema = $source->schemaCollection();
|
|
|
|
|
if (!$schema->cacheMetadata()) {
|
|
if (!$schema->cacheMetadata()) {
|
|
|
$this->_io->verbose('Metadata cache was disabled in config. Enabling to write cache.');
|
|
$this->_io->verbose('Metadata cache was disabled in config. Enabling to write cache.');
|
|
|
$schema->cacheMetadata(true);
|
|
$schema->cacheMetadata(true);
|
|
@@ -64,11 +59,13 @@ class OrmCacheShell extends Shell {
|
|
|
* Clear metadata.
|
|
* Clear metadata.
|
|
|
*
|
|
*
|
|
|
* @param $name string
|
|
* @param $name string
|
|
|
- * @return void
|
|
|
|
|
|
|
+ * @return boolean
|
|
|
*/
|
|
*/
|
|
|
public function clear($name = null) {
|
|
public function clear($name = null) {
|
|
|
- $source = ConnectionManager::get($this->params['connection']);
|
|
|
|
|
- $schema = $source->schemaCollection();
|
|
|
|
|
|
|
+ $schema = $this->_getSchema();
|
|
|
|
|
+ if (!$schema) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
$tables = [$name];
|
|
$tables = [$name];
|
|
|
if (empty($name)) {
|
|
if (empty($name)) {
|
|
|
$tables = $schema->listTables();
|
|
$tables = $schema->listTables();
|
|
@@ -92,6 +89,23 @@ class OrmCacheShell extends Shell {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Helper method to get the schema collection.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return \Cake\Database\Schema\Collection
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function _getSchema() {
|
|
|
|
|
+ $source = ConnectionManager::get($this->params['connection']);
|
|
|
|
|
+ if (!method_exists($source, 'schemaCollection')) {
|
|
|
|
|
+ $msg = sprintf('The "%s" connection is not compatible with orm caching, ' .
|
|
|
|
|
+ 'as it does not implement a "schemaCollection()" method.',
|
|
|
|
|
+ $this->params['connection']);
|
|
|
|
|
+ $this->error($msg);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $source->schemaCollection();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
* Get the option parser for this shell.
|
|
* Get the option parser for this shell.
|
|
|
*
|
|
*
|
|
|
* @return \Cake\Console\ConsoleOptionParser
|
|
* @return \Cake\Console\ConsoleOptionParser
|