Last active
December 19, 2015 22:09
-
-
Save oojacoboo/6025775 to your computer and use it in GitHub Desktop.
Example of a class using custom named method to replace string params
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 | |
| namespace WidgetFactory\Modules; | |
| class MyModule extends MyORM | |
| { | |
| /** | |
| * Shared method to get the option value from the db | |
| * @param string $option | |
| * @return mixed | |
| */ | |
| public function getOption($option) { | |
| return $this->query("SELECT `value` FROM `module_option` WHERE `name` = ?", array($option)); | |
| } | |
| /** | |
| * Update the option value | |
| * @param string $option | |
| * @param mixed $value | |
| * @return mixed | |
| */ | |
| public function setOption($option, $value) { | |
| return $this->query("UPDATE `module_option` SET `value` = ? WHERE `name` = ?", array($value, $option)); | |
| } | |
| /** | |
| * Should we send emails with this module? | |
| * @return mixed | |
| */ | |
| public function getOptionSendEmails() { | |
| return $this->getOption("sendEmails"); | |
| } | |
| /** | |
| * Is sharing to social networks enabled by default? | |
| * @return mixed | |
| */ | |
| public function getOptionShareByDefault() { | |
| return $this->getOption("shareByDefault"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment