Page MenuHomePhabricator

How dangerous is this edit engine extension?
Closed, ResolvedPublic

Asked by yelirekim on Feb 15 2016, 3:53 PM.

Details

I've swiftly begun work subverting the intentions of edit engine with this extension. Owners already has an edit field called "owners" on it, and our extension here provides a field with the same name, of the same type, except it's locked so people can't edit it! How great.

I'm wondering how dangerous this is in terms of what engine extensions were conceived to be able to do. Is this one of the things they can safely do, or have I done something really bad?

1<?php
2
3final class CIEnforcementEngineExtension extends PhabricatorEditEngineExtension {
4
5 const EXTENSIONKEY = 'enforcement.owners';
6
7 public function isExtensionEnabled() {
8 return true;
9 }
10
11 public function getExtensionName() {
12 return pht('Enforcement Policies');
13 }
14
15 public function supportsObject(
16 PhabricatorEditEngine $engine,
17 PhabricatorApplicationTransactionInterface $object) {
18
19 return
20 $engine instanceof PhabricatorOwnersPackageEditEngine &&
21 $object instanceof PhabricatorOwnersPackage;
22
23 }
24
25 public function buildCustomEditFields(
26 PhabricatorEditEngine $engine,
27 PhabricatorApplicationTransactionInterface $object) {
28
29 return [
30 id(new PhabricatorDatasourceEditField())
31 ->setKey('owners')
32 ->setLabel(pht('Enforced Owners'))
33 ->setDescription(pht('Users and projects which own the package.'))
34 ->setIsLocked(true)
35 ->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_OWNERS)
36 ->setDatasource(new PhabricatorProjectOrUserDatasource())
37 ->setIsCopyable(true)
38 ->setValue($object->getOwnerPHIDs()),
39 ];
40 }
41
42}

Answers

epriestley
Updated 2,986 Days Ago

This will probably start throwing an exception once I do this by mistake myself.

The expectation is that you can lock the field from the web UI: OwnersCreate PackageConfigure FormEdit Form ConfigurationLock / Hide FieldsOwners: Locked.

Is there a reason that doesn't work in your case?

New Answer

Answer

This question has been marked as closed, but you can still leave a new answer.