Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param object $service
- * @param array $options
- * @param array $defaults
- */
- public static function setServiceOptions($service, $options, array $defaults = NULL, array $ignore = NULL)
- {
- $options = Nette\Utils\Arrays::mergeTree((array)$options, $defaults);
- // set options
- foreach ($options as $name => $val) {
- $method = 'set' . strtoupper($name[0]) . substr($name, 1);
- if (!method_exists($service, $method) && !in_array($ignore[$name])) {
- $e = new MemberAccessException("Call to undefined method " . get_class($service) . "::$method().");
- throw new Nette\InvalidArgumentException("Unknown option $name", NULL, $e);
- }
- $service->$method = $val;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment