Blog\Model\Comment::getList PHP Метод

getList() публичный Метод

Return all comments in document
public getList ( integer $documentId = null, null | boolean $isActive = true ) : array
$documentId integer Document id
$isActive null | boolean Is active
Результат array
    public function getList($documentId = null, $isActive = true)
    {
        $driverName = $this->getDriverName();
        return $this->select(function (Select $select) use($documentId, $isActive, $driverName) {
            if (!empty($documentId)) {
                $select->where->equalTo('document_id', $documentId);
            }
            if (!is_null($isActive)) {
                if ($driverName == 'pdo_pgsql') {
                    $select->where->equalTo('is_active', empty($isActive) ? 'false' : 'true');
                } else {
                    $select->where->equalTo('is_active', (int) $isActive);
                }
            }
            $select->order('created_at ASC');
        })->toArray();
    }

Usage Example

Пример #1
0
 /**
  * Display widget dashboard
  *
  * @param \Zend\EventManager\EventInterface $event Event
  *
  * @return void
  */
 public function dashboard(Event $event)
 {
     $commentModel = new Comment();
     $unactiveCommentList = $commentModel->getList(null, false);
     $activeCommentList = $commentModel->getList(null, true);
     $widgets = $event->getParam('widgets');
     $widgets['blog']['id'] = 'blog';
     $widgets['blog']['title'] = 'Blog information';
     $widgets['blog']['content'] = $this->addPath(__DIR__ . '/views')->render('dashboard.phtml', array('unactiveComments' => count($unactiveCommentList), 'activeComments' => count($activeCommentList)));
     $event->setParam('widgets', $widgets);
 }
All Usage Examples Of Blog\Model\Comment::getList