You're after the ParserFactory class, which can be used from a post_install or similar script executed as your module/package is installed. My understanding is that ParserFactory will call custom files if they're there, or stock files and adjust them appropriately and safely if not.
In your module's directory, create a subdirectory called 'scripts' and create 'post_install.php' which contains a single function post_install(). Your package dir will look something like this:
~$ find .
/LICENSE.txt
/manifest.php
/scripts/post_install.php
You use the ParserFactory like this:
<?php
function post_install(){
// $parser becomes an associative array for the metadata, similar to editviewdefs.php
require_once('modules/ModuleBuilder/parsers/ParserFactory.php');
$parser = ParserFactory::getParser('detailview', 'Accounts');
// finding the panels (which contain their fields), you can
// now add fields or additional arrays to this array, creating new panels
// (you could manipulate $parser->_viewdefs directly, but I find this easier)
$panels = array_keys ( $parser->_viewdefs [ 'panels' ] );
// place your panels back into the $parser and save
$parser->_viewdefs['panels'] = $panels;
$parser->handleSave(false);
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…