Pimcore\Model\Asset::getTotalCount PHP Method

getTotalCount() public static method

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

Usage Example

コード例 #1
0
 /** Returns the total number of assets 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 assetCountAction()
 {
     $this->checkUserPermission("assets");
     $condition = urldecode($this->getParam("condition"));
     $groupBy = $this->getParam("groupBy");
     $params = array();
     if (!empty($condition)) {
         $params["condition"] = $condition;
     }
     if (!empty($groupBy)) {
         $params["groupBy"] = $groupBy;
     }
     $count = Asset::getTotalCount($params);
     $this->encoder->encode(array("success" => true, "data" => array("totalCount" => $count)));
 }