public function generate()
 {
     $author_phid = $this->loadPhabrictorUserPHID();
     $author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $author_phid);
     $mock = PholioMock::initializeNewMock($author);
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_UNKNOWN, array());
     $template = id(new PholioTransaction())->setContentSource($content_source);
     // Accumulate Transactions
     $changes = array();
     $changes[PholioTransaction::TYPE_NAME] = $this->generateTitle();
     $changes[PholioTransaction::TYPE_DESCRIPTION] = $this->generateDescription();
     $changes[PhabricatorTransactions::TYPE_VIEW_POLICY] = PhabricatorPolicies::POLICY_PUBLIC;
     $changes[PhabricatorTransactions::TYPE_SUBSCRIBERS] = array('=' => $this->getCCPHIDs());
     // Get Files and make Images
     $file_phids = $this->generateImages();
     $files = id(new PhabricatorFileQuery())->setViewer($author)->withPHIDs($file_phids)->execute();
     $mock->setCoverPHID(head($files)->getPHID());
     $sequence = 0;
     $images = array();
     foreach ($files as $file) {
         $image = new PholioImage();
         $image->setFilePHID($file->getPHID());
         $image->setSequence($sequence++);
         $image->attachMock($mock);
         $images[] = $image;
     }
     // Apply Transactions
     $transactions = array();
     foreach ($changes as $type => $value) {
         $transaction = clone $template;
         $transaction->setTransactionType($type);
         $transaction->setNewValue($value);
         $transactions[] = $transaction;
     }
     $mock->openTransaction();
     $editor = id(new PholioMockEditor())->setContentSource($content_source)->setContinueOnNoEffect(true)->setActor($author)->applyTransactions($mock, $transactions);
     foreach ($images as $image) {
         $image->setMockID($mock->getID());
         $image->save();
     }
     $mock->saveTransaction();
     return $mock->save();
 }