Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13991035
D16368.id39367.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D16368.id39367.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2044,6 +2044,9 @@
'PhabricatorCalendarEventEndDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php',
'PhabricatorCalendarEventFrequencyTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventFrequencyTransaction.php',
'PhabricatorCalendarEventFulltextEngine' => 'applications/calendar/search/PhabricatorCalendarEventFulltextEngine.php',
+ 'PhabricatorCalendarEventHeraldAdapter' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php',
+ 'PhabricatorCalendarEventHeraldField' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldField.php',
+ 'PhabricatorCalendarEventHeraldFieldGroup' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldFieldGroup.php',
'PhabricatorCalendarEventHostPolicyRule' => 'applications/calendar/policyrule/PhabricatorCalendarEventHostPolicyRule.php',
'PhabricatorCalendarEventHostTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventHostTransaction.php',
'PhabricatorCalendarEventIconTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventIconTransaction.php',
@@ -2054,6 +2057,7 @@
'PhabricatorCalendarEventJoinController' => 'applications/calendar/controller/PhabricatorCalendarEventJoinController.php',
'PhabricatorCalendarEventListController' => 'applications/calendar/controller/PhabricatorCalendarEventListController.php',
'PhabricatorCalendarEventMailReceiver' => 'applications/calendar/mail/PhabricatorCalendarEventMailReceiver.php',
+ 'PhabricatorCalendarEventNameHeraldField' => 'applications/calendar/herald/PhabricatorCalendarEventNameHeraldField.php',
'PhabricatorCalendarEventNameTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventNameTransaction.php',
'PhabricatorCalendarEventPHIDType' => 'applications/calendar/phid/PhabricatorCalendarEventPHIDType.php',
'PhabricatorCalendarEventQuery' => 'applications/calendar/query/PhabricatorCalendarEventQuery.php',
@@ -6757,6 +6761,9 @@
'PhabricatorCalendarEventEndDateTransaction' => 'PhabricatorCalendarEventDateTransaction',
'PhabricatorCalendarEventFrequencyTransaction' => 'PhabricatorCalendarEventTransactionType',
'PhabricatorCalendarEventFulltextEngine' => 'PhabricatorFulltextEngine',
+ 'PhabricatorCalendarEventHeraldAdapter' => 'HeraldAdapter',
+ 'PhabricatorCalendarEventHeraldField' => 'HeraldField',
+ 'PhabricatorCalendarEventHeraldFieldGroup' => 'HeraldFieldGroup',
'PhabricatorCalendarEventHostPolicyRule' => 'PhabricatorPolicyRule',
'PhabricatorCalendarEventHostTransaction' => 'PhabricatorCalendarEventTransactionType',
'PhabricatorCalendarEventIconTransaction' => 'PhabricatorCalendarEventTransactionType',
@@ -6770,6 +6777,7 @@
'PhabricatorCalendarEventJoinController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventListController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventMailReceiver' => 'PhabricatorObjectMailReceiver',
+ 'PhabricatorCalendarEventNameHeraldField' => 'PhabricatorCalendarEventHeraldField',
'PhabricatorCalendarEventNameTransaction' => 'PhabricatorCalendarEventTransactionType',
'PhabricatorCalendarEventPHIDType' => 'PhabricatorPHIDType',
'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
@@ -289,5 +289,19 @@
return $body;
}
+ protected function shouldApplyHeraldRules(
+ PhabricatorLiskDAO $object,
+ array $xactions) {
+ return true;
+ }
+
+ protected function buildHeraldAdapter(
+ PhabricatorLiskDAO $object,
+ array $xactions) {
+
+ return id(new PhabricatorCalendarEventHeraldAdapter())
+ ->setObject($object);
+ }
+
}
diff --git a/src/applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php b/src/applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php
@@ -0,0 +1,56 @@
+<?php
+
+final class PhabricatorCalendarEventHeraldAdapter extends HeraldAdapter {
+
+ private $object;
+
+ public function getAdapterApplicationClass() {
+ return 'PhabricatorCalendarApplication';
+ }
+
+ public function getAdapterContentDescription() {
+ return pht('React to events being created or updated.');
+ }
+
+ protected function newObject() {
+ return new PhabricatorCalendarEvent();
+ }
+
+ public function isTestAdapterForObject($object) {
+ return ($object instanceof PhabricatorCalendarEvent);
+ }
+
+ public function getAdapterTestDescription() {
+ return pht(
+ 'Test rules which run when an event is created or updated.');
+ }
+
+ public function setObject($object) {
+ $this->object = $object;
+ return $this;
+ }
+
+ public function getObject() {
+ return $this->object;
+ }
+
+ public function getAdapterContentName() {
+ return pht('Calendar Events');
+ }
+
+ public function supportsRuleType($rule_type) {
+ switch ($rule_type) {
+ case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
+ case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
+ return true;
+ case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
+ default:
+ return false;
+ }
+ }
+
+ public function getHeraldName() {
+ return $this->getObject()->getMonogram();
+ }
+
+}
diff --git a/src/applications/calendar/herald/PhabricatorCalendarEventHeraldField.php b/src/applications/calendar/herald/PhabricatorCalendarEventHeraldField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/herald/PhabricatorCalendarEventHeraldField.php
@@ -0,0 +1,13 @@
+<?php
+
+abstract class PhabricatorCalendarEventHeraldField extends HeraldField {
+
+ public function supportsObject($object) {
+ return ($object instanceof PhabricatorCalendarEvent);
+ }
+
+ public function getFieldGroupKey() {
+ return PhabricatorCalendarEventHeraldFieldGroup::FIELDGROUPKEY;
+ }
+
+}
diff --git a/src/applications/calendar/herald/PhabricatorCalendarEventHeraldFieldGroup.php b/src/applications/calendar/herald/PhabricatorCalendarEventHeraldFieldGroup.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/herald/PhabricatorCalendarEventHeraldFieldGroup.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PhabricatorCalendarEventHeraldFieldGroup
+ extends HeraldFieldGroup {
+
+ const FIELDGROUPKEY = 'calendar.event';
+
+ public function getGroupLabel() {
+ return pht('Event Fields');
+ }
+
+ protected function getGroupOrder() {
+ return 1000;
+ }
+
+}
diff --git a/src/applications/calendar/herald/PhabricatorCalendarEventNameHeraldField.php b/src/applications/calendar/herald/PhabricatorCalendarEventNameHeraldField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/herald/PhabricatorCalendarEventNameHeraldField.php
@@ -0,0 +1,20 @@
+<?php
+
+final class PhabricatorCalendarEventNameHeraldField
+ extends PhabricatorCalendarEventHeraldField {
+
+ const FIELDCONST = 'calendar.event.name';
+
+ public function getHeraldFieldName() {
+ return pht('Name');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $object->getName();
+ }
+
+ protected function getHeraldFieldStandardType() {
+ return self::STANDARD_TEXT;
+ }
+
+}
diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -768,7 +768,10 @@
);
}
- abstract protected function initializeNewAdapter();
+ protected function initializeNewAdapter() {
+ $this->setObject($this->newObject());
+ return $this;
+ }
/**
* Does this adapter's event fire only once?
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 8:19 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6716511
Default Alt Text
D16368.id39367.diff (8 KB)
Attached To
Mode
D16368: Add basic Herald support to Calendar
Attached
Detach File
Event Timeline
Log In to Comment