Source for file ServiceLocator.php
Documentation is available at ServiceLocator.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see http://nettephp.com
- 12: *
- 18: */
- 28: /**
- 29: * Service locator pattern implementation.
- 30: *
- 34: */
- 36: {
- 48: /**
- 50: */
- 52: {
- 54: }
- 58: /**
- 59: * Adds the specified service to the service container.
- 65: */
- 67: {
- 70: }
- 75: }
- 79: throw new InvalidArgumentException("Service named '$name' is an instantiated object and must therefore be singleton without options.");
- 80: }
- 86: }
- 88: }
- 89: }
- 93: /**
- 94: * Removes the specified service type from the service container.
- 96: */
- 98: {
- 101: }
- 105: }
- 109: /**
- 110: * Gets the service object of the specified type.
- 114: */
- 116: {
- 119: }
- 125: throw new InvalidArgumentException("Service named '$name' is singleton and therefore can not have options.");
- 126: }
- 133: throw new InvalidArgumentException("Service named '$name' is singleton and therefore can not have options.");
- 137: }
- 142: throw new AmbiguousServiceException("Cannot instantiate service '$name', class '$factory' not found.");
- 143: }
- 147: }
- 153: throw new AmbiguousServiceException("Cannot instantiate service '$name', handler '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 154: }
- 158: throw new AmbiguousServiceException("Cannot instantiate service '$name', value returned by '$textual' is not object.");
- 159: }
- 160: }
- 165: }
- 167: }
- 174: }
- 175: }
- 179: /**
- 180: * Exists the service?
- 184: */
- 186: {
- 189: }
- 192: return isset($this->registry[$lower]) || (!$created && isset($this->factories[$lower])) || ($this->parent !== NULL && $this->parent->hasService($name, $created));
- 193: }
- 197: /**
- 198: * Returns the parent container if any.
- 200: */
- 202: {
- 204: }
- 206: }
- 210: /**
- 211: * Ambiguous service resolution exception.
- 212: *
- 216: */
- 218: {
- 219: }