eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway\LegacyStorage::countImageReferences PHP Method

countImageReferences() public method

Returns the number of recorded references to the given $path.
public countImageReferences ( string $uri ) : integer
$uri string File IO uri (not legacy)
return integer
    public function countImageReferences($uri)
    {
        $path = $this->redecorator->redecorateFromSource($uri);
        $connection = $this->getConnection();
        $selectQuery = $connection->createSelectQuery();
        $selectQuery->select($selectQuery->expr->count($connection->quoteColumn('id')))->from($connection->quoteTable('ezimagefile'))->where($selectQuery->expr->like($connection->quoteColumn('filepath'), $selectQuery->bindValue($path . '%')));
        $statement = $selectQuery->prepare();
        $statement->execute();
        return (int) $statement->fetchColumn();
    }