From 233edd61106ae4d40257090381a00a7859c13ebd Mon Sep 17 00:00:00 2001 From: Amal Sharma Date: Tue, 19 Dec 2017 16:14:32 +0530 Subject: [PATCH] Make provision to skip fields when generating Views --- scripts/Phalcon/Builder/Scaffold.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/Phalcon/Builder/Scaffold.php b/scripts/Phalcon/Builder/Scaffold.php index 25e94cc5b..500893e40 100644 --- a/scripts/Phalcon/Builder/Scaffold.php +++ b/scripts/Phalcon/Builder/Scaffold.php @@ -35,6 +35,8 @@ */ class Scaffold extends Component { + private $fieldsToSkip = array(); + /** * @param string $fieldName * @@ -91,6 +93,9 @@ public function build() $name = $this->options->get('name'); $config = $this->getConfig(); + if (isset($config->application->fieldsToSkip)) { + $this->fieldsToSkip = array_map('trim', explode(",", $config->application->fieldsToSkip)); + } if (empty($config->path('database.adapter'))) { throw new BuilderException('Adapter was not found in the config. Please specify a config variable [database][adapter].'); } @@ -426,6 +431,8 @@ private function _makeFields($action) $code = ''; foreach ($this->options->get('dataTypes') as $attribute => $dataType) { + if (in_array($attribute, $this->fieldsToSkip)) + continue; if (($action == 'new' || $action == 'edit') && $attribute == $identityField) { continue; } @@ -451,6 +458,8 @@ private function _makeFieldsVolt($action) $code = ''; foreach ($this->options->get('dataTypes') as $attribute => $dataType) { + if (in_array($attribute, $this->fieldsToSkip)) + continue; if (($action == 'new' || $action == 'edit') && $attribute == $identityField) { continue; } @@ -718,12 +727,16 @@ private function _makeViewSearch() $headerCode = ''; foreach ($this->options->get('attributes') as $attribute) { + if (in_array($attribute, $this->fieldsToSkip)) + continue; $headerCode .= "\t\t\t" . '' . $this->_getPossibleLabel($attribute) . '' . PHP_EOL; } $rowCode = ''; $this->options->offsetSet('allReferences', array_merge($this->options->get('autocompleteFields')->toArray(), $this->options->get('selectDefinition')->toArray())); foreach ($this->options->get('dataTypes') as $fieldName => $dataType) { + if (in_array($fieldName, $this->fieldsToSkip)) + continue; $rowCode .= "\t\t\t" . 'options->get('allReferences')[$fieldName])) { if ($this->options->get('genSettersGetters')) { @@ -783,12 +796,16 @@ private function _makeViewSearchVolt() $headerCode = ''; foreach ($this->options->get('attributes') as $attribute) { + if (in_array($attribute, $this->fieldsToSkip)) + continue; $headerCode .= "\t\t\t" . '' . $this->_getPossibleLabel($attribute) . '' . PHP_EOL; } $rowCode = ''; $this->options->offsetSet('allReferences', array_merge($this->options->get('autocompleteFields')->toArray(), $this->options->get('selectDefinition')->toArray())); foreach ($this->options->get('dataTypes') as $fieldName => $dataType) { + if (in_array($fieldName, $this->fieldsToSkip)) + continue; $rowCode .= "\t\t\t" . '{{ '; if (!isset($this->options->get('allReferences')[$fieldName])) { if ($this->options->contains('genSettersGetters')) {