Ejemplo n.º 1
0
 /**
  * Returns the first value of a property or <code>null</code> if the
  * property is not set.
  *
  * @param string $id
  * @return mixed
  */
 private function getFirstValue($id)
 {
     if ($this->properties === null) {
         return null;
     }
     $properties = $this->properties->getProperties();
     if (isset($properties[$id])) {
         return $properties[$id]->getFirstValue();
     }
     return null;
 }
 /**
  * Handle initialization of properties from the object data
  *
  * @param PropertiesInterface $properties
  */
 private function initializeObjectDataProperties(PropertiesInterface $properties)
 {
     // get secondary types
     $propertyList = $properties->getProperties();
     if (isset($propertyList[PropertyIds::SECONDARY_OBJECT_TYPE_IDS])) {
         $this->secondaryTypes = array();
         foreach ($propertyList[PropertyIds::SECONDARY_OBJECT_TYPE_IDS]->getValues() as $secondaryTypeId) {
             $type = $this->getSession()->getTypeDefinition($secondaryTypeId);
             if ($type instanceof SecondaryTypeInterface) {
                 $this->secondaryTypes[] = $type;
             }
         }
     }
     $this->properties = $this->getObjectFactory()->convertPropertiesDataToPropertyList($this->getObjectType(), (array) $this->getSecondaryTypes(), $properties);
     $this->extensions[(string) ExtensionLevel::cast(ExtensionLevel::PROPERTIES)] = $properties->getExtensions();
 }
Ejemplo n.º 3
0
 /**
  * @param PropertiesInterface $properties
  * @return PropertyDataInterface[]
  */
 public function convertQueryProperties(PropertiesInterface $properties)
 {
     return $properties->getProperties();
 }
 /**
  * Converts a Properties list into an array that can be used for the CMIS request.
  *
  * @param PropertiesInterface $properties
  * @return array Example <code>
  * array('propertyId' => array(0 => 'myId'), 'propertyValue' => array(0 => 'valueOfMyId'))
  * </code>
  */
 protected function convertPropertiesToQueryArray(PropertiesInterface $properties)
 {
     $propertiesArray = array();
     $propertyCounter = 0;
     $propertiesArray[Constants::CONTROL_PROP_ID] = array();
     $propertiesArray[Constants::CONTROL_PROP_VALUE] = array();
     foreach ($properties->getProperties() as $property) {
         $propertiesArray[Constants::CONTROL_PROP_ID][$propertyCounter] = $property->getId();
         $propertyValues = $property->getValues();
         if (count($propertyValues) === 1) {
             $propertiesArray[Constants::CONTROL_PROP_VALUE][$propertyCounter] = $this->convertPropertyValueToSimpleType($property->getFirstValue());
         } elseif (count($propertyValues) > 1) {
             $propertyValueCounter = 0;
             $propertiesArray[Constants::CONTROL_PROP_VALUE][$propertyCounter] = array();
             foreach ($propertyValues as $propertyValue) {
                 $propertiesArray[Constants::CONTROL_PROP_VALUE][$propertyCounter][$propertyValueCounter] = $this->convertPropertyValueToSimpleType($propertyValue);
                 $propertyValueCounter++;
             }
         }
         $propertyCounter++;
     }
     return $propertiesArray;
 }