Advanced property handling

@param array $propertyValues
517453
protected function saveAdvProperty($propertyValues)
    {
        // might break using hard
        $range = array();
        foreach($propertyValues as $key => $value){
            if(is_array($value)){
                // set the range
                foreach($value as $v){
                    $range[] = $this->getClass(tao_helpers_Uri::decode($v));
                }
            }
            else{
                $values[tao_helpers_Uri::decode($key)] = tao_helpers_Uri::decode($value);
            }

        }
        //if label is empty
        $validator = new tao_helpers_form_validators_NotEmpty(array('message' => __('Property\'s label field is required')));
        if(!$validator->evaluate($values[OntologyRdfs::RDFS_LABEL])){
            throw new Exception($validator->getMessage());
        }

        $property = $this->getProperty($values['uri']);
        unset($values['uri']);
        $property->removePropertyValues($this->getProperty(OntologyRdfs::RDFS_RANGE));
        if(!empty($range)){
            foreach($range as $r){
                $property->setRange($r);
            }
        }
        $this->bindProperties($property, $values);
    }
956661
public function renderSimple(array $values, array $propertyNames)
    {
        $data = [];
        foreach ($propertyNames as $key => $label) {
            $data[] = [$label, $values[$key]];
        }
        $this->render($data, ['Property', 'Value']);
    }
91757
public function setProperty($propertyName, $propertyValue)
    {
        if ($propertyName == '')
            throw new Exception('Property Name not specified');

        if ($propertyValue == '')
            throw new Exception('Property Value not specified');

        //build URI 
        $strURI = Product::$baseProductUri . '/email/' . $this->getFileName() . '/properties/' . $propertyName;

        $put_data_arr['Value'] = $propertyValue;

        $put_data = json_encode($put_data_arr);

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $put_data);

        $json = json_decode($responseStream);

        if ($json->Code == 200)
            return $json->EmailProperty->Value;
        else
            return false;
    }
1243862
private function bindValues(array $values)
    {
        $this->bindedParameters = array();
        $this->bindedTypes = array();
        $this->bindedValues = array();

        foreach ($values as $parameter => $value) {
            if (is_int($parameter)) {
                $parameter++;
            }

            $this->bindValue($parameter, $value);
        }
    }
230142
protected function convertColumnsToProperties(array $databaseValues)
    {
        $propertyValues = [];
        $propertyMap = $this->getPropertyMap();

        foreach ($databaseValues as $columnName => $value) {
            $conversionFunction = $propertyMap[$columnName]['cast'];

            $propertyValues[$propertyMap[$columnName]['name']] = $conversionFunction($value);
        }

        return $propertyValues;
    }
192804
public static function createApplicationComponentFromPostValues($postValues)
    {
        if (isset($postValues['title'], $postValues['component'])) {
            $applicationComponent = new \stdClass();
            $applicationComponent->title = $postValues['title'];
            $applicationComponent->slug = StringUtil::slugify($postValues['title']);
            $applicationComponent->component = $postValues['component'];
            $applicationComponent->parameters = new \stdClass();
            if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
                foreach ($postValues['parameterNames'] as $key => $value) {
                    $applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
                }
            }

            return $applicationComponent;
        } else {
            throw new \Exception('Trying to create application component with invalid data.');
        }
    }
821768
function setValue($values) {
        $values = (array)$values;
        foreach ($values as $name=>$value) {
            if (array_key_exists($name, $this->_values)) {
                $this->_values[$name] = $value;
            }
        }
    }
359779
private static function fillForFrontend($propertyRows, $property)
    {
        $carry = '';
        $column = static::dataTypeToEavColumn($property->data_type);
        foreach ($propertyRows as $row) {
            $value = Property::castValueToDataType($row[$column], $property->data_type);
            if ($property->allow_multiple_values === false) {
                if (true === empty($carry)) {
                    $carry = $value;
                }
                continue;
            }
            $carry[] = $value;
        }
        return $carry;
    }
536890
public function setFieldsWithValues(array $fieldsValues)
    {
        $this->supports = [];
        $this->values = [];

        foreach ($fieldsValues as $field => $value) {
            if (is_int($field)) {
                $field = $value;
                $value = null;
            }

            $this->supports[ ] = $field;
            if (!is_null($value)) {
                $this->values[ $field ] = $value;
            }
        }

        return $this;
    }
262545
public function onChange(array $previousValues)
    {
       if (isset($this->defaultCallback)) {
           $callback = $this->defaultCallback;
           $this->default = $callback($previousValues);
       }
    }
1030659
public static function setDataTypes(array $types) : void
    {
        // Datatypes key validation
        foreach ($types as $key => $value) {
            if (!preg_match('/^[A-Za-z0-9-_]+$/', $key)) {
                throw new \UnexpectedValueException("<b>$key</b> is not a valid datatype key", 1);

            } elseif (!is_string($value)) {
                throw new \LogicException("<b>$key</b> must have a string value", 1);
            }
        }

        // Put keys between brackets
        self::$datatypes = array_combine(
            array_map(function ($t) {
                return '/\{' . $t . '\}/';
            }, array_keys($types)),
            $types
        );
    }
850937
public function setProperties(array $properties)
	{
		foreach($properties as $key=>$value)
			$this->parseProperty($key, $value);

		return $this;
	}
1349309
public function fromRaw($properties)
	{
		$this->validateProperties($properties);

		foreach ($properties as $property => $value) {
			$this->properties[$property] = $value;
		}
	}
182669
public function _delete(...$keyValues) {
		$instance = DAO::getOne ( $this->model, $keyValues, false );
		$this->operate_ ( $instance, function ($instance) {
			return DAO::remove ( $instance );
		}, "deleted", "Unable to delete the instance", $keyValues );
	}
621271
public function setRawProperties( $properties )
    {
        if ( ! empty( $properties ) )
        {
            foreach ( $properties as $name => $value )
            {
                switch ( true )
                {
                    case is_array( $value ) &&
                            array_key_exists( 'value', $value ):
                        $value = (object) $value;

                    case is_object( $value ):
                        if ( ! isset( $value->value ) )
                        {
                            $value->value = null;
                        }

                        if ( ! isset( $value->priority ) )
                        {
                            $value->priority = null;
                        }

                        if ( ! isset( $value->name ) )
                        {
                            $value->name = $name;
                        }

                        $this->setRawProperty(
                            $value->name,
                            $value->value,
                            $value->priority
                        );
                        break;

                    case is_array( $value ):
                        if ( count( $value ) > 2 )
                        {
                            list( $rawName, $value, $priority ) = $value;

                            if ( empty( $rawName ) )
                            {
                                $rawName = $name;
                            }
                        }
                        else if ( count( $value ) > 1 )
                        {
                            $rawName = $name;
                            list( $value, $priority ) = $value;
                        }
                        else
                        {
                            $rawName    = $name;
                            $priority   = null;
                            $value      = empty( $value ) ? null : current( $value );
                        }

                        $this->setRawProperty( $rawName, $value, $priority );
                        break;

                    default:
                        $this->setRawProperty( $name, $value );
                        break;
                }
            }
        }

        return $this;
    }
830570
public function alterFormValues(array $formValues)
    {
        foreach ($this->getMeta() as $key => $fieldMeta) {
            /** @var \stdClass $fieldMeta */
            if ($fieldMeta->type === 'checkbox') {
                if (!empty($formValues[$key])) {
                    // Check for empty() as the collection name may have
                    // been initialized with an empty string.
                    if (empty($formValues[$fieldMeta->collection])) {
                        $formValues[$fieldMeta->collection] = array();
                    }
                    $formValues[$fieldMeta->collection][] = $key;
                }
            }
        }
        return $formValues;
    }
1063149
public function data_preprocessing(&$defaultvalues) {
        parent::data_preprocessing($defaultvalues);
        $defaultvalues['completionentriesenabled'] = !empty($defaultvalues['completionentries']) ? 1 : 0;
        if (empty($defaultvalues['completionentries'])) {
            $defaultvalues['completionentries'] = 1;
        }
    }