Exemple #1
0
 /**
  * Update current bookmark
  *
  * @param string $identifier
  * @return void
  */
 protected function updateCurrentBookmark($identifier)
 {
     $bookmarks = $this->bookmarkManagement->loadByNamespace($this->_request->getParam('namespace'));
     foreach ($bookmarks->getItems() as $bookmark) {
         if ($bookmark->getIdentifier() == $identifier) {
             $bookmark->setCurrent(true);
         } else {
             $bookmark->setCurrent(false);
         }
         $this->bookmarkRepository->save($bookmark);
     }
 }
Exemple #2
0
 /**
  * Update bookmarks based on request params
  *
  * @param BookmarkInterface $bookmark
  * @param string $identifier
  * @param string $title
  * @param array $config
  * @return void
  */
 protected function updateBookmark(BookmarkInterface $bookmark, $identifier, $title, array $config = [])
 {
     $this->filterVars($config);
     $bookmark->setUserId($this->userContext->getUserId())->setNamespace($this->_request->getParam('namespace'))->setIdentifier($identifier)->setTitle($title)->setConfig($config)->setCurrent($identifier !== self::CURRENT_IDENTIFIER);
     $this->bookmarkRepository->save($bookmark);
     $bookmarks = $this->bookmarkManagement->loadByNamespace($this->_request->getParam('namespace'));
     foreach ($bookmarks->getItems() as $bookmark) {
         if ($bookmark->getIdentifier() == $identifier) {
             continue;
         }
         $bookmark->setCurrent(false);
         $this->bookmarkRepository->save($bookmark);
     }
 }