Skip to content

Commit

Permalink
[mms] Add Horde_Registry#hasLink() (Bug #13175).
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed May 14, 2014
1 parent b710754 commit 153f277
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
45 changes: 41 additions & 4 deletions framework/Core/lib/Horde/Registry.php
Expand Up @@ -1016,6 +1016,36 @@ public function hasInterface($interface)
* false if the method doesn't exist.
*/
public function hasMethod($method, $app = null)
{
return $this->_doHasSearch($method, $app, 'methods');
}

/**
* Determine if a link has been registered with the registry.
*
* @since 2.12.0
*
* @param string $method The full name of the link method to check for.
* @param string $app Only check this application.
*
* @return mixed The application implementing $method if we have it,
* false if the link method doesn't exist.
*/
public function hasLink($method, $app = null)
{
return $this->_doHasSearch($method, $app, 'links');
}

/**
* Do the has*() search.
*
* @see hasMethod
* @see hasLink
*
* @param string $func The API function to call to get the list of
* elements to search. Either 'methods' or 'links'.
*/
protected function _doHasSearch($method, $app, $func)
{
if (is_null($app)) {
if (($lookup = $this->_methodLookup($method)) === false) {
Expand All @@ -1026,11 +1056,18 @@ public function hasMethod($method, $app = null)
$call = $method;
}

$api_ob = $this->_loadApi($app);
if ($api_ob = $this->_loadApi($app)) {
switch ($func) {
case 'links':
$links = $api_ob->links();
return isset($links[$call]);

return ($api_ob && in_array($call, $api_ob->methods()))
? $app
: false;
case 'methods':
return in_array($call, $api_ob->methods());
}
}

return false;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions framework/Core/package.xml
Expand Up @@ -39,6 +39,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Add Horde_Registry#hasLink() (Bug #13175).
* [mjr] Fix returning mailbox list for ActiveSync clients when not using IMAP subscriptions (Bug #13177).
</notes>
<contents>
Expand Down Expand Up @@ -3392,6 +3393,7 @@
<date>2014-05-02</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Add Horde_Registry#hasLink() (Bug #13175).
* [mjr] Fix returning mailbox list for ActiveSync clients when not using IMAP subscriptions (Bug #13177).
</notes>
</release>
Expand Down

0 comments on commit 153f277

Please sign in to comment.