/** * Initialize the CMIS Object * * @param SessionInterface $session * @param ObjectTypeInterface $objectType * @param OperationContextInterface $context * @param ObjectDataInterface|null $objectData */ public function initialize(SessionInterface $session, ObjectTypeInterface $objectType, OperationContextInterface $context, ObjectDataInterface $objectData = null) { if (count($this->getMissingBaseProperties($objectType->getPropertyDefinitions())) !== 0) { throw new CmisInvalidArgumentException(sprintf('Object type must have at least the base property definitions! ' . 'These property definitions are missing: %s', implode(', ', PropertyIds::getBasePropertyKeys()))); } $this->session = $session; $this->objectType = $objectType; $this->secondaryTypes = null; $this->creationContext = clone $context; $this->refreshTimestamp = (int) round(microtime(true) * 1000); if ($objectData !== null) { $this->initializeObjectData($objectData); } }
/** * Convert PropertyData into a property API object * * @param ObjectTypeInterface $objectType * @param SecondaryTypeInterface[] $secondaryTypes * @param PropertyDataInterface $propertyData * @return PropertyInterface * @throws CmisRuntimeException */ protected function convertProperty(ObjectTypeInterface $objectType, array $secondaryTypes, PropertyDataInterface $propertyData) { $definition = $objectType->getPropertyDefinition($propertyData->getId()); // search secondary types if ($definition === null && !empty($secondaryTypes)) { foreach ($secondaryTypes as $secondaryType) { $propertyDefinitions = $secondaryType->getPropertyDefinitions(); if (!empty($propertyDefinitions)) { $definition = $secondaryType->getPropertyDefinition($propertyData->getId()); if ($definition !== null) { break; } } } } // the type might have changed -> reload type definitions if ($definition === null) { $reloadedObjectType = $this->session->getTypeDefinition($objectType->getId(), false); $definition = $reloadedObjectType->getPropertyDefinition($propertyData->getId()); if ($definition === null && !empty($secondaryTypes)) { foreach ($secondaryTypes as $secondaryType) { $reloadedSecondaryType = $this->session->getTypeDefinition($secondaryType->getId(), false); $propertyDefinitions = $reloadedSecondaryType->getPropertyDefinitions(); if (!empty($propertyDefinitions)) { $definition = $reloadedSecondaryType->getPropertyDefinition($propertyData->getId()); if ($definition !== null) { break; } } } } } if ($definition === null) { // property without definition throw new CmisRuntimeException(sprintf('Property "%s" doesn\'t exist!', $propertyData->getId())); } return $this->createProperty($definition, $propertyData->getValues()); }
/** * Sets the designated parameter to the query name of the given type. * * @param integer $parameterIndex the parameter index (one-based) * @param ObjectTypeInterface $type the object type */ public function setType($parameterIndex, ObjectTypeInterface $type) { $this->setParameter($parameterIndex, $this->escape($type->getQueryName())); }
/** * Fetches the relationships from or to an object from the repository. * * @param ObjectIdInterface $objectId * @param boolean $includeSubRelationshipTypes * @param RelationshipDirection $relationshipDirection * @param ObjectTypeInterface $type * @param OperationContextInterface|null $context * @return RelationshipInterface[] */ public function getRelationships(ObjectIdInterface $objectId, $includeSubRelationshipTypes, RelationshipDirection $relationshipDirection, ObjectTypeInterface $type, OperationContextInterface $context = null) { if ($context === null) { $context = $this->getDefaultContext(); } // TODO: Implement cache! return $this->getBinding()->getRelationshipService()->getObjectRelationships($this->getRepositoryId(), $objectId->getId(), $includeSubRelationshipTypes, $relationshipDirection, $type->getId()); }