Updated generateContext to be quicker

Originally there was 2 getOption calls within the while loop. This doesn't display as a problem until a large amount of resources are pulled from the database.

By moving the getOption outside of the while loop and using the variable we see the generateContext() function speed up by about 100x.

With a resource tree of ~250,000 resources we saw about 1,600,000 calls to getOption, this new approach reduces that to 2.
Improved generateContext method to be quicker
Improved generateContext method to be quicker

* origin/master:
  Updated generateContext to be quicker