mapByProperties($this->getProps(), $item); } /** * Summarize an section * * Includes properties with the apiSummary flag in the section schema. */ public function summarize(Section $item): array { return $this->mapByProperties($this->getSummaryProps(), $item); } /** * Map a collection of Sections * * @see self::map */ public function mapMany(Enumerable $collection): Enumerable { $this->collection = $collection; return $collection->map(function ($item) { return $this->map($item); }); } /** * Summarize a collection of Sections * * @see self::summarize */ public function summarizeMany(Enumerable $collection): Enumerable { $this->collection = $collection; return $collection->map(function ($item) { return $this->summarize($item); }); } /** * Map schema properties of an Section to an assoc array */ protected function mapByProperties(array $props, Section $item): array { $output = []; foreach ($props as $prop) { switch ($prop) { case '_href': $output[$prop] = $this->getApiUrl('sections/' . $item->getId()); break; default: $output[$prop] = $item->getData($prop); break; } } $output = $this->schemaService->addMissingMultilingualValues($this->schema, $output, $this->context->getSupportedFormLocales()); ksort($output); return $this->withExtensions($output, $item); } }