Пример #1
0
 /**
  * Try to determined what object type the given objectData belongs to and return that type.
  *
  * @param ObjectDataInterface $objectData
  * @return ObjectTypeInterface|null The object type or <code>null</code> if type could not be determined
  */
 public function getTypeFromObjectData(ObjectDataInterface $objectData)
 {
     if ($objectData->getProperties() === null || count($objectData->getProperties()->getProperties()) === 0) {
         return null;
     }
     $typeProperty = $objectData->getProperties()->getProperties()[PropertyIds::OBJECT_TYPE_ID];
     if (!$typeProperty instanceof PropertyId) {
         return null;
     }
     return $this->session->getTypeDefinition($typeProperty->getFirstValue());
 }
Пример #2
0
 /**
  * Translates a TypeDefinition or string into a query name for
  * that TypeDefinition. Returns the input string as fallback if
  * the type could not be resolved. Input may contain an alias,
  * if so, we split and preserve the alias but attempt to translate
  * the type ID part.
  *
  * @param mixed $typeDefinitionMixed Input describing the type
  * @param string $autoAlias If alias is not provided
  * @return array
  */
 protected function getQueryNameAndAliasForType($typeDefinitionMixed, $autoAlias)
 {
     $alias = null;
     if (is_array($typeDefinitionMixed)) {
         list($typeDefinitionMixed, $alias) = $typeDefinitionMixed;
     }
     if ($typeDefinitionMixed instanceof TypeDefinitionInterface) {
         $queryName = $typeDefinitionMixed->getQueryName();
     } elseif (is_string($typeDefinitionMixed) && strpos($typeDefinitionMixed, ' ')) {
         list($typeDefinitionMixed, $alias) = explode(' ', $typeDefinitionMixed, 2);
     }
     try {
         $queryName = $this->session->getTypeDefinition($typeDefinitionMixed)->getQueryName();
     } catch (CmisObjectNotFoundException $error) {
         $queryName = $typeDefinitionMixed;
     }
     return array($queryName, $alias ? $alias : $autoAlias);
 }