本文整理汇总了PHP中PhabricatorDestructionEngine类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorDestructionEngine类的具体用法?PHP PhabricatorDestructionEngine怎么用?PHP PhabricatorDestructionEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorDestructionEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyExternalEffects
public function applyExternalEffects($object, $value)
{
$events = id(new PhabricatorCalendarEventQuery())->setViewer($this->getActor())->withImportSourcePHIDs(array($object->getPHID()))->execute();
$engine = new PhabricatorDestructionEngine();
foreach ($events as $event) {
$engine->destroyObject($event);
}
}
示例2: deleteFile
public function deleteFile($handle)
{
$engine = new PhabricatorDestructionEngine();
$chunks = $this->loadAllChunks($handle, true);
foreach ($chunks as $chunk) {
$engine->destroyObject($chunk);
}
}
示例3: destroyObjectPermanently
public function destroyObjectPermanently(PhabricatorDestructionEngine $engine)
{
$bindings = id(new AlmanacBindingQuery())->setViewer($engine->getViewer())->withInterfacePHIDs(array($this->getPHID()))->execute();
foreach ($bindings as $binding) {
$engine->destroyObject($binding);
}
$this->delete();
}
示例4: destroyObject
public function destroyObject(PhabricatorDestructionEngine $engine, $object)
{
$template = $object->getApplicationTransactionTemplate();
$xactions = $template->loadAllWhere('objectPHID = %s', $object->getPHID());
foreach ($xactions as $xaction) {
$engine->destroyObject($xaction);
}
}
示例5: destroyObjectPermanently
public function destroyObjectPermanently(PhabricatorDestructionEngine $engine)
{
$interfaces = id(new AlmanacInterfaceQuery())->setViewer($engine->getViewer())->withNetworkPHIDs(array($this->getPHID()))->execute();
foreach ($interfaces as $interface) {
$engine->destroyObject($interface);
}
$this->delete();
}
示例6: destroyObject
public function destroyObject(PhabricatorDestructionEngine $engine, $object)
{
$object_phid = $object->getPHID();
$transcripts = id(new HeraldTranscript())->loadAllWhere('objectPHID = %s', $object_phid);
foreach ($transcripts as $transcript) {
$engine->destroyObject($transcript);
}
}
示例7: destroyObjectPermanently
public function destroyObjectPermanently(PhabricatorDestructionEngine $engine)
{
$file_phid = $this->getFilePHID();
$file = id(new PhabricatorFileQuery())->setViewer($engine->getViewer())->withPHIDs(array($file_phid))->executeOne();
if ($file) {
$engine->destroyObject($file);
}
$this->delete();
}
示例8: collectGarbage
protected function collectGarbage()
{
$file_requests = id(new PhabricatorFileExternalRequest())->loadAllWhere('ttl < %d LIMIT 100', PhabricatorTime::getNow());
$engine = new PhabricatorDestructionEngine();
foreach ($file_requests as $request) {
$engine->destroyObject($request);
}
return count($file_requests) == 100;
}
示例9: destroyObjectPermanently
public function destroyObjectPermanently(PhabricatorDestructionEngine $engine)
{
$viewer = $engine->getViewer();
$this->openTransaction();
$packages = id(new PhabricatorPackagesPackageQuery())->setViewer($viewer)->withPublisherPHIDs(array($this->getPHID()))->execute();
foreach ($packages as $package) {
$engine->destroyObject($package);
}
$this->delete();
$this->saveTransaction();
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$show_prototypes = PhabricatorEnv::getEnvConfig('phabricator.show-prototypes');
if (!$show_prototypes) {
throw new Exception(pht('Show prototypes is disabled.
Set `phabricator.show-prototypes` to `true` to use the image proxy'));
}
$viewer = $request->getViewer();
$img_uri = $request->getStr('uri');
// Validate the URI before doing anything
PhabricatorEnv::requireValidRemoteURIForLink($img_uri);
$uri = new PhutilURI($img_uri);
$proto = $uri->getProtocol();
if (!in_array($proto, array('http', 'https'))) {
throw new Exception(pht('The provided image URI must be either http or https'));
}
// Check if we already have the specified image URI downloaded
$cached_request = id(new PhabricatorFileExternalRequest())->loadOneWhere('uriIndex = %s', PhabricatorHash::digestForIndex($img_uri));
if ($cached_request) {
return $this->getExternalResponse($cached_request);
}
$ttl = PhabricatorTime::getNow() + phutil_units('7 days in seconds');
$external_request = id(new PhabricatorFileExternalRequest())->setURI($img_uri)->setTTL($ttl);
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
// Cache missed so we'll need to validate and download the image
try {
// Rate limit outbound fetches to make this mechanism less useful for
// scanning networks and ports.
PhabricatorSystemActionEngine::willTakeAction(array($viewer->getPHID()), new PhabricatorFilesOutboundRequestAction(), 1);
$file = PhabricatorFile::newFromFileDownload($uri, array('viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'canCDN' => true));
if (!$file->isViewableImage()) {
$mime_type = $file->getMimeType();
$engine = new PhabricatorDestructionEngine();
$engine->destroyObject($file);
$file = null;
throw new Exception(pht('The URI "%s" does not correspond to a valid image file, got ' . 'a file with MIME type "%s". You must specify the URI of a ' . 'valid image file.', $uri, $mime_type));
} else {
$file->save();
}
$external_request->setIsSuccessful(true)->setFilePHID($file->getPHID())->save();
unset($unguarded);
return $this->getExternalResponse($external_request);
} catch (HTTPFutureHTTPResponseStatus $status) {
$external_request->setIsSuccessful(false)->setResponseMessage($status->getMessage())->save();
return $this->getExternalResponse($external_request);
} catch (Exception $ex) {
// Not actually saving the request in this case
$external_request->setResponseMessage($ex->getMessage());
return $this->getExternalResponse($external_request);
}
}
示例11: destroyObjectPermanently
public function destroyObjectPermanently(PhabricatorDestructionEngine $engine)
{
$this->openTransaction();
$atoms = id(new DivinerAtomQuery())->setViewer($engine->getViewer())->withBookPHIDs(array($this->getPHID()))->execute();
foreach ($atoms as $atom) {
$engine->destroyObject($atom);
}
$this->delete();
$this->saveTransaction();
}
示例12: returnDeleteAddressResponse
private function returnDeleteAddressResponse(AphrontRequest $request, PhutilURI $uri, $email_object_id)
{
$viewer = $this->getViewer();
$email_object = id(new PhabricatorMetaMTAApplicationEmailQuery())->setViewer($viewer)->withIDs(array($email_object_id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$email_object) {
return new Aphront404Response();
}
if ($request->isDialogFormPost()) {
$engine = new PhabricatorDestructionEngine();
$engine->destroyObject($email_object);
return id(new AphrontRedirectResponse())->setURI($uri);
}
$dialog = id(new AphrontDialogView())->setUser($viewer)->addHiddenInput('delete', $email_object_id)->setTitle(pht('Delete Address'))->appendParagraph(pht('Are you sure you want to delete this email address?'))->addSubmitButton(pht('Delete'))->addCancelButton($uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例13: applyFinalEffects
protected function applyFinalEffects(PhabricatorLiskDAO $object, array $xactions)
{
$actor = $this->getActor();
// We import events when you create a source, or if you later reload it
// explicitly.
$should_reload = $this->getIsNewObject();
// We adjust the import trigger if you change the import frequency or
// disable the import.
$should_trigger = false;
foreach ($xactions as $xaction) {
$xaction_type = $xaction->getTransactionType();
switch ($xaction_type) {
case PhabricatorCalendarImportReloadTransaction::TRANSACTIONTYPE:
$should_reload = true;
break;
case PhabricatorCalendarImportFrequencyTransaction::TRANSACTIONTYPE:
$should_trigger = true;
break;
case PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE:
$should_trigger = true;
break;
}
}
if ($should_reload) {
$import_engine = $object->getEngine();
$import_engine->importEventsFromSource($actor, $object, true);
}
if ($should_trigger) {
$trigger_phid = $object->getTriggerPHID();
if ($trigger_phid) {
$trigger = id(new PhabricatorWorkerTriggerQuery())->setViewer($actor)->withPHIDs(array($trigger_phid))->executeOne();
if ($trigger) {
$engine = new PhabricatorDestructionEngine();
$engine->destroyObject($trigger);
}
}
$frequency = $object->getTriggerFrequency();
$now = PhabricatorTime::getNow();
switch ($frequency) {
case PhabricatorCalendarImport::FREQUENCY_ONCE:
$clock = null;
break;
case PhabricatorCalendarImport::FREQUENCY_HOURLY:
$clock = new PhabricatorMetronomicTriggerClock(array('period' => phutil_units('1 hour in seconds')));
break;
case PhabricatorCalendarImport::FREQUENCY_DAILY:
$clock = new PhabricatorDailyRoutineTriggerClock(array('start' => $now));
break;
default:
throw new Exception(pht('Unknown import trigger frequency "%s".', $frequency));
}
// If the object has been disabled, don't write a new trigger.
if ($object->getIsDisabled()) {
$clock = null;
}
if ($clock) {
$trigger_action = new PhabricatorScheduleTaskTriggerAction(array('class' => 'PhabricatorCalendarImportReloadWorker', 'data' => array('importPHID' => $object->getPHID(), 'via' => PhabricatorCalendarImportReloadWorker::VIA_TRIGGER), 'options' => array('objectPHID' => $object->getPHID(), 'priority' => PhabricatorWorker::PRIORITY_BULK)));
$trigger_phid = PhabricatorPHID::generateNewPHID(PhabricatorWorkerTriggerPHIDType::TYPECONST);
$object->setTriggerPHID($trigger_phid)->save();
$trigger = id(new PhabricatorWorkerTrigger())->setClock($clock)->setAction($trigger_action)->setPHID($trigger_phid)->save();
} else {
$object->setTriggerPHID(null)->save();
}
}
return $xactions;
}
示例14: destroyObjectPermanently
public function destroyObjectPermanently(PhabricatorDestructionEngine $engine)
{
$phid = $this->getPHID();
$this->openTransaction();
$this->delete();
PhabricatorRepositoryURIIndex::updateRepositoryURIs($phid, array());
$books = id(new DivinerBookQuery())->setViewer($engine->getViewer())->withRepositoryPHIDs(array($phid))->execute();
foreach ($books as $book) {
$engine->destroyObject($book);
}
$atoms = id(new DivinerAtomQuery())->setViewer($engine->getViewer())->withRepositoryPHIDs(array($phid))->execute();
foreach ($atoms as $atom) {
$engine->destroyObject($atom);
}
$lfs_refs = id(new PhabricatorRepositoryGitLFSRefQuery())->setViewer($engine->getViewer())->withRepositoryPHIDs(array($phid))->execute();
foreach ($lfs_refs as $ref) {
$engine->destroyObject($ref);
}
$this->saveTransaction();
}
示例15: destroyTransform
private function destroyTransform(PhabricatorTransformedFile $xform)
{
$engine = new PhabricatorDestructionEngine();
$file = id(new PhabricatorFileQuery())->setViewer($engine->getViewer())->withPHIDs(array($xform->getTransformedPHID()))->executeOne();
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
if (!$file) {
if ($xform->getID()) {
$xform->delete();
}
} else {
$engine->destroyObject($file);
}
unset($unguarded);
}