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

canRemoveImageReference() protected method

Checks if image $path can be removed when deleting $versionNo and $fieldId.
protected canRemoveImageReference ( string $path, integer $versionNo, mixed $fieldId ) : boolean
$path string legacy image path (var/storage/images...)
$versionNo integer
$fieldId mixed
return boolean
    protected function canRemoveImageReference($path, $versionNo, $fieldId)
    {
        $connection = $this->getConnection();
        $selectQuery = $connection->createSelectQuery();
        $selectQuery->select($selectQuery->expr->count($connection->quoteColumn('id', 'ezcontentobject_attribute')))->from($connection->quoteTable('ezcontentobject_attribute'))->innerJoin($connection->quoteTable('ezimagefile'), $selectQuery->expr->eq($connection->quoteColumn('contentobject_attribute_id', 'ezimagefile'), $connection->quoteColumn('id', 'ezcontentobject_attribute')))->where($selectQuery->expr->lAnd($selectQuery->expr->eq($connection->quoteColumn('contentobject_attribute_id'), $selectQuery->bindValue($fieldId, null, \PDO::PARAM_INT)), $selectQuery->expr->neq($connection->quoteColumn('version'), $selectQuery->bindValue($versionNo, null, \PDO::PARAM_INT)), $selectQuery->expr->like($connection->quoteColumn('filepath'), $selectQuery->bindValue($path . '%'))));
        $statement = $selectQuery->prepare();
        $statement->execute();
        return (int) $statement->fetchColumn() === 0;
    }