Created
August 2, 2012 16:50
-
-
Save sugarknowledge/3238621 to your computer and use it in GitHub Desktop.
Module Loader Restriction Workarounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //require utils | |
| require_once("include/utils.php"); | |
| $check_path = "modules/Accounts/logic_hooks.php"; | |
| //if the $check_path exists in custom, $path will be returned as "custom/{$check_path}", otherwise $check_path will be returned | |
| $path = get_custom_file_if_exists("modules/Accounts/logic_hooks.php"); | |
| if ($check_path != $path) | |
| { | |
| //file exists in custom | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $check_path = "custom/modules/Accounts/logic_hooks.php"; | |
| if (file_exists($check_path)) | |
| { | |
| //file exists | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once('include/utils/sugar_file_utils.php'); | |
| $file = '/path/to/myFile.php'; | |
| $contents = sugar_file_get_contents($file); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $file = '/path/to/myFile.php'; | |
| if(is_readable($file)) | |
| { | |
| $contents = file_get_contents($file); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once('include/utils/sugar_file_utils.php'); | |
| $file = '/path/to/myFile.php'; | |
| if (sugar_file_get_contents($file) !== false) | |
| { | |
| //file is readable | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $file = '/path/to/myFile.php'; | |
| if(is_readable($file)) | |
| { | |
| //file is readable | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Adding a logic hook | |
| require_once("include/utils.php"); | |
| check_logic_hook_file("Accounts", "before_save", Array(999, 'Example Logic Hook', 'custom/modules/<module>/my_hook.php', 'my_hook_class', 'my_hook_function')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Removing a logic hook | |
| require_once("include/utils.php"); | |
| remove_logic_hook("Accounts", "before_save", Array(999, 'Example Logic Hook', 'custom/modules/<module>/my_hook.php', 'my_hook_class', 'my_hook_function')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $module = "Accounts"; | |
| $id = "6468238c-da75-fd9a-406b-50199fe6b5f8"; | |
| //creating a new bean | |
| $focus = BeanFactory::newBean($module); | |
| //or creating a new bean and retrieving a specific record | |
| $focus = BeanFactory::getBean($module, $id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $module = "Account"; | |
| $id = "6468238c-da75-fd9a-406b-50199fe6b5f8"; | |
| //creating a new bean | |
| $focus = new $module() | |
| //retrieving a specific record | |
| $focus->retrieve($id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment