...a cure is not perfect unless it maintains health once restored. In the strife of the battle [of this life], spiritual health may be maintained nowhere but in the ranks of the Church, 'terrible as an army set in array', and this is because of the armament of its sevenfold grace. This is why there have to be seven sacraments. Since this army consists of elements that are subject to weakening, in order that the ranks be perfectly and permanently strengthened, it needs sacraments to fortify, relieve, and replenish its members: to fortify the combatants, relieve the wounded, and replenish the dying....
And so Baptism is designed for those just entering the fight, Confirmation for those engaged in combat, the Eucharist for those refreshing their strength, Penance for those rising from their sickbeds, Extreme Unction for those who are departing, Orders for those who break in the new recruits, and Matrimony for those who provide these recruits.
[St. Bonaventure, Breviloquium, Monti, ed. and tr., Franciscan Institute Publications (St. Bonaventure, NY: 2005) pp. 220-221. The quotation is from Song of Songs, of course.]
According to the editors, Bonaventure is deriving this scheme from Peter of Poitiers, about whom I know nothing except that he has a reputation for complicated and subtle argumentation and that he has to be distinguished from several other people of the same name. But the notion of sacraments as armaments may well have been strengthened by a number of comments by Hugh of Saint Victor in his De Sacramentis, one of the most influential treatises of sacramental theology in the medieval period [Hugh of St. Victor, On the Sacraments of the Christian Faith, Deferrari, tr., Ex Fontibus (2016)]:
So there are three things simultaneously, faith, sacrament, and work. In faith, fortitude is attributed to the Christian, in the sacraments, arms; in good works, weapons for him who is to fight against the devil. (I.IX.VIII, p. 165)
Now, that in this battle he may be able to stand unconquered and guard his good unharmed, there are given him, as it is said, arms in the sacraments with which he may fortify himself, missiles in good works with which he may lay the enemy low, so that with love of faith and with hope combined he may meanwhile both be strengthened and live. (I.X.IX, p. 182)