public function __construct($route, RouteDocument $routeDocument, CustomUrlDocument $customUrl) { parent::__construct(sprintf('Cannot delete current route "%s" of custom-url "%s"', $route, $customUrl->getTitle()), 9000); $this->route = $route; $this->routeDocument = $routeDocument; $this->customUrl = $customUrl; }
/** * Bind data array to given document. * * TODO this logic have to be extracted in a proper way. * * @param CustomUrlDocument $document * @param array $data * @param string $locale */ private function bind(CustomUrlDocument $document, $data, $locale) { $document->setTitle($data['title']); unset($data['title']); $metadata = $this->metadataFactory->getMetadataForAlias('custom_url'); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($metadata->getFieldMappings() as $fieldName => $mapping) { if (!array_key_exists($fieldName, $data)) { continue; } $value = $data[$fieldName]; if (array_key_exists('type', $mapping) && $mapping['type'] === 'reference') { $value = $this->documentManager->find($value['uuid'], $locale, ['load_ghost_content' => true]); } $accessor->setValue($document, $fieldName, $value); } $document->setLocale($locale); }