/** * returns TRUE if property is multiple. * * @return bool */ public function getIsMultiple() { return $this->property->getIsMultiple(); }
/** * Returns prepared data from property * use callback to prepare data foreach property function($contentType, $property). * * @param PropertyInterface $property * @param callable $dataCallback * @param bool $returnType * * @return array */ private function prepareData(PropertyInterface $property, callable $dataCallback, $returnType = true) { /** @var BlockPropertyInterface $blockProperty */ $blockProperty = $property; while (!$blockProperty instanceof BlockPropertyInterface) { $blockProperty = $blockProperty->getProperty(); } $data = []; for ($i = 0; $i < $blockProperty->getLength(); ++$i) { $blockPropertyType = $blockProperty->getProperties($i); if ($returnType) { $type = $blockPropertyType->getName(); $data[$i] = ['type' => $type]; } foreach ($blockPropertyType->getChildProperties() as $childProperty) { $contentType = $this->contentTypeManager->get($childProperty->getContentTypeName()); $data[$i][$childProperty->getName()] = $dataCallback($contentType, $childProperty); } } if (!$property->getIsMultiple() && count($data) > 0) { $data = $data[0]; } return $data; }