unsetting object value

91 views Asked by At

I am trying to unset an object's value

I want to unset the document number -950 from the object $docList

foreach ($docList as  $document) {
    $visibleOrgIDs = $docList->LoadVisibleOrganizationListByDocID($document->getId());
    if(!in_array($org,$visibleOrgIDs)){
        unset($document->getId());
    }
}

$docList is the object which I am traversing. print_r($docList) will result in this:

LomsDocumentList Object (
    [offset:protected] => 
    [limit:protected] => 
    [filter:protected] => 
    [sort:protected] => 
    [additionalFields:protected] => 
    [fetchCount] => 
    [countAll] => 
    [objectIds:RosiBaseList:private] => Array
        (
            [0] => 950
        )

    [storage:SplObjectStorage:private] => Array
        (
            [00000000277be4ca0000000108de8355] => Array
                (
                    [obj] => LomsDocument Object
                        (
                            [DBtableFieldNames:protected] => Array
                                (
                                    [id] => DOC_ID
                                    [parentDocumentId] => PARENT_ID
                                    [ownerId] => OWNER_ID
                                    [fileId] => FILE_ID
                                    [linkId] => LINK_ID
                                    [documentTypeId] => DOC_TYPE_ID
                                    [languageId] => LANG
                                    [organizationId] => ORG_ID
                                    [bpDepartmentId] => BP_DEPARTMENT_ID
                                    [elementId] => ELEMENT_ID
                                    [title] => TITLE
                                    [description] => DESCRIPTION
                                    [validUntil] => VALID_UNTIL
                                    [isInternal] => IS_INTERNAL
                                    [isInRevision] => IS_IN_REVISION
                                    [mediaType] => MEDIA_TYPE
                                    [expirationAdviceSent] => EXPIRATION_ADVICE_SENT
                                    [firstAuthorId] => CRT_ID
                                    [lastAuthorId] => LAST_UPDT_ID
                                    [contentOwnerId] => CONTENT_OWNER_ID
                                    [extractDocumentId] => EXTRACT_ID
                                    [sortField] => SORT_FIELD
                                    [category] => CATEGORY
                                    [mediaUpdateAt] => LAST_MEDIA_CHNG_DATE_TIME
                                    [mediaUpdateBy] => LAST_MEDIA_CHNG_NAME
                                )

                            [DBtableName:protected] => LOMS_DOC
                            [parentDocumentId:protected] => 
                            [parentDocument:protected] => 
                            [ownerId:protected] => 174450
                            [owner:protected] => 
                            [fileId:protected] => 4967
                            [file:protected] => 
                            [linkId:protected] => 
                            [link:protected] => 
                            [documentTypeId:protected] => 3
                            [documentType:protected] => 
                            [languageId:protected] => de
                            [language:protected] => 
                            [organizationId:protected] => 122
                            [organization:protected] => 
                            [bpDepartmentId:protected] => 122
                            [bpDepartment:protected] => 
                            [elementId:protected] => 52
                            [element:protected] => 
                            [title:protected] => Testdokument_1_New_BF_BENE_20.11.2014
                            [description:protected] => Test OMS BF Finance BeNe
                            [validUntil:protected] => DateTime Object
                                (
                                    [date] => 2014-12-19 00:00:00.000000
                                    [timezone_type] => 3
                                    [timezone] => Europe/Berlin
                                )
1

There are 1 answers

4
machineaddict On

You can make a method inside LomsDocumentList class that unsets that variable objectIds by using the array_search function.

Example:

class LomsDocumentList {
    public function searchAndUnsetByValue($val) {
        $key = array_search($val, $this->objectIds);
        if ($key !== FALSE) {
            unset($this->objectIds[$key]);
        }
    }
}

and call it

$docList->searchAndUnsetByValue(950);