Example #1
0
 /**
  * get options as key value pair
  *
  * @return array
  */
 public function toOptionArray()
 {
     if (is_null($this->options)) {
         $this->options = $this->countryCollectionFactory->create()->toOptionArray(' ');
     }
     return $this->options;
 }
Example #2
0
 /**
  * @param Author $author
  * @return string
  */
 public function getAuthorUrl(Author $author)
 {
     if ($urlKey = $author->getUrlKey()) {
         $prefix = $this->scopeConfig->getValue(self::URL_PREFIX_CONFIG_PATH, ScopeInterface::SCOPE_STORE);
         $suffix = $this->scopeConfig->getValue(self::URL_SUFFIX_CONFIG_PATH, ScopeInterface::SCOPE_STORE);
         $path = ($prefix ? $prefix . '/' : '') . $urlKey . ($suffix ? '.' . $suffix : '');
         return $this->urlBuilder->getUrl('', ['_direct' => $path]);
     }
     return $this->urlBuilder->getUrl('sample_news/author/view', ['id' => $author->getId()]);
 }
Example #3
0
 /**
  * @param AuthorModel $author
  *
  * @return array
  */
 public function getCategoryIds(AuthorModel $author)
 {
     $adapter = $this->getConnection();
     $select = $adapter->select()->from($this->authorCategoryTable, 'category_id')->where('author_id = ?', (int) $author->getId());
     return $adapter->fetchCol($select);
 }
Example #4
0
 /**
  * @param Author $author
  * @return $this
  */
 protected function doTheAction(Author $author)
 {
     $author->setIsActive($this->isActive);
     $author->save();
     return $this;
 }
Example #5
0
 /**
  * Add author id to error message
  *
  * @param Author $author
  * @param string $errorText
  * @return string
  */
 protected function getErrorWithAuthorId(Author $author, $errorText)
 {
     return '[Author ID: ' . $author->getId() . '] ' . $errorText;
 }
Example #6
0
 /**
  * @param $author
  * @return $this
  */
 protected function doTheAction(Author $author)
 {
     $author->delete();
     return $this;
 }