private function prepareElements(array $elementsData, $acceptScalar = true)
    {
        $elements = [];
        foreach ($elementsData as $key => $data) {
            if (true === $acceptScalar && is_scalar($data)) {
                $elements[$key] = $data;
                continue;
            }

            if (!is_array($data)) {
                continue;
            }

            if (isset($data['type']) && isset($data['uid'])) {
                if (null !== $element = $this->findOneByTypeAndUid($data['type'], $data['uid'])) {
                    $elements[$key] = $element;
                }

                continue;
            }

            $elements[$key] = [];
            foreach ($data as $row) {
                if (
                    isset($row['type'])
                    && isset($row['uid'])
                    && null !== $element = $this->findOneByTypeAndUid($row['type'], $row['uid'])
                ) {
                    $elements[$key][] = $element;
                }
            }
        }

        return $elements;
    }
private function prepareElements(array $elementsData, $acceptScalar = true)
    {
        $elements = [];
        foreach ($elementsData as $key => $data) {
            if (true === $acceptScalar && is_scalar($data)) {
                $elements[$key] = $data;
                continue;
            }

            if (!is_array($data)) {
                continue;
            }

            if (isset($data['type']) && isset($data['uid'])) {
                if (null !== $element = $this->findOneByTypeAndUid($data['type'], $data['uid'])) {
                    $elements[$key] = $element;
                }

                continue;
            }

            $elements[$key] = [];
            foreach ($data as $row) {
                if (
                    isset($row['type'])
                    && isset($row['uid'])
                    && null !== $element = $this->findOneByTypeAndUid($row['type'], $row['uid'])
                ) {
                    $elements[$key][] = $element;
                }
            }
        }

        return $elements;
    }
private function prepareElements ( array $ elementsData , $ acceptScalar = true ) { $ elements = [ ] ; foreach ( $ elementsData as $ key => $ data ) { if ( true === $ acceptScalar && is_scalar ( $ data ) ) { $ elements [ $ key ] = $ data ; continue ; } if ( ! is_array ( $ data ) ) { continue ; } if ( isset ( $ data [ 'type' ] ) && isset ( $ data [ 'uid' ] ) ) { if ( null !== $ element = $ this -> findOneByTypeAndUid ( $ data [ 'type' ] , $ data [ 'uid' ] ) ) { $ elements [ $ key ] = $ element ; } continue ; } $ elements [ $ key ] = [ ] ; foreach ( $ data as $ row ) { if ( isset ( $ row [ 'type' ] ) && isset ( $ row [ 'uid' ] ) && null !== $ element = $ this -> findOneByTypeAndUid ( $ row [ 'type' ] , $ row [ 'uid' ] ) ) { $ elements [ $ key ] [ ] = $ element ; } } } return $ elements ; }
Prepare elements to be setted.

@param  array   $elementsData The elements to be setted.
@param  boolean $acceptScalar If true, scalar value will be accepted.

@return array
Prepare elements to be setted .