src/CMDBCategory.php
public function batchCreate(array $objectIDs, $categoryConst, array $attributes) {
        $entryIDs = [];

        $requests = [];

        foreach ($objectIDs as $objectID) {
            foreach ($attributes as $data) {
                $params = [
                    'objID' => $objectID,
                    'data' => $data,
                    'category' => $categoryConst
                ];

                $requests[] = [
                    'method' => 'cmdb.category.create',
                    'params' => $params
                ];
            }
        }

        $result = $this->api->batchRequest($requests);

        foreach ($result as $entry) {
            // Do not check 'id' because in a batch request it is always NULL:
            if (!array_key_exists('success', $entry) ||
                $entry['success'] !== true) {
                if (array_key_exists('message', $entry)) {
                    throw new RuntimeException(sprintf('Bad result: %s', $entry['message']));
                } else {
                    throw new RuntimeException('Bad result');
                }
            }

            $entryIDs[] = (int) $entry['id'];
        }

        return $entryIDs;
    }
public function batchCreate(array $objectIDs, $categoryConst, array $attributes) {
        $entryIDs = [];

        $requests = [];

        foreach ($objectIDs as $objectID) {
            foreach ($attributes as $data) {
                $params = [
                    'objID' => $objectID,
                    'data' => $data,
                    'category' => $categoryConst
                ];

                $requests[] = [
                    'method' => 'cmdb.category.create',
                    'params' => $params
                ];
            }
        }

        $result = $this->api->batchRequest($requests);

        foreach ($result as $entry) {
            // Do not check 'id' because in a batch request it is always NULL:
            if (!array_key_exists('success', $entry) ||
                $entry['success'] !== true) {
                if (array_key_exists('message', $entry)) {
                    throw new RuntimeException(sprintf('Bad result: %s', $entry['message']));
                } else {
                    throw new RuntimeException('Bad result');
                }
            }

            $entryIDs[] = (int) $entry['id'];
        }

        return $entryIDs;
    }
public function batchCreate ( array $ objectIDs , $ categoryConst , array $ attributes ) { $ entryIDs = [ ] ; $ requests = [ ] ; foreach ( $ objectIDs as $ objectID ) { foreach ( $ attributes as $ data ) { $ params = [ 'objID' => $ objectID , 'data' => $ data , 'category' => $ categoryConst ] ; $ requests [ ] = [ 'method' => 'cmdb.category.create' , 'params' => $ params ] ; } } $ result = $ this -> api -> batchRequest ( $ requests ) ; foreach ( $ result as $ entry ) { // Do not check 'id' because in a batch request it is always NULL: if ( ! array_key_exists ( 'success' , $ entry ) || $ entry [ 'success' ] !== true ) { if ( array_key_exists ( 'message' , $ entry ) ) { throw new RuntimeException ( sprintf ( 'Bad result: %s' , $ entry [ 'message' ] ) ) ; } else { throw new RuntimeException ( 'Bad result' ) ; } } $ entryIDs [ ] = ( int ) $ entry [ 'id' ] ; } return $ entryIDs ; }
Create multiple entries for a specific category and one or more objects

@param array $objectIDs List of object identifiers as integers
@param string $categoryConst Category constant
@param array $attributes Indexed array of attributes as key-value pairs

@return array List of entry identifiers as integers

@throws Exception on error
Create multiple entries for a specific category and one or more objects