discuss.answer
This would clear the site cache for you:
<?php
$cm = $modx->getCacheManager();
$cm->refresh();
Perfect! Thanks!
A related question: what will MODx return if any of these operations fail? Will the script die with an error or does each API call just return false? I want to make sure I properly handle errors.
getObject() will return null on failure (getCollection() returns an empty array on failure).
If getObject() fails and you don't have a sanity check, the first get() call will cause a fatal error (calling get() on a non-object).
If getObject() is successful, you can usually count on the the other methods working, though it's common to check the return value of the save() call (which will return true or false).
Thanks for the knowledge!
I bought your book and it's been quite helpful as well. Thanks!
Thanks for buying my book.