|
143 | 143 | --with-favorites Turn on Sugar Favorites generation. Will generate records in "sugarfavorites" table for modules |
144 | 144 | describes in config as \$sugarFavoritesModules, \$sugarFavoritesModules will be multiplied with |
145 | 145 | "load factor" (-l) argument |
| 146 | + --profile Name of file in folder config/profiles (without .php) or path to php-config-file with profile data. |
| 147 | + File can contain php-arrays |
| 148 | + - modules -- counts of beans to create |
| 149 | + - profile_opts -- redefines of settings listed here |
| 150 | + In case of setting profile (this setting) setting -l (load factor) will be ignored. |
146 | 151 |
|
147 | 152 | "Powered by SugarCRM" |
148 | 153 |
|
|
173 | 178 | 'as_last_rec:', |
174 | 179 | 'iterator:', |
175 | 180 | 'insert_batch_size:', |
| 181 | + 'profile:', |
176 | 182 | ) |
177 | 183 | ); |
178 | 184 |
|
|
192 | 198 |
|
193 | 199 | define('TIDBIT_DIR', __DIR__); |
194 | 200 | define('CONFIG_DIR', __DIR__ . '/config'); |
| 201 | +define('PROFILES_DIR', CONFIG_DIR . '/profiles'); |
195 | 202 | define('DATA_DIR', CONFIG_DIR . '/data'); |
196 | 203 | define('RELATIONSHIPS_DIR', CONFIG_DIR . '/relationships'); |
197 | 204 |
|
198 | | -require_once __DIR__ . '/vendor/autoload.php'; |
| 205 | +/* |
| 206 | + * if Tidbit is running independently, the dependencies are in the /vendor |
| 207 | + * directory, but if Tidbit is part of a larger composer managed system, the |
| 208 | + * dependencies are a couple directories higher. If neither are found, bail |
| 209 | + */ |
| 210 | +if (file_exists(__DIR__ . '/vendor/autoload.php')) { |
| 211 | + require_once __DIR__ . '/vendor/autoload.php'; |
| 212 | +} elseif (file_exists(__DIR__ . '../../autoload.php')) { |
| 213 | + require_once __DIR__ . '../../autoload.php'; |
| 214 | +} else { |
| 215 | + exitWithError('Unable to locate composer\'s autoload.php file'); |
| 216 | +} |
199 | 217 |
|
200 | 218 | // load general config |
201 | 219 | require_once CONFIG_DIR . '/config.php'; |
202 | 220 |
|
203 | 221 | set_exception_handler('uncaughtExceptionHandler'); |
204 | 222 |
|
| 223 | +if (isset($opts['profile'])) { |
| 224 | + if (is_file($opts['profile'])) { |
| 225 | + require_once $opts['profile']; |
| 226 | + } elseif (is_file(PROFILES_DIR . '/' . $opts['profile'] . '.php')) { |
| 227 | + require_once PROFILES_DIR . '/' . $opts['profile'] . '.php'; |
| 228 | + } else { |
| 229 | + exitWithError('Given profile ' . $opts['profile'] . ' does not exist'); |
| 230 | + } |
| 231 | + |
| 232 | + if (isset($profile_opts)) { |
| 233 | + $opts = array_merge($opts, $profile_opts); |
| 234 | + } |
| 235 | +} |
| 236 | + |
205 | 237 | if (isset($opts['sugar_path'])) { |
206 | 238 | $sugarPath = $opts['sugar_path']; |
207 | 239 | } |
|
292 | 324 | $moduleUsingGenerators = array('KBContents', 'Categories', 'SugarFavorites'); |
293 | 325 |
|
294 | 326 |
|
295 | | -if (isset($opts['l'])) { |
| 327 | +if (isset($opts['l']) && !isset($opts['profile'])) { |
296 | 328 | if (!is_numeric($opts['l'])) { |
297 | 329 | exitWithError($usageStr); |
298 | 330 | } |
|
301 | 333 | $modules[$m] *= $factor; |
302 | 334 | } |
303 | 335 |
|
304 | | - // Multiple favorites with $factor too |
| 336 | + // Multiple favorites with $factor too |
305 | 337 | if (isset($opts['with-favorites'])) { |
306 | 338 | foreach ($sugarFavoritesModules as $m => $n) { |
307 | 339 | $sugarFavoritesModules[$m] *= $factor; |
|
0 commit comments