Sulu\Bundle\MediaBundle\Collection\Manager\CollectionManagerInterface::save PHP Method

save() public method

Creates a new collection or overrides an existing one.
public save ( array $data, integer $userId ) : Collection
$data array The data of the category to save
$userId integer The id of the user, who is doing this change
return Sulu\Bundle\MediaBundle\Api\Collection
    public function save($data, $userId);

Usage Example

示例#1
0
 /**
  * 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);
 }