hasInterface() public méthode

Determine if an interface is implemented by an active application.
public hasInterface ( string $interface ) : mixed
$interface string The interface to check for.
Résultat mixed The application implementing $interface if we have it, false if the interface is not implemented.
Exemple #1
0
 /**
  * Constructor.
  *
  * @param Horde_Registry $registry         A registry object.
  * @param Horde_Dav_Storage_Base $storage  A storage object.
  */
 public function __construct(Horde_Registry $registry, Horde_Dav_Storage_Base $storage)
 {
     $this->_registry = $registry;
     $this->_storage = $storage;
     foreach (array('calendar', 'tasks') as $interface) {
         try {
             $application = $this->_registry->hasInterface($interface);
             if ($application) {
                 $this->_interfaces[$interface] = $application;
             }
         } catch (Horde_Exception $e) {
         }
     }
 }
Exemple #2
0
 /**
  * Delete a folder.
  *
  * @param string $class  The EAS collection class.
  * @param string $id     The folder id
  *
  * @since 2.12.0
  */
 public function deleteFolder($class, $id)
 {
     switch ($class) {
         case Horde_ActiveSync::CLASS_TASKS:
             if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
                 throw new Horde_ActiveSync_Exception('Deleting addressbooks not supported by the contacts API.', Horde_ActiveSync_Exception::UNSUPPORTED);
             }
             $this->_registry->tasks->deleteTasklist($id);
             break;
         case Horde_ActiveSync::CLASS_CONTACTS:
             if (!$this->_registry->hasMethod('contacts/deleteAddressbook') || !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
                 throw new Horde_ActiveSync_Exception('Deleting addressbooks not supported by the contacts API.', Horde_ActiveSync_Exception::UNSUPPORTED);
             }
             $this->_registry->contacts->deleteAddressbook($id);
             break;
         case Horde_ActiveSync::CLASS_CALENDAR:
             if (!$this->_registry->hasMethod('calendar/deleteCalendar') || !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
                 throw new Horde_ActiveSync_Exception('Deleting calendars not supported by the calendar API.', Horde_ActiveSync_Exception::UNSUPPORTED);
             }
             $this->_registry->calendar->deleteCalendar($id);
             break;
         case Horde_ActiveSync::CLASS_NOTES:
             if (!$this->_registry->hasMethod('notes/deleteNotepad') || !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
                 throw new Horde_ActiveSync_Exception('Deleting notepads not supported by the notes API.', Horde_ActiveSync_Exception::UNSUPPORTED);
             }
             $this->_registry->notes->deleteNotepad($id);
             break;
     }
 }
Exemple #3
0
 /**
  * Returns the name of the application providing the 'contacts' interface.
  *
  * @return string  An application name.
  * @throws Sabre\DAV\Exception if no contacts application is installed.
  */
 protected function _contacts()
 {
     $contacts = $this->_registry->hasInterface('contacts');
     if (!$contacts) {
         throw new DAV\Exception('No contacts application installed');
     }
     return $contacts;
 }