/**
  * @param array $parameters
  * @param Cache|null $typeDefinitionCache
  * @return CmisBindingInterface
  */
 public function createBinding(array $parameters, Cache $typeDefinitionCache = null)
 {
     if (count($parameters) === 0) {
         throw new CmisRuntimeException('Session parameters must be set!');
     }
     if (!isset($parameters[SessionParameter::BINDING_TYPE])) {
         throw new CmisRuntimeException('Required binding type is not configured!');
     }
     try {
         $bindingType = BindingType::cast($parameters[SessionParameter::BINDING_TYPE]);
         $bindingFactory = $this->getCmisBindingFactory();
         switch (true) {
             case $bindingType->equals(BindingType::BROWSER):
                 $binding = $bindingFactory->createCmisBrowserBinding($parameters, $typeDefinitionCache);
                 break;
             case $bindingType->equals(BindingType::ATOMPUB):
             case $bindingType->equals(BindingType::WEBSERVICES):
             case $bindingType->equals(BindingType::CUSTOM):
             default:
                 $binding = null;
         }
         if (!is_object($binding) || !$binding instanceof CmisBinding) {
             throw new CmisRuntimeException(sprintf('The given binding "%s" is not yet implemented.', $parameters[SessionParameter::BINDING_TYPE]));
         }
     } catch (InvalidEnumerationValueException $exception) {
         throw new CmisRuntimeException('Invalid binding type given: ' . $parameters[SessionParameter::BINDING_TYPE]);
     }
     return $binding;
 }
Пример #2
0
 /**
  * Returns the binding type.
  *
  * @return BindingType
  */
 public function getBindingType()
 {
     $bindingType = $this->session->get(SessionParameter::BINDING_TYPE);
     if (!is_string($bindingType)) {
         return BindingType::cast(BindingType::CUSTOM);
     }
     try {
         return BindingType::cast($bindingType);
     } catch (InvalidEnumerationValueException $exception) {
         return BindingType::cast(BindingType::CUSTOM);
     }
 }