|
@@ 67-74 (lines=8) @@
|
| 64 |
|
* @param string $prefix Virtual path |
| 65 |
|
* @param VirtualRESTService $instance |
| 66 |
|
*/ |
| 67 |
|
public function mount( $prefix, VirtualRESTService $instance ) { |
| 68 |
|
if ( !preg_match( self::VALID_MOUNT_REGEX, $prefix ) ) { |
| 69 |
|
throw new UnexpectedValueException( "Invalid service mount point '$prefix'." ); |
| 70 |
|
} elseif ( isset( $this->instances[$prefix] ) ) { |
| 71 |
|
throw new UnexpectedValueException( "A service is already mounted on '$prefix'." ); |
| 72 |
|
} |
| 73 |
|
$this->instances[$prefix] = $instance; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
/** |
| 77 |
|
* Unmap a prefix to service handler |
|
@@ 81-88 (lines=8) @@
|
| 78 |
|
* |
| 79 |
|
* @param string $prefix Virtual path |
| 80 |
|
*/ |
| 81 |
|
public function unmount( $prefix ) { |
| 82 |
|
if ( !preg_match( self::VALID_MOUNT_REGEX, $prefix ) ) { |
| 83 |
|
throw new UnexpectedValueException( "Invalid service mount point '$prefix'." ); |
| 84 |
|
} elseif ( !isset( $this->instances[$prefix] ) ) { |
| 85 |
|
throw new UnexpectedValueException( "No service is mounted on '$prefix'." ); |
| 86 |
|
} |
| 87 |
|
unset( $this->instances[$prefix] ); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
/** |
| 91 |
|
* Get the prefix and service that a virtual path is serviced by |