private function addSubfield($_subfield)
    {
        if (array_key_exists('subfieldtagrange', $_subfield)) {
            $_subfieldRange = $this->handleSubfieldRanges($_subfield['subfieldtagrange']);
        } else {
            $_subfieldRange[] = $_subfield['subfieldtag'];
        }

        foreach ($_subfieldRange as $subfieldTag) {
            $Subfield = new Subfield((string) $subfieldTag);

            if (array_key_exists('index', $_subfield)) {
                $_pos = $this->validatePos($_subfield['index']);

                $Subfield->setIndexStartEnd($_pos[0], $_pos[1]);
            } else {
                // as of MARCspec 3.2.2 spec without index is always an abbreviation
                $Subfield->setIndexStartEnd(0, '#');
            }

            if (array_key_exists('charpos', $_subfield)) {
                $_chars = $this->validatePos($_subfield['charpos']);

                $Subfield->setCharStartEnd($_chars[0], $_chars[1]);
            }

            if (array_key_exists('subspecs', $_subfield)) {
                $_subSpecs = [];

                foreach ($_subfield['subspecs'] as $subspec) {
                    if (!array_key_exists('operator', $subspec)) {
                        foreach ($subspec as $orSubSpec) {
                            $_subSpecs[] = $this->createSubSpec($orSubSpec, $Subfield);
                        }
                        $Subfield->addSubSpec($_subSpecs);
                    } else {
                        $Subspec = $this->createSubSpec($subspec, $Subfield);

                        $Subfield->addSubSpec($Subspec);
                    }
                }
            }

            $this->addSubfields($Subfield);
        }
    }
private function addSubfield($_subfield)
    {
        if (array_key_exists('subfieldtagrange', $_subfield)) {
            $_subfieldRange = $this->handleSubfieldRanges($_subfield['subfieldtagrange']);
        } else {
            $_subfieldRange[] = $_subfield['subfieldtag'];
        }

        foreach ($_subfieldRange as $subfieldTag) {
            $Subfield = new Subfield((string) $subfieldTag);

            if (array_key_exists('index', $_subfield)) {
                $_pos = $this->validatePos($_subfield['index']);

                $Subfield->setIndexStartEnd($_pos[0], $_pos[1]);
            } else {
                // as of MARCspec 3.2.2 spec without index is always an abbreviation
                $Subfield->setIndexStartEnd(0, '#');
            }

            if (array_key_exists('charpos', $_subfield)) {
                $_chars = $this->validatePos($_subfield['charpos']);

                $Subfield->setCharStartEnd($_chars[0], $_chars[1]);
            }

            if (array_key_exists('subspecs', $_subfield)) {
                $_subSpecs = [];

                foreach ($_subfield['subspecs'] as $subspec) {
                    if (!array_key_exists('operator', $subspec)) {
                        foreach ($subspec as $orSubSpec) {
                            $_subSpecs[] = $this->createSubSpec($orSubSpec, $Subfield);
                        }
                        $Subfield->addSubSpec($_subSpecs);
                    } else {
                        $Subspec = $this->createSubSpec($subspec, $Subfield);

                        $Subfield->addSubSpec($Subspec);
                    }
                }
            }

            $this->addSubfields($Subfield);
        }
    }
private function addSubfield ( $ _subfield ) { if ( array_key_exists ( 'subfieldtagrange' , $ _subfield ) ) { $ _subfieldRange = $ this -> handleSubfieldRanges ( $ _subfield [ 'subfieldtagrange' ] ) ; } else { $ _subfieldRange [ ] = $ _subfield [ 'subfieldtag' ] ; } foreach ( $ _subfieldRange as $ subfieldTag ) { $ Subfield = new Subfield ( ( string ) $ subfieldTag ) ; if ( array_key_exists ( 'index' , $ _subfield ) ) { $ _pos = $ this -> validatePos ( $ _subfield [ 'index' ] ) ; $ Subfield -> setIndexStartEnd ( $ _pos [ 0 ] , $ _pos [ 1 ] ) ; } else { // as of MARCspec 3.2.2 spec without index is always an abbreviation $ Subfield -> setIndexStartEnd ( 0 , '#' ) ; } if ( array_key_exists ( 'charpos' , $ _subfield ) ) { $ _chars = $ this -> validatePos ( $ _subfield [ 'charpos' ] ) ; $ Subfield -> setCharStartEnd ( $ _chars [ 0 ] , $ _chars [ 1 ] ) ; } if ( array_key_exists ( 'subspecs' , $ _subfield ) ) { $ _subSpecs = [ ] ; foreach ( $ _subfield [ 'subspecs' ] as $ subspec ) { if ( ! array_key_exists ( 'operator' , $ subspec ) ) { foreach ( $ subspec as $ orSubSpec ) { $ _subSpecs [ ] = $ this -> createSubSpec ( $ orSubSpec , $ Subfield ) ; } $ Subfield -> addSubSpec ( $ _subSpecs ) ; } else { $ Subspec = $ this -> createSubSpec ( $ subspec , $ Subfield ) ; $ Subfield -> addSubSpec ( $ Subspec ) ; } } } $ this -> addSubfields ( $ Subfield ) ; } }
Creates and adds a single subfield from the MARCspecParser result.

@param array $_subfield The MARCspecParser result array
Creates and adds a single subfield from the MARCspecParser result .