Importer/PKP/SectionImporter.php
public function importSection($id, $newJournalId)
    {
        /** @var Journal $journal */
        $journal = $this->em->getReference('VipaJournalBundle:Journal', $newJournalId);
        $this->consoleOutput->writeln("Reading section #" . $id . "... ", true);

        $sectionSql = "SELECT * FROM sections WHERE section_id = :id LIMIT 1";
        $sectionStatement = $this->dbalConnection->prepare($sectionSql);
        $sectionStatement->bindValue('id', $id);
        $sectionStatement->execute();

        $settingsSql = "SELECT locale, setting_name, setting_value FROM section_settings WHERE section_id = :id";
        $settingsStatement = $this->dbalConnection->prepare($settingsSql);
        $settingsStatement->bindValue('id', $id);
        $settingsStatement->execute();

        $pkpSection = $sectionStatement->fetch();
        $pkpSettings = $settingsStatement->fetchAll();

        foreach ($pkpSettings as $setting) {
            $locale = !empty($setting['locale']) ? $setting['locale'] : 'en_US';
            $name = $setting['setting_name'];
            $value = $setting['setting_value'];
            $this->settings[$locale][$name] = $value;
        }

        $section = new Section();
        $section->setJournal($journal);
        $section->setAllowIndex(!empty($pkpSection['meta_indexed']) ? $pkpSection['meta_indexed'] : 0);
        $section->setHideTitle(!empty($pkpSection['hide_title']) ? $pkpSection['hide_title'] : 0);
        $section->setSectionOrder(!empty($pkpSection['seq']) ? intval($pkpSection['seq']) : 0);

        foreach ($this->settings as $fieldLocale => $fields) {
            $section->setCurrentLocale(mb_substr($fieldLocale, 0, 2, 'UTF-8'));
            $section->setTitle(!empty($fields['title']) ? $fields['title']: '-');
        }

        $this->consoleOutput->writeln("Writing section #" . $id . "... ", true);

        $this->em->persist($section);

        return $section;
    }
public function importSection($id, $newJournalId)
    {
        /** @var Journal $journal */
        $journal = $this->em->getReference('VipaJournalBundle:Journal', $newJournalId);
        $this->consoleOutput->writeln("Reading section #" . $id . "... ", true);

        $sectionSql = "SELECT * FROM sections WHERE section_id = :id LIMIT 1";
        $sectionStatement = $this->dbalConnection->prepare($sectionSql);
        $sectionStatement->bindValue('id', $id);
        $sectionStatement->execute();

        $settingsSql = "SELECT locale, setting_name, setting_value FROM section_settings WHERE section_id = :id";
        $settingsStatement = $this->dbalConnection->prepare($settingsSql);
        $settingsStatement->bindValue('id', $id);
        $settingsStatement->execute();

        $pkpSection = $sectionStatement->fetch();
        $pkpSettings = $settingsStatement->fetchAll();

        foreach ($pkpSettings as $setting) {
            $locale = !empty($setting['locale']) ? $setting['locale'] : 'en_US';
            $name = $setting['setting_name'];
            $value = $setting['setting_value'];
            $this->settings[$locale][$name] = $value;
        }

        $section = new Section();
        $section->setJournal($journal);
        $section->setAllowIndex(!empty($pkpSection['meta_indexed']) ? $pkpSection['meta_indexed'] : 0);
        $section->setHideTitle(!empty($pkpSection['hide_title']) ? $pkpSection['hide_title'] : 0);
        $section->setSectionOrder(!empty($pkpSection['seq']) ? intval($pkpSection['seq']) : 0);

        foreach ($this->settings as $fieldLocale => $fields) {
            $section->setCurrentLocale(mb_substr($fieldLocale, 0, 2, 'UTF-8'));
            $section->setTitle(!empty($fields['title']) ? $fields['title']: '-');
        }

        $this->consoleOutput->writeln("Writing section #" . $id . "... ", true);

        $this->em->persist($section);

        return $section;
    }
public function importSection ( $ id , $ newJournalId ) { /** @var Journal $journal */ $ journal = $ this -> em -> getReference ( 'VipaJournalBundle:Journal' , $ newJournalId ) ; $ this -> consoleOutput -> writeln ( "Reading section #" . $ id . "... " , true ) ; $ sectionSql = "SELECT * FROM sections WHERE section_id = :id LIMIT 1" ; $ sectionStatement = $ this -> dbalConnection -> prepare ( $ sectionSql ) ; $ sectionStatement -> bindValue ( 'id' , $ id ) ; $ sectionStatement -> execute ( ) ; $ settingsSql = "SELECT locale, setting_name, setting_value FROM section_settings WHERE section_id = :id" ; $ settingsStatement = $ this -> dbalConnection -> prepare ( $ settingsSql ) ; $ settingsStatement -> bindValue ( 'id' , $ id ) ; $ settingsStatement -> execute ( ) ; $ pkpSection = $ sectionStatement -> fetch ( ) ; $ pkpSettings = $ settingsStatement -> fetchAll ( ) ; foreach ( $ pkpSettings as $ setting ) { $ locale = ! empty ( $ setting [ 'locale' ] ) ? $ setting [ 'locale' ] : 'en_US' ; $ name = $ setting [ 'setting_name' ] ; $ value = $ setting [ 'setting_value' ] ; $ this -> settings [ $ locale ] [ $ name ] = $ value ; } $ section = new Section ( ) ; $ section -> setJournal ( $ journal ) ; $ section -> setAllowIndex ( ! empty ( $ pkpSection [ 'meta_indexed' ] ) ? $ pkpSection [ 'meta_indexed' ] : 0 ) ; $ section -> setHideTitle ( ! empty ( $ pkpSection [ 'hide_title' ] ) ? $ pkpSection [ 'hide_title' ] : 0 ) ; $ section -> setSectionOrder ( ! empty ( $ pkpSection [ 'seq' ] ) ? intval ( $ pkpSection [ 'seq' ] ) : 0 ) ; foreach ( $ this -> settings as $ fieldLocale => $ fields ) { $ section -> setCurrentLocale ( mb_substr ( $ fieldLocale , 0 , 2 , 'UTF-8' ) ) ; $ section -> setTitle ( ! empty ( $ fields [ 'title' ] ) ? $ fields [ 'title' ] : '-' ) ; } $ this -> consoleOutput -> writeln ( "Writing section #" . $ id . "... " , true ) ; $ this -> em -> persist ( $ section ) ; return $ section ; }
Imports the given section
@param int $id Section's ID
@param int $newJournalId Section's Journal ID
@return Section
Imports the given section