/** * {@inheritdoc} */ public function resolveDatasource($datasource, array $propertyParameter, array $options) { if (empty($datasource)) { return; } if ($datasource === 'root') { $title = 'smart-content.media.all-collections'; return new DatasourceItem('root', $title, $title); } $entity = $this->collectionManager->getById($datasource, $options['locale']); return new DatasourceItem($entity->getId(), $entity->getTitle(), $entity->getTitle()); }
/** * Creates a new collection. * * @param string $title * @param string $key * @param string $locale * @param int $userId * @param int|null $parent id of parent collection or null for root * @param int|null $id if not null a colleciton will be updated * * @return Collection */ private function createCollection($title, $key, $locale, $userId, $parent = null, $id = null) { $data = ['title' => $title, 'key' => $key, 'type' => ['id' => 2], 'locale' => $locale]; if ($parent !== null) { $data['parent'] = $parent; } if ($id !== null) { $data['id'] = $id; } return $this->collectionManager->save($data, $userId); }