From 87429f2c52d9e1dac26854082b9a6d4720244804 Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Mon, 27 Apr 2015 19:16:54 +0200 Subject: [PATCH 1/2] skip empty tvs --- src/Command/ExtractCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Command/ExtractCommand.php b/src/Command/ExtractCommand.php index 1432af5..216f36a 100644 --- a/src/Command/ExtractCommand.php +++ b/src/Command/ExtractCommand.php @@ -370,6 +370,7 @@ protected function objectToArray(\xPDOObject $object) $templateVars = $object->getTemplateVars(); foreach ($templateVars as $tv) { /** @var \modTemplateVar $tv */ + if (empty($tv->get('value'))) continue; $tvs[$tv->get('name')] = $tv->get('value'); } ksort($tvs); From 410f5e9df1596710851f9e6985e311c079ca76d7 Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Mon, 27 Apr 2015 20:20:39 +0200 Subject: [PATCH 2/2] update check to use default tv value --- src/Command/ExtractCommand.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Command/ExtractCommand.php b/src/Command/ExtractCommand.php index 216f36a..4064300 100644 --- a/src/Command/ExtractCommand.php +++ b/src/Command/ExtractCommand.php @@ -20,6 +20,7 @@ class ExtractCommand extends BaseCommand protected $_useResource = null; protected $_resource = false; + protected $_defaultTVValues = array(); protected function configure() { @@ -370,11 +371,16 @@ protected function objectToArray(\xPDOObject $object) $templateVars = $object->getTemplateVars(); foreach ($templateVars as $tv) { /** @var \modTemplateVar $tv */ - if (empty($tv->get('value'))) continue; + if(!isset($this->_defaultTVValues[$tv->get('id')])) { + // get default TV value + $tvObject = $this->modx->getObject('modTemplateVar', $tv->get('id')); + $this->_defaultTVValues[$tv->get('id')] = $tvObject->get('default_text'); + } + if ($tv->get('value') === $this->_defaultTVValues[$tv->get('id')]) continue; $tvs[$tv->get('name')] = $tv->get('value'); } ksort($tvs); - $data['tvs'] = $tvs; + if(!empty($tvs)) $data['tvs'] = $tvs;; break; // Handle string-based categories automagically on elements