Pimcore\Model\Document::getTotalCount PHP Method

getTotalCount() public static method

Get total count of documents.
public static getTotalCount ( array $config = [] ) : integer
$config array
return integer count
    public static function getTotalCount($config = [])
    {
        if (is_array($config)) {
            $listClass = "Pimcore\\Model\\Document\\Listing";
            $list = \Pimcore::getDiContainer()->make($listClass);
            $list->setValues($config);
            $count = $list->getTotalCount();
            return $count;
        }
    }

Usage Example

 /** Returns the total number of documents matching the given condition
  *  GET http://[YOUR-DOMAIN]/webservice/rest/asset-count?apikey=[API-KEY]&condition=type%3D%27folder%27
  *
  * Parameters:
  *      - condition
  *      - group by key
  */
 public function documentCountAction()
 {
     $this->checkUserPermission("documents");
     $condition = urldecode($this->getParam("condition"));
     $groupBy = $this->getParam("groupBy");
     $params = array();
     if (!empty($condition)) {
         $params["condition"] = $condition;
     }
     if (!empty($groupBy)) {
         $params["groupBy"] = $groupBy;
     }
     $count = Document::getTotalCount($params);
     $this->encoder->encode(array("success" => true, "data" => array("totalCount" => $count)));
 }