src/CMDBDialog.php
public function batchCreate(array $values) {
        $requests = [];

        foreach ($values as $category => $keyValuePair) {
            foreach ($keyValuePair as $attribute => $mixed) {
                $values = [];

                if (is_array($mixed)) {
                    $values = $mixed;
                } else {
                    $values[] = $mixed;
                }

                foreach ($values as $value) {
                    $requests[] = [
                        'method' => 'cmdb.dialog.create',
                        'params' => [
                            'category' => $category,
                            'property' => $attribute,
                            'value' => $value
                        ]
                    ];
                }
            }
        }

        $entryIDs = [];

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

        foreach ($entries as $entry) {
            if (!array_key_exists('entry_id', $entry) ||
                !is_numeric($entry['entry_id'])) {
                throw new RuntimeException('Bad result');
            }

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

        return $entryIDs;
    }
public function batchCreate(array $values) {
        $requests = [];

        foreach ($values as $category => $keyValuePair) {
            foreach ($keyValuePair as $attribute => $mixed) {
                $values = [];

                if (is_array($mixed)) {
                    $values = $mixed;
                } else {
                    $values[] = $mixed;
                }

                foreach ($values as $value) {
                    $requests[] = [
                        'method' => 'cmdb.dialog.create',
                        'params' => [
                            'category' => $category,
                            'property' => $attribute,
                            'value' => $value
                        ]
                    ];
                }
            }
        }

        $entryIDs = [];

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

        foreach ($entries as $entry) {
            if (!array_key_exists('entry_id', $entry) ||
                !is_numeric($entry['entry_id'])) {
                throw new RuntimeException('Bad result');
            }

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

        return $entryIDs;
    }
public function batchCreate ( array $ values ) { $ requests = [ ] ; foreach ( $ values as $ category => $ keyValuePair ) { foreach ( $ keyValuePair as $ attribute => $ mixed ) { $ values = [ ] ; if ( is_array ( $ mixed ) ) { $ values = $ mixed ; } else { $ values [ ] = $ mixed ; } foreach ( $ values as $ value ) { $ requests [ ] = [ 'method' => 'cmdb.dialog.create' , 'params' => [ 'category' => $ category , 'property' => $ attribute , 'value' => $ value ] ] ; } } } $ entryIDs = [ ] ; $ entries = $ this -> api -> batchRequest ( $ requests ) ; foreach ( $ entries as $ entry ) { if ( ! array_key_exists ( 'entry_id' , $ entry ) || ! is_numeric ( $ entry [ 'entry_id' ] ) ) { throw new RuntimeException ( 'Bad result' ) ; } $ entryIDs [ ] = ( int ) $ entry [ 'entry_id' ] ; } return $ entryIDs ; }
Create one or more entries for a drow-down menu

@param array $values Values:
[
'cat' => [
'attr' => 'value', 'attr' => 'value'
],
'cat' => [
'attr' => ['value 1', 'value 2']
]
]

@return array List of entry identifiers

@throws Exception on error

@todo Add support for parameter "parent"!
Create one or more entries for a drow - down menu