Convert an association to KV form.

@return string $result String in KV form suitable for
deserialization by deserialize.
420244
function serialize()
    {
        $data = array(
                     'version' => '2',
                     'handle' => $this->handle,
                     'secret' => base64_encode($this->secret),
                     'issued' => strval(intval($this->issued)),
                     'lifetime' => strval(intval($this->lifetime)),
                     'assoc_type' => $this->assoc_type
                     );

        assert(array_keys($data) == $this->assoc_keys);

        return Auth_OpenID_KVForm::fromArray($data);
    }
659013
public function mergeAttr()
    {
        $arrays = func_get_args();
        $result = array();

        foreach ($arrays as $array) {
            $result = $this->mergeRecursive($result, $array);
        }

        return $result;
    }
606732
public function ItemEditForm() {
        $form=parent::ItemEditForm();
        
        if($form) {
            if($this->record && $this->record->exists()) {
                $kapostBase=KapostAdmin::config()->kapost_base_url;
                if($kapostBase[strlen($kapostBase)-1]!='/') {
                    $kapostBase.='/';
                }
                
                $form->Fields()->addFieldToTab('Root.Main', $field=ReadonlyField::create(
                                                                    'KapostRefID_linked',
                                                                    $this->record->fieldLabel('KapostRefID'),
                                                                    (!empty($kapostBase) ? '<a href="'.htmlentities($kapostBase.'posts/'.$this->record->KapostRefID).'" target="_blank">'.htmlentities($this->record->KapostRefID).'</a>':$this->record->KapostRefID)
                                                                )->setForm($form));
                $field->dontEscape=true;
                
                
                $form->Actions()->insertBefore(
                                                FormAction::create('doConvertPost', _t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'))
                                                    ->setUseButtonTag(true)
                                                    ->addExtraClass('ss-ui-action-constructive kapost-action-convert')
                                                    ->setAttribute('data-icon', 'kapost-convert')
                                                    ->setForm($form)
                                            , 'action_doDelete');
            }
            
            
            $form->addExtraClass('KapostAdmin');
        }
        
        return $form;
    }
220747
public function toArray()
    {
        $return = array();
        foreach ($this->_attribs as $key => $value) {
            $return[$key] = $value;
        }

        if ($this->_value instanceof CanConvertToArray) {
            $return = array_merge($return, $this->_value->toArray());
        } else {
            $return[$this->_name] = $this->_value;
        }

        return $return;
    }
194744
public function HolderAttributes() {
		$ret = "";
		foreach($this->holderAttributes as $k => $v) {
			$ret .= "$k=\"".Convert::raw2att($v)."\" ";
		}
		return $ret;
	}
66221
public function toArray()
	{
		$result = parent::toArray();

		if (isset($result['suspended']))
		{
			$result['suspended'] = $this->getSuspendedAttribute($result['suspended']);
		}
		if (isset($result['banned']))
		{
			$result['banned'] = $this->getBannedAttribute($result['banned']);
		}
		if (isset($result['last_attempt_at']) and $result['last_attempt_at'] instanceof DateTime)
		{
			$result['last_attempt_at'] = $result['last_attempt_at']->format('Y-m-d H:i:s');
		}
		if (isset($result['suspended_at']) and $result['suspended_at'] instanceof DateTime)
		{
			$result['suspended_at'] = $result['suspended_at']->format('Y-m-d H:i:s');
		}

		return $result;
	}
1040161
public static function toAssociative($array, $recursive = false) {
        $associative = new AssociativeArray();

        foreach($array as $key => $value) {
            if ($recursive && is_array($value)) {
                $associative[$key] = self::toAssociative($value, true);
            } else {
                $associative[$key] = $value;
            }
        }

        return $associative;

    }
243590
public function toArray() {
        $data = parent::toArray();
        foreach (array('_related', '_virtual') as $prop) {
            foreach ($this->{$prop} as $key => $val) {
                if ($val instanceof Zend_Db_Table_Row_Abstract
                    || $val instanceof Zend_Db_Table_Rowset_Abstract
                ) {
                    $data[$key] = $val->toArray();
                } else {
                    $data[$key] = $val;
                }
            }
        }
        return $data;
    }
968589
public function to_array()
    {
        debug_message('entering function '.__FUNCTION__.' in '.__CLASS__);
        //lomdata
        $lomdata = array(
            'general' => array(
                'identifier' => array(
                    'catalog' => $this->catalog,
                    'entry' => $this->identifier
                )
            ),//general
            'lifeCycle' => array(),
            'educational' => array(),
            'technical'    => array(),
            'rights' => array(),
            'classification' => array(),
            'metaMetadata' => array(),
            'relation'    => array()
        );
        //-----general.title (M)
        if (empty($this->title)) {
            array_push($this->title, "Untitled");
        }
        $lang = 'pt';
        $lomdata['general']['title'] = array("string?language=$lang" => $this->title[0]);
        //-----general.keyword (M)
        //initialize keyword
        //keywords from subject have the form: Language::keyword1$$Language::keyword2 ..
        $lomdata['general']['keyword'] = array();
        foreach ($this->subject as $elem) {
            $kw_elements = explode('$$', $elem);
            foreach ($kw_elements as $kw_elem) {
                $lang_kw = explode('::', $kw_elem);
                $kw = array_pop($lang_kw);
                if (empty($lang_kw)) {
                    $lang = 'pt';
                } else {
                    $lang = array_pop($lang_kw);
                }
                //add keyword
                if (strlen($kw) > 2) {
                    debug_message('adding keyword: '.$kw.' (length='.strlen($kw).') ; language '.$lang);
                    array_push($lomdata['general']['keyword'], array("string?language=$lang" =>$kw));
                }
            }
        }
        //-----general.description (M)
        //debug_var_dump('this->description', $this->description);
        //debug_var_dump('this', $this);
        if (empty($this->description)) {
            //repeat title in description if empty
            $_title = "";
            if (is_array($this->title)) {
                $_title = end($this->title);
            }
            array_push($this->description, $_title);
        }
        //initialize description
        $lomdata['general']['description'] = array();
        foreach ($this->description as $elem) {
            $lang = 'pt';
            array_push($lomdata['general']['description'], array("string?language=$lang" =>$elem));
            //add keywords from description
            if (strlen($elem) > 2) {
                array_push(
                    $lomdata['general']['keyword'],
                    array("string?language=pt" => implode(', ', array_keys($this->extractCommonWords($elem))))
                );
            }
            //debug_var_dump('lomdata->general->keyword', $lomdata['general']['keyword']);
        }
        //if after all this keyword is still empty....
        if (empty($lomdata['general']['keyword'])) {
            if (is_array($this->type_) && $this->type_[0] == 'collection') {
                array_push($lomdata['general']['keyword'], array("string?language=pt" =>'canal'));
            } else {
                array_push($lomdata['general']['keyword'], array("string?language=pt" =>'video'));
            }
        }
        //-----general.language (M)
        if (empty($this->language)) {
            array_push($this->language, "pt");
        }
        //initialize language
        $lomdata['general']['language'] = array();
        foreach ($this->language as $elem) {
            array_push($lomdata['general']['language'], $elem);
        }
        //-----general.coverage
        if (!empty($this->coverage)) {
            $lomdata['general']['coverage'] = array();
            foreach ($this->coverage as $elem) {
                $lang = 'pt';
                array_push($lomdata['general']['coverage'], array("string?language=$lang" =>$elem));
            }
        }
        //-----lifeCycle.contribute (M)
        if (empty($this->creator) && empty($this->publisher) && empty($this->contributor)) {
            //set unknown creator
            array_push($this->creator, "Unknown");
        }
        //intialize contribute
        $lomdata['lifeCycle']['contribute'] = array();
        //---lifeCycle.contribute -> creator
        if (!empty($this->creator)) {
            foreach ($this->creator as $elem) {
                array_push(
                    $lomdata['lifeCycle']['contribute'],
                    array(
                    'role' => array(
                        'source' => 'LOMv1.0',
                        'value' => 'author'),
                    'entity' => $this->asVcard($elem) )
                );
            }
        }
        //---lifeCycle.contribute -> publisher
        if (!empty($this->publisher)) {
            $date = '';
            if (!empty($this->date_)) {
                $date = $this->date_[0];
            }
            foreach ($this->publisher as $elem) {
                array_push(
                    $lomdata['lifeCycle']['contribute'],
                    array(
                    'role' => array(
                        'source' => 'LOMv1.0',
                        'value' => 'publisher'),
                    'entity' => $this->asVcard($elem),
                    'date' => array('dateTime' => $date) )
                );
            }
        }
        //---lifeCycle.contribute -> editor
        if (!empty($this->contributor)) {
            foreach ($this->contributor as $elem) {
                array_push(
                    $lomdata['lifeCycle']['contribute'],
                    array(
                    'role' => array(
                        'source' => 'LOMv1.0',
                        'value' => 'editor'),
                    'entity' => $this->asVcard($elem) )
                );
            }
        }
        //-----educational.learningResourceType
        $lomdata['educational']['learningResourceType'] =
            array(
            'source' => 'LOMv1.0',
            'value' => 'lecture');
        //-----technical.location (M)
        if (empty($this->source)) {
            array_push($this->source, "undefined");
        }
        //intialize location
        $lomdata['technical']['location'] = array();
        foreach ($this->source as $elem) {
            array_push($lomdata['technical']['location'], $elem);
        }
        //-----technical.thumbnail (M)
        if (empty($this->thumbnail)) {
            array_push($this->thumbnail, 'none');
        }
        $lomdata['technical']['thumbnail'] = $this->thumbnail[0];
        //-----technical.format
        if (!empty($this->format_)) {
            //initialize format
            $lomdata['technical']['format'] = array();
            foreach ($this->format_ as $elem) {
                array_push($lomdata['technical']['format'], $elem);
            }
        }
        //-----rights.description
        if (!empty($this->rights)) {
            //initialize description
            $lomdata['rights']['description'] = array();
            foreach ($this->rights as $elem) {
                $lang = 'pt';
                array_push($lomdata['rights']['description'], array("string?language=$lang" => $elem));
            }
        }
        //metaMetadata.identifier
        $lomdata['metaMetadata']['identifier'] = array(
            'catalog' => $lomdata['general']['identifier']['catalog'],
            'entry' => $lomdata['general']['identifier']['entry']
        );
        //relation
        if (!empty($this->relation)) {
            foreach ($this->relation as $elem) {
                array_push($lomdata['relation'], array(
                    'kind' => array(
                        'source' => 'LOMv1.0',
                        'value' => 'ispartof'),
                    'resource' => array(
                        'description' => array("string?language=en" => $elem)
                    )
                ));
            }
        }

        return $lomdata;
    }
1209882
public function toArray()
	{
		$result = parent::toArray();

		if (isset($result['activated']))
		{
			$result['activated'] = $this->getActivatedAttribute($result['activated']);
		}
		if (isset($result['permissions']))
		{
			$result['permissions'] = $this->getPermissionsAttribute($result['permissions']);
		}
		if (isset($result['suspended_at']))
		{
			$result['suspended_at'] = $result['suspended_at']->format('Y-m-d H:i:s');
		}

		return $result;
	}
840621
public function jsonSerialize()
    {
        return array_map(function($value)
        {
            if($value instanceof JsonSerialize)
                return $value->jsonSerialize();
            elseif($value instanceof  JsonInterface)
                return json_decode($value->toJson(), true);
            elseif($value instanceof ArrayInterface)
                return $value->toArray();
            else
                return $value;

        }, $this->attributes);
    }
1293927
public function toArray()
    {
        $array = array();
        $data  = $this->__options;
        foreach ($data as $key => $value)
        {
            if ($value instanceof KObjectConfig) {
                $array[$key] = $value->toArray();
            } else {
                $array[$key] = $value;
            }
        }

        return $array;
    }
915879
public function getPkv()
    {
        $pk = $this->getPk();

        try {
            if (is_array($pk)) {
                $pkv = [];
                foreach ($pk as $pkItem) {
                    $val = $this->getAttrVal($pkItem);
                    $pkv[$pkItem] = $val;
                }
            } else {
                $pkv = $this->getAttrVal($pk);
            }
        } catch (\Exception $e) {
            return null;
        }

        return $pkv;
    }
1214739
public function format() {

        /*         * Add the mandatary props* */
        if (!is_null($this->name)) {
            $result[self::NAME_KEY] = $this->name;
        }

        /*         * Add the optional props if any* */
        if (!is_null($this->optionalProperties)) {
            $result = array_merge($result, $this->optionalProperties);
        }


        return $result;
    }
541959
public function hashCode()
    {
        $validPk = null !== $this->getPartId() &&
            null !== $this->getCompositeId();

        $validPrimaryKeyFKs = 2;
        $primaryKeyFKs = [];

        //relation skill_part_fk_part to table kk_trixionary_skill
        if ($this->aSkillRelatedByPartId && $hash = spl_object_hash($this->aSkillRelatedByPartId)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        //relation skill_part_fk_composite to table kk_trixionary_skill
        if ($this->aSkillRelatedByCompositeId && $hash = spl_object_hash($this->aSkillRelatedByCompositeId)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        if ($validPk) {
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
        } elseif ($validPrimaryKeyFKs) {
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
        }

        return spl_object_hash($this);
    }
53910
public function attributesToArray()
    {
        $attributes = $this->getArrayableAttributes();

        foreach ($this->getDates() as $key) {
            if (! isset($attributes[$key])) {
                continue;
            }

            $attributes[$key] = (string) $this->asDateTime($attributes[$key]);
        }

        foreach ($this->getMutatedAttributes() as $key) {
            if (! array_key_exists($key, $attributes)) {
                continue;
            }

            $attributes[$key] = $this->mutateAttributeForArray($key, $attributes[$key]);
        }

        foreach ($this->getArrayableAppends() as $key) {
            $attributes[$key] = $this->mutateAttributeForArray($key, null);
        }

        return $attributes;
    }
1257130
public function deserialize(): object
    {
        $this->buffer->position($this->assetOffset / 2);

        $usernameLength = $this->buffer->readUInt8();

        $this->transaction->asset = [
            'delegate' => [
                'username' => $this->buffer->position($this->assetOffset + 2)->readHexBytes($usernameLength * 2),
            ],
        ];

        return $this->parseSignatures($this->assetOffset + ($usernameLength + 1) * 2);
    }