src/CMDBObject.php
public function load($objectID) {
        $object = $this->read($objectID);

        if (count($object) === 0) {
            throw new RuntimeException('Object not found');
        }

        if (!array_key_exists('objecttype', $object)) {
            throw new RuntimeException(sprintf(
                'Object %s has no type',
                $objectID
            ));
        }

        $cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);

        $object += $cmdbObjectTypeCategories->readByID(
            $object['objecttype']
        );

        $cmdbCategory = new CMDBCategory($this->api);

        $categoryTypes = ['catg', 'cats', 'custom'];

        $cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
        $blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();

        foreach ($categoryTypes as $categoryType) {
            if (!array_key_exists($categoryType, $object)) {
                continue;
            }

            $categoryConstants = [];

            for ($i = 0; $i < count($object[$categoryType]); $i++) {
                if (!array_key_exists('const', $object[$categoryType][$i])) {
                    throw new RuntimeException(
                        'Information about categories is broken. Constant is missing.'
                    );
                }

                $categoryConstant = $object[$categoryType][$i]['const'];

                if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
                    continue;
                }

                $object[$categoryType][$i]['entries'] = [];

                $categoryConstants[] = $categoryConstant;
            }

            $categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);

            for ($i = 0; $i < count($categoryConstants); $i++) {
                $index = -1;
                $entries = [];

                foreach ($object[$categoryType] as $key => $category) {
                    if ($category['const'] === $categoryConstants[$i]) {
                        $index = $key;
                        $entries = $categoryEntries[$i];
                        break;
                    }
                }

                $object[$categoryType][$index]['entries'] = $entries;
            }
        }

        return $object;
    }
public function load($objectID) {
        $object = $this->read($objectID);

        if (count($object) === 0) {
            throw new RuntimeException('Object not found');
        }

        if (!array_key_exists('objecttype', $object)) {
            throw new RuntimeException(sprintf(
                'Object %s has no type',
                $objectID
            ));
        }

        $cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);

        $object += $cmdbObjectTypeCategories->readByID(
            $object['objecttype']
        );

        $cmdbCategory = new CMDBCategory($this->api);

        $categoryTypes = ['catg', 'cats', 'custom'];

        $cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
        $blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();

        foreach ($categoryTypes as $categoryType) {
            if (!array_key_exists($categoryType, $object)) {
                continue;
            }

            $categoryConstants = [];

            for ($i = 0; $i < count($object[$categoryType]); $i++) {
                if (!array_key_exists('const', $object[$categoryType][$i])) {
                    throw new RuntimeException(
                        'Information about categories is broken. Constant is missing.'
                    );
                }

                $categoryConstant = $object[$categoryType][$i]['const'];

                if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
                    continue;
                }

                $object[$categoryType][$i]['entries'] = [];

                $categoryConstants[] = $categoryConstant;
            }

            $categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);

            for ($i = 0; $i < count($categoryConstants); $i++) {
                $index = -1;
                $entries = [];

                foreach ($object[$categoryType] as $key => $category) {
                    if ($category['const'] === $categoryConstants[$i]) {
                        $index = $key;
                        $entries = $categoryEntries[$i];
                        break;
                    }
                }

                $object[$categoryType][$index]['entries'] = $entries;
            }
        }

        return $object;
    }
public function load ( $ objectID ) { $ object = $ this -> read ( $ objectID ) ; if ( count ( $ object ) === 0 ) { throw new RuntimeException ( 'Object not found' ) ; } if ( ! array_key_exists ( 'objecttype' , $ object ) ) { throw new RuntimeException ( sprintf ( 'Object %s has no type' , $ objectID ) ) ; } $ cmdbObjectTypeCategories = new CMDBObjectTypeCategories ( $ this -> api ) ; $ object += $ cmdbObjectTypeCategories -> readByID ( $ object [ 'objecttype' ] ) ; $ cmdbCategory = new CMDBCategory ( $ this -> api ) ; $ categoryTypes = [ 'catg' , 'cats' , 'custom' ] ; $ cmdbCategoryInfo = new CMDBCategoryInfo ( $ this -> api ) ; $ blacklistedCategoryConstants = $ cmdbCategoryInfo -> getVirtualCategoryConstants ( ) ; foreach ( $ categoryTypes as $ categoryType ) { if ( ! array_key_exists ( $ categoryType , $ object ) ) { continue ; } $ categoryConstants = [ ] ; for ( $ i = 0 ; $ i < count ( $ object [ $ categoryType ] ) ; $ i ++ ) { if ( ! array_key_exists ( 'const' , $ object [ $ categoryType ] [ $ i ] ) ) { throw new RuntimeException ( 'Information about categories is broken. Constant is missing.' ) ; } $ categoryConstant = $ object [ $ categoryType ] [ $ i ] [ 'const' ] ; if ( in_array ( $ categoryConstant , $ blacklistedCategoryConstants ) ) { continue ; } $ object [ $ categoryType ] [ $ i ] [ 'entries' ] = [ ] ; $ categoryConstants [ ] = $ categoryConstant ; } $ categoryEntries = $ cmdbCategory -> batchRead ( [ $ objectID ] , $ categoryConstants ) ; for ( $ i = 0 ; $ i < count ( $ categoryConstants ) ; $ i ++ ) { $ index = - 1 ; $ entries = [ ] ; foreach ( $ object [ $ categoryType ] as $ key => $ category ) { if ( $ category [ 'const' ] === $ categoryConstants [ $ i ] ) { $ index = $ key ; $ entries = $ categoryEntries [ $ i ] ; break ; } } $ object [ $ categoryType ] [ $ index ] [ 'entries' ] = $ entries ; } } return $ object ; }
Load all data about object

@param int $objectID Object identifier

@return array Multi-dimensional array

@throws Exception on error

@deprecated This method is pretty slow. Use readAll() instead!
Load all data about object