@param Section $section

@return array - The serialized representation of a contribution
186629
public function serialize(Section $section, $options = [], $isNew = false)
    {
        $author = $section->getAuthor();
        $extraMeta = [];
        if (in_array(Options::DEEP_SERIALIZE, $options) && !$section->isRoot()) {
            $extraMeta = [
                'new' => $isNew,
                'parent' => $section->getParent()->getUuid(),
                'moved' => $section->hasMoved(),
            ];
        }

        return [
            'id' => $section->getUuid(),
            'activeContribution' => $this->contributionSerializer->serialize($section->getActiveContribution()),
            'meta' => array_merge($extraMeta, [
                'createdAt' => $section->getCreationDate()->format('Y-m-d H:i'),
                'visible' => $section->getVisible(),
                'deletedAt' => $section->getDeleted() ? $section->getDeletionDate()->format('Y-m-d H:i') : null,
                'creator' => null === $author ?
                    null :
                    $this->userSerializer->serialize($author, [Options::SERIALIZE_MINIMAL]),
            ]),
            'children' => [],
        ];
    }
335530
public function compareContributions(Section $section, $uuids)
    {
        $contributions = $this->contributionRepository->findyBySectionAndUuids($section, $uuids);
        $titleDiff = new HtmlDiff($contributions[0]->getTitle(), $contributions[1]->getTitle(), false);
        $textDiff = new HtmlDiff($contributions[0]->getText(), $contributions[1]->getText(), true);
        $contribution = new Contribution();
        $contribution->setText($textDiff->outputDiff()->toString());
        $contribution->setTitle($titleDiff->outputDiff()->toString());
        $contribution->setContributor($contributions[1]->getContributor());
        $contribution->setCreationDate($contributions[1]->getCreationDate());
        $contribution->refreshUuid();
        $contributions[1] = $contribution;

        return $contributions;
    }
995425
public function get_section_name($section) {
        $section = $this->get_section($section);
        if ((string)$section->name !== '') {
            // Return the name the user set.
            return format_string($section->name, true, array('context' => context_course::instance($this->courseid)));
        } else {
            return $this->get_default_section_name($section);
        }
    }
1115997
public function renderSections($sections = null)
    {
        if ($sections === null) {
            $sections = $this->getSections();
        }
        $res = '';
        foreach ($sections as $section) {
            $res .= $this->renderSection($section);
        }

        return $res;
    }
1113725
private function resolverType(string $section, string $key)
    {
        return $this->typeRegistry->get(
            $this->schemaRegistry->get($section, $key)->getType()
        );
    }
1073016
public function getSectionType($section, $code)
    {
        if (!isset($this->types[$section])) {
            return null;
        }

        $types = array_filter(
            $this->types[$section],
            function (ImageType $item) use ($code) {
                return strtolower($code) === strtolower($item->getCode());
            }
        );

        return array_values($types)[0];
    }
1046334
public static function InSection($Section) {
      $Section = (array)$Section;
      foreach ($Section as $Name) {
         if (isset(self::$_Section[$Name]))
            return TRUE;
      }
      return FALSE;
   }
920222
public function setSection( Section$section=null ):self
	{
		if( !$section ){
			$this->sectionLevel= 0;
			$this->currentSection= null;

			return $this;
		}

		if( $this->currentSection ){
			$this->throw('Nesting definition of section is forbidden.');
		}

		if( isset($this->parent->sections[$section->name]) ){
			$this->throw("Section {$section->name} already defined.");
		}

		$this->currentSection= $section;

		if( $section->name ){
			$this->parent->sections[$section->name]=$section;
		}

		$this->sectionLevel= $this->level+1;

		return $this;
	}
1033724
public static function get_config($section = '') {

        $params = self::validate_parameters(self::get_config_parameters(), array('section' => $section));

        $settings = api::get_config($params['section']);
        $result['settings'] = array();
        foreach ($settings as $name => $value) {
            $result['settings'][] = array(
                'name' => $name,
                'value' => $value,
            );
        }

        $result['warnings'] = array();
        return $result;
    }
1119226
public function info($section = null) {
        return $this->returnCommand(['INFO'], null, $section ? [$section] : null, ResponseParser::PARSE_INFO);
    }
195050
public function removeSection( $section )
	{
		if( !$this->usesSections() )
			throw new RuntimeException( 'Sections are disabled' );
		if( !$this->hasSection( $section ) )
			throw new InvalidArgumentException( 'Section "'.$section.'" is not existing' );
		$index	= array_search( $section, $this->sections);
		unset( $this->sections[$index] );
		return is_int( $this->write() );
	}
953094
protected function getSection($section)
    {
        return isset($this->sections[$section])
            ? $this->sections[$section]
            : null;
    }
137844
protected function retrieveSectionContent( $section ) {
		if ( array_key_exists( 'raw', $section['content'] ) ) {
			$source_content = $section['content']['raw'];
		} else {
			$source_content = $section['content']['rendered'];
		}

		// According to the html5 spec section 8.3: https://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#serializing-html-fragments
		// We should replace any occurrences of the U+00A0 NO-BREAK SPACE character (aka "\xc2\xa0") by the string "&nbsp;" when serializing HTML5
		// When cloning, we don't want to modify whitespaces, so we hide them from the parser.
		$characters_to_keep = [ "\xc2\xa0" ];
		foreach ( $characters_to_keep as $c ) {
			$md5 = md5( $c );
			$source_content = str_replace( $c, "<!-- pb_fixme_{$md5} -->", $source_content );
		}

		// Load source content
		$html5 = new \Pressbooks\HtmlParser();
		$dom = $html5->loadHTML( $source_content );

		// Download images, change image paths
		$media = $this->downloads->scrapeAndKneadImages( $dom );
		$dom = $media['dom'];
		$attachments = $media['attachments'];

		// Download media, change media paths
		$media = $this->downloads->scrapeAndKneadMedia( $dom, $html5->parser );
		$dom = $media['dom'];
		$attachments = array_merge( $attachments, $media['attachments'] );

		// Fix internal links
		$dom = $this->fixInternalLinks( $dom );

		// Save the destination content
		$content = $html5->saveHTML( $dom );

		// Put back the hidden characters
		foreach ( $characters_to_keep as $c ) {
			$md5 = md5( $c );
			$content = str_replace( "<!-- pb_fixme_{$md5} -->", $c, $content );
		}

		// Count attachments
		foreach ( $attachments as $pid ) {
			$this->clonedItems['media'][] = $pid;
		}

		return [ trim( $content ), $attachments ];
	}
360240
private function getSectionsNumbers(array $sections): array
    {
        $sectionsNumbers = array_column($sections, 'id');

        return array_combine($sectionsNumbers, array_fill_keys($sectionsNumbers, false));
    }
292768
public function addSection(PHPRtfLite_Container_Section $section = null)
    {
        if ($section === null) {
            $section = new PHPRtfLite_Container_Section($this);
        }

        $this->_sections[] = $section;

        return $section;
    }
29694
public function deserialize($data, User $user, Section $section = null)
    {
        if (empty($section)) {
            $section = new Section();
            $section->refreshUuid();
            $section->setAuthor($user);
        }
        if ($data['activeContribution']) {
            $activeContribution = $this->contributionSerializer->deserialize($data['activeContribution'], $user, $section);
            $section->setActiveContribution($activeContribution);
        }

        return $section;
    }
275677
public function keysForSection(string $section, array $default = []): array
    {
        if (isset($this->propertyData[$section])) {
            return array_keys($this->propertyData[$section]);
        }

        return $default;
    }