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