Beispiel #1
0
 /**
  * Add news category
  *
  * @param array $category
  * @return integer
  */
 public function add(array $category)
 {
     $repo = $this->store()->getRepository('news_category');
     $repo->appendLockTables(['tbl_user']);
     if (isset($category['USER_ID'])) {
         $user_id = intval($category['USER_ID']);
         $user = User::finder()->filter(['ID' => $user_id])->count();
         if ($user == 0) {
             throw new \RuntimeException('User is not found');
         }
     }
     $entity = new NewsCategoryEntity();
     $entity->setData($category);
     return $this->store()->add($repo, $entity);
 }
Beispiel #2
0
 /**
  * Return finder
  *
  * @return \BX\DB\Filter\SqlBuilder
  */
 public function getFinder()
 {
     return self::finder(NewsCategoryEntity::getClass());
 }