@@ -7,101 +7,101 @@ |
||
| 7 | 7 | class EmailMessagingService implements ConfirmationMessagingService |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @config |
|
| 12 | - * @var string |
|
| 13 | - */ |
|
| 14 | - private static $default_from = '[email protected]'; |
|
| 10 | + /** |
|
| 11 | + * @config |
|
| 12 | + * @var string |
|
| 13 | + */ |
|
| 14 | + private static $default_from = '[email protected]'; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @config |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - private static $default_subject = 'Deploynaut notification'; |
|
| 16 | + /** |
|
| 17 | + * @config |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + private static $default_subject = 'Deploynaut notification'; |
|
| 21 | 21 | |
| 22 | - public function sendMessage($source, $message, $recipients, $arguments = array()) |
|
| 23 | - { |
|
| 24 | - $from = empty($arguments['from']) |
|
| 25 | - ? Config::inst()->get(get_class($this), 'default_from') |
|
| 26 | - : $arguments['from']; |
|
| 27 | - $subject = empty($arguments['subject']) |
|
| 28 | - ? Config::inst()->get(get_class($this), 'default_subject') |
|
| 29 | - : $arguments['subject']; |
|
| 22 | + public function sendMessage($source, $message, $recipients, $arguments = array()) |
|
| 23 | + { |
|
| 24 | + $from = empty($arguments['from']) |
|
| 25 | + ? Config::inst()->get(get_class($this), 'default_from') |
|
| 26 | + : $arguments['from']; |
|
| 27 | + $subject = empty($arguments['subject']) |
|
| 28 | + ? Config::inst()->get(get_class($this), 'default_subject') |
|
| 29 | + : $arguments['subject']; |
|
| 30 | 30 | |
| 31 | - // Split users and send individually |
|
| 32 | - $this->sendIndividualMessages($source, $message, $recipients, $from, $subject); |
|
| 33 | - } |
|
| 31 | + // Split users and send individually |
|
| 32 | + $this->sendIndividualMessages($source, $message, $recipients, $from, $subject); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Separates recipients into individual users |
|
| 37 | - * |
|
| 38 | - * @param PipelineStep $source Source client step |
|
| 39 | - * @param string $message Plain text message |
|
| 40 | - * @param mixed $recipients Either a Member object, string, or array of strings or Member objects |
|
| 41 | - * @param string $from |
|
| 42 | - * @param string $subject |
|
| 43 | - * @return boolean True if success |
|
| 44 | - */ |
|
| 45 | - protected function sendIndividualMessages($source, $message, $recipients, $from, $subject) |
|
| 46 | - { |
|
| 47 | - // Split recipients that are comma separated |
|
| 48 | - if (is_string($recipients) && stripos($recipients, ',')) { |
|
| 49 | - $recipients = explode(',', $recipients); |
|
| 50 | - return $this->sendIndividualMessages($source, $message, $recipients, $from, $subject); |
|
| 51 | - } |
|
| 35 | + /** |
|
| 36 | + * Separates recipients into individual users |
|
| 37 | + * |
|
| 38 | + * @param PipelineStep $source Source client step |
|
| 39 | + * @param string $message Plain text message |
|
| 40 | + * @param mixed $recipients Either a Member object, string, or array of strings or Member objects |
|
| 41 | + * @param string $from |
|
| 42 | + * @param string $subject |
|
| 43 | + * @return boolean True if success |
|
| 44 | + */ |
|
| 45 | + protected function sendIndividualMessages($source, $message, $recipients, $from, $subject) |
|
| 46 | + { |
|
| 47 | + // Split recipients that are comma separated |
|
| 48 | + if (is_string($recipients) && stripos($recipients, ',')) { |
|
| 49 | + $recipients = explode(',', $recipients); |
|
| 50 | + return $this->sendIndividualMessages($source, $message, $recipients, $from, $subject); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - // Iterate through arrays |
|
| 54 | - if (is_array($recipients) || $recipients instanceof SS_List) { |
|
| 55 | - foreach ($recipients as $recipient) { |
|
| 56 | - $this->sendIndividualMessages($source, $message, $recipient, $from, $subject); |
|
| 57 | - } |
|
| 58 | - return true; |
|
| 59 | - } |
|
| 53 | + // Iterate through arrays |
|
| 54 | + if (is_array($recipients) || $recipients instanceof SS_List) { |
|
| 55 | + foreach ($recipients as $recipient) { |
|
| 56 | + $this->sendIndividualMessages($source, $message, $recipient, $from, $subject); |
|
| 57 | + } |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - if ($recipients) { |
|
| 62 | - $this->sendMessageTo($source, $from, $recipients, $subject, $message); |
|
| 63 | - return true; |
|
| 64 | - } |
|
| 61 | + if ($recipients) { |
|
| 62 | + $this->sendMessageTo($source, $from, $recipients, $subject, $message); |
|
| 63 | + return true; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // Can't send to empty recipient |
|
| 67 | - return false; |
|
| 68 | - } |
|
| 66 | + // Can't send to empty recipient |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Send an message to a single recipient |
|
| 73 | - * |
|
| 74 | - * @param PipelineStep $source Client step |
|
| 75 | - * @param string $from |
|
| 76 | - * @param string|Member $to |
|
| 77 | - * @param string $subject |
|
| 78 | - * @param string $body |
|
| 79 | - */ |
|
| 80 | - protected function sendMessageTo($source, $from, $to, $subject, $body) |
|
| 81 | - { |
|
| 82 | - if ($to instanceof Member) { |
|
| 83 | - $to = $to->Email; |
|
| 84 | - } |
|
| 85 | - $this->sendViaEmail($source, $from, $to, $subject, $body); |
|
| 86 | - } |
|
| 71 | + /** |
|
| 72 | + * Send an message to a single recipient |
|
| 73 | + * |
|
| 74 | + * @param PipelineStep $source Client step |
|
| 75 | + * @param string $from |
|
| 76 | + * @param string|Member $to |
|
| 77 | + * @param string $subject |
|
| 78 | + * @param string $body |
|
| 79 | + */ |
|
| 80 | + protected function sendMessageTo($source, $from, $to, $subject, $body) |
|
| 81 | + { |
|
| 82 | + if ($to instanceof Member) { |
|
| 83 | + $to = $to->Email; |
|
| 84 | + } |
|
| 85 | + $this->sendViaEmail($source, $from, $to, $subject, $body); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Send an email to a single recipient |
|
| 90 | - * |
|
| 91 | - * @param PipelineStep $source Client step |
|
| 92 | - * @param string $from |
|
| 93 | - * @param string $to |
|
| 94 | - * @param string $subject |
|
| 95 | - * @param string $body |
|
| 96 | - */ |
|
| 97 | - protected function sendViaEmail($source, $from, $to, $subject, $body) |
|
| 98 | - { |
|
| 99 | - $email = new Email($from, $to, $subject, $body); |
|
| 100 | - if ($source->getDryRun()) { |
|
| 101 | - $source->log("[Skipped] Sent message to $to (subject: $subject)"); |
|
| 102 | - } else { |
|
| 103 | - $email->sendPlain(); |
|
| 104 | - $source->log("Sent message to $to (subject: $subject)"); |
|
| 105 | - } |
|
| 106 | - } |
|
| 88 | + /** |
|
| 89 | + * Send an email to a single recipient |
|
| 90 | + * |
|
| 91 | + * @param PipelineStep $source Client step |
|
| 92 | + * @param string $from |
|
| 93 | + * @param string $to |
|
| 94 | + * @param string $subject |
|
| 95 | + * @param string $body |
|
| 96 | + */ |
|
| 97 | + protected function sendViaEmail($source, $from, $to, $subject, $body) |
|
| 98 | + { |
|
| 99 | + $email = new Email($from, $to, $subject, $body); |
|
| 100 | + if ($source->getDryRun()) { |
|
| 101 | + $source->log("[Skipped] Sent message to $to (subject: $subject)"); |
|
| 102 | + } else { |
|
| 103 | + $email->sendPlain(); |
|
| 104 | + $source->log("Sent message to $to (subject: $subject)"); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | } |
@@ -3,85 +3,85 @@ |
||
| 3 | 3 | class PipelineController extends Controller |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - private static $allowed_actions = array( |
|
| 7 | - 'abort', |
|
| 8 | - 'log', |
|
| 9 | - 'step' |
|
| 10 | - ); |
|
| 6 | + private static $allowed_actions = array( |
|
| 7 | + 'abort', |
|
| 8 | + 'log', |
|
| 9 | + 'step' |
|
| 10 | + ); |
|
| 11 | 11 | |
| 12 | - protected $controller = null; |
|
| 12 | + protected $controller = null; |
|
| 13 | 13 | |
| 14 | - protected $pipeline = null; |
|
| 14 | + protected $pipeline = null; |
|
| 15 | 15 | |
| 16 | - public function __construct($controller, Pipeline $pipeline) |
|
| 17 | - { |
|
| 18 | - $this->controller = $controller; |
|
| 19 | - parent::__construct(); |
|
| 20 | - $this->pipeline = $pipeline; |
|
| 21 | - } |
|
| 16 | + public function __construct($controller, Pipeline $pipeline) |
|
| 17 | + { |
|
| 18 | + $this->controller = $controller; |
|
| 19 | + parent::__construct(); |
|
| 20 | + $this->pipeline = $pipeline; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Shows status of this pipeline |
|
| 25 | - */ |
|
| 26 | - public function index() |
|
| 27 | - { |
|
| 28 | - return $this->controller->customise(new ArrayData(array( |
|
| 29 | - 'Pipeline' => $this->pipeline |
|
| 30 | - )))->renderWith('DNRoot_pipeline'); |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * Shows status of this pipeline |
|
| 25 | + */ |
|
| 26 | + public function index() |
|
| 27 | + { |
|
| 28 | + return $this->controller->customise(new ArrayData(array( |
|
| 29 | + 'Pipeline' => $this->pipeline |
|
| 30 | + )))->renderWith('DNRoot_pipeline'); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Get log for this pipeline |
|
| 35 | - */ |
|
| 36 | - public function log() |
|
| 37 | - { |
|
| 38 | - $log = $this->pipeline->getLogger(); |
|
| 39 | - if ($log->exists()) { |
|
| 40 | - $content = $log->content(); |
|
| 41 | - } else { |
|
| 42 | - $content = 'Waiting for action to start'; |
|
| 43 | - } |
|
| 33 | + /** |
|
| 34 | + * Get log for this pipeline |
|
| 35 | + */ |
|
| 36 | + public function log() |
|
| 37 | + { |
|
| 38 | + $log = $this->pipeline->getLogger(); |
|
| 39 | + if ($log->exists()) { |
|
| 40 | + $content = $log->content(); |
|
| 41 | + } else { |
|
| 42 | + $content = 'Waiting for action to start'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $sendJSON = (strpos($this->request->getHeader('Accept'), 'application/json') !== false) |
|
| 46 | - || $this->request->getExtension() == 'json'; |
|
| 45 | + $sendJSON = (strpos($this->request->getHeader('Accept'), 'application/json') !== false) |
|
| 46 | + || $this->request->getExtension() == 'json'; |
|
| 47 | 47 | |
| 48 | - $content = preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n", $content); |
|
| 49 | - if ($sendJSON) { |
|
| 50 | - $this->response->addHeader("Content-type", "application/json"); |
|
| 51 | - return json_encode(array( |
|
| 52 | - 'status' => $this->pipeline->Status, |
|
| 53 | - 'content' => $content, |
|
| 54 | - )); |
|
| 55 | - } else { |
|
| 56 | - $this->response->addHeader("Content-type", "text/plain"); |
|
| 57 | - return $content; |
|
| 58 | - } |
|
| 59 | - } |
|
| 48 | + $content = preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n", $content); |
|
| 49 | + if ($sendJSON) { |
|
| 50 | + $this->response->addHeader("Content-type", "application/json"); |
|
| 51 | + return json_encode(array( |
|
| 52 | + 'status' => $this->pipeline->Status, |
|
| 53 | + 'content' => $content, |
|
| 54 | + )); |
|
| 55 | + } else { |
|
| 56 | + $this->response->addHeader("Content-type", "text/plain"); |
|
| 57 | + return $content; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Aborts the current pipeline |
|
| 63 | - */ |
|
| 64 | - public function abort() |
|
| 65 | - { |
|
| 66 | - if ($this->pipeline->canAbort()) { |
|
| 67 | - $this->pipeline->markAborted(); |
|
| 68 | - } |
|
| 69 | - return $this->redirect($this->pipeline->Environment()->Link()); |
|
| 70 | - } |
|
| 61 | + /** |
|
| 62 | + * Aborts the current pipeline |
|
| 63 | + */ |
|
| 64 | + public function abort() |
|
| 65 | + { |
|
| 66 | + if ($this->pipeline->canAbort()) { |
|
| 67 | + $this->pipeline->markAborted(); |
|
| 68 | + } |
|
| 69 | + return $this->redirect($this->pipeline->Environment()->Link()); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Perform an action on the current pipeline step |
|
| 74 | - */ |
|
| 75 | - public function step() |
|
| 76 | - { |
|
| 77 | - $action = $this->request->param('ID'); |
|
| 78 | - $step = $this->pipeline->CurrentStep(); |
|
| 72 | + /** |
|
| 73 | + * Perform an action on the current pipeline step |
|
| 74 | + */ |
|
| 75 | + public function step() |
|
| 76 | + { |
|
| 77 | + $action = $this->request->param('ID'); |
|
| 78 | + $step = $this->pipeline->CurrentStep(); |
|
| 79 | 79 | |
| 80 | - // Check if the action is available on this step |
|
| 81 | - if ($step && ($actions = $step->allowedActions()) && isset($actions[$action])) { |
|
| 82 | - // Execute this action, allowing it to override the httpresponse given |
|
| 83 | - $step->$action(); |
|
| 84 | - } |
|
| 85 | - return $this->redirect($this->pipeline->Environment()->Link()); |
|
| 86 | - } |
|
| 80 | + // Check if the action is available on this step |
|
| 81 | + if ($step && ($actions = $step->allowedActions()) && isset($actions[$action])) { |
|
| 82 | + // Execute this action, allowing it to override the httpresponse given |
|
| 83 | + $step->$action(); |
|
| 84 | + } |
|
| 85 | + return $this->redirect($this->pipeline->Environment()->Link()); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -3,29 +3,29 @@ |
||
| 3 | 3 | class GitSHA extends Varchar |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - /** |
|
| 7 | - * @param string|null $name |
|
| 8 | - * @param array $options |
|
| 9 | - */ |
|
| 10 | - public function __construct($name = null, $options = array()) |
|
| 11 | - { |
|
| 12 | - // Size should probably be 40, but to avoid schema change leave for now |
|
| 13 | - parent::__construct($name, 255, $options); |
|
| 14 | - } |
|
| 6 | + /** |
|
| 7 | + * @param string|null $name |
|
| 8 | + * @param array $options |
|
| 9 | + */ |
|
| 10 | + public function __construct($name = null, $options = array()) |
|
| 11 | + { |
|
| 12 | + // Size should probably be 40, but to avoid schema change leave for now |
|
| 13 | + parent::__construct($name, 255, $options); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @return string |
|
| 18 | - */ |
|
| 19 | - public function FullHash() |
|
| 20 | - { |
|
| 21 | - return $this->value; |
|
| 22 | - } |
|
| 16 | + /** |
|
| 17 | + * @return string |
|
| 18 | + */ |
|
| 19 | + public function FullHash() |
|
| 20 | + { |
|
| 21 | + return $this->value; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function ShortHash() |
|
| 28 | - { |
|
| 29 | - return substr($this->value, 0, 7); |
|
| 30 | - } |
|
| 24 | + /** |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function ShortHash() |
|
| 28 | + { |
|
| 29 | + return substr($this->value, 0, 7); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -3,29 +3,29 @@ |
||
| 3 | 3 | interface DeploynautEventInterface extends \League\Event\EventInterface |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - /** |
|
| 7 | - * Should return the event name, e.g 'event.name' |
|
| 8 | - * |
|
| 9 | - * @return string |
|
| 10 | - */ |
|
| 11 | - public function getName(); |
|
| 6 | + /** |
|
| 7 | + * Should return the event name, e.g 'event.name' |
|
| 8 | + * |
|
| 9 | + * @return string |
|
| 10 | + */ |
|
| 11 | + public function getName(); |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Get the value for the $keyname or empty string |
|
| 15 | - * |
|
| 16 | - * @param string $keyname |
|
| 17 | - * |
|
| 18 | - * @return string |
|
| 19 | - */ |
|
| 20 | - public function get($keyname); |
|
| 13 | + /** |
|
| 14 | + * Get the value for the $keyname or empty string |
|
| 15 | + * |
|
| 16 | + * @param string $keyname |
|
| 17 | + * |
|
| 18 | + * @return string |
|
| 19 | + */ |
|
| 20 | + public function get($keyname); |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @return array |
|
| 24 | - */ |
|
| 25 | - public function asArray(); |
|
| 22 | + /** |
|
| 23 | + * @return array |
|
| 24 | + */ |
|
| 25 | + public function asArray(); |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @return string - returns the data as json |
|
| 29 | - */ |
|
| 30 | - public function asJSON(); |
|
| 27 | + /** |
|
| 28 | + * @return string - returns the data as json |
|
| 29 | + */ |
|
| 30 | + public function asJSON(); |
|
| 31 | 31 | } |
@@ -23,83 +23,83 @@ |
||
| 23 | 23 | class GenericEvent extends AbstractEvent implements DeploynautEventInterface |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - protected $name = ''; |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + protected $name = ''; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - protected $data = []; |
|
| 31 | + /** |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + protected $data = []; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param string $name - event name |
|
| 38 | - * @param array $data |
|
| 39 | - * |
|
| 40 | - * @return GenericEvent |
|
| 41 | - */ |
|
| 42 | - public static function create($name, array $data) |
|
| 43 | - { |
|
| 44 | - return Injector::inst()->createWithArgs(get_called_class(), [$name, $data]); |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * @param string $name - event name |
|
| 38 | + * @param array $data |
|
| 39 | + * |
|
| 40 | + * @return GenericEvent |
|
| 41 | + */ |
|
| 42 | + public static function create($name, array $data) |
|
| 43 | + { |
|
| 44 | + return Injector::inst()->createWithArgs(get_called_class(), [$name, $data]); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Event constructor |
|
| 49 | - * |
|
| 50 | - * @param string $eventName - e.g. 'event.name' |
|
| 51 | - * @param array $data |
|
| 52 | - */ |
|
| 53 | - public function __construct($eventName, array $data) |
|
| 54 | - { |
|
| 55 | - $this->name = $eventName; |
|
| 56 | - $this->data = $data; |
|
| 57 | - } |
|
| 47 | + /** |
|
| 48 | + * Event constructor |
|
| 49 | + * |
|
| 50 | + * @param string $eventName - e.g. 'event.name' |
|
| 51 | + * @param array $data |
|
| 52 | + */ |
|
| 53 | + public function __construct($eventName, array $data) |
|
| 54 | + { |
|
| 55 | + $this->name = $eventName; |
|
| 56 | + $this->data = $data; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * get the event name, e.g 'event.name' |
|
| 61 | - * |
|
| 62 | - * @return string |
|
| 63 | - */ |
|
| 64 | - public function getName() |
|
| 65 | - { |
|
| 66 | - return $this->name; |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * get the event name, e.g 'event.name' |
|
| 61 | + * |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 64 | + public function getName() |
|
| 65 | + { |
|
| 66 | + return $this->name; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Get the value for the $keyname or empty string |
|
| 71 | - * |
|
| 72 | - * @param string $keyname |
|
| 73 | - * |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 76 | - public function get($keyname) |
|
| 77 | - { |
|
| 78 | - if (array_key_exists($keyname, $this->data)) { |
|
| 79 | - return $this->data[$keyname]; |
|
| 80 | - } |
|
| 81 | - return ''; |
|
| 82 | - } |
|
| 69 | + /** |
|
| 70 | + * Get the value for the $keyname or empty string |
|
| 71 | + * |
|
| 72 | + * @param string $keyname |
|
| 73 | + * |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | + public function get($keyname) |
|
| 77 | + { |
|
| 78 | + if (array_key_exists($keyname, $this->data)) { |
|
| 79 | + return $this->data[$keyname]; |
|
| 80 | + } |
|
| 81 | + return ''; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * return all the data as an array, including the event name as 'event'; |
|
| 86 | - * |
|
| 87 | - * @return array |
|
| 88 | - */ |
|
| 89 | - public function asArray() |
|
| 90 | - { |
|
| 91 | - $payload = $this->data; |
|
| 92 | - $payload['event'] = $this->getName(); |
|
| 93 | - return $payload; |
|
| 94 | - } |
|
| 84 | + /** |
|
| 85 | + * return all the data as an array, including the event name as 'event'; |
|
| 86 | + * |
|
| 87 | + * @return array |
|
| 88 | + */ |
|
| 89 | + public function asArray() |
|
| 90 | + { |
|
| 91 | + $payload = $this->data; |
|
| 92 | + $payload['event'] = $this->getName(); |
|
| 93 | + return $payload; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * return all the data as a JSON string, including the event name as 'event'; |
|
| 98 | - * |
|
| 99 | - * @return string - returns the data as json |
|
| 100 | - */ |
|
| 101 | - public function asJSON() |
|
| 102 | - { |
|
| 103 | - return json_encode($this->asArray()); |
|
| 104 | - } |
|
| 96 | + /** |
|
| 97 | + * return all the data as a JSON string, including the event name as 'event'; |
|
| 98 | + * |
|
| 99 | + * @return string - returns the data as json |
|
| 100 | + */ |
|
| 101 | + public function asJSON() |
|
| 102 | + { |
|
| 103 | + return json_encode($this->asArray()); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class DeploynautFileExtension extends DataExtension |
| 3 | 3 | { |
| 4 | - /** |
|
| 5 | - * If this file is attached to a {@link DNDataArchive}, then we need to check security permissions, to ensure the |
|
| 6 | - * currently logged in {@link Member} can download the file. |
|
| 7 | - * |
|
| 8 | - * This uses the secureassets module to provide the security of these assets. |
|
| 9 | - */ |
|
| 10 | - public function canDownload() |
|
| 11 | - { |
|
| 12 | - $member = Member::currentUser(); |
|
| 13 | - $file = $this->owner; |
|
| 14 | - $archive = DNDataArchive::get()->filter('ArchiveFileID', $file->ID)->First(); |
|
| 4 | + /** |
|
| 5 | + * If this file is attached to a {@link DNDataArchive}, then we need to check security permissions, to ensure the |
|
| 6 | + * currently logged in {@link Member} can download the file. |
|
| 7 | + * |
|
| 8 | + * This uses the secureassets module to provide the security of these assets. |
|
| 9 | + */ |
|
| 10 | + public function canDownload() |
|
| 11 | + { |
|
| 12 | + $member = Member::currentUser(); |
|
| 13 | + $file = $this->owner; |
|
| 14 | + $archive = DNDataArchive::get()->filter('ArchiveFileID', $file->ID)->First(); |
|
| 15 | 15 | |
| 16 | - if ($archive) { |
|
| 17 | - return $archive->canDownload($member); |
|
| 18 | - } |
|
| 16 | + if ($archive) { |
|
| 17 | + return $archive->canDownload($member); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - return true; // By default, files can be downloaded from assets/ normally |
|
| 21 | - } |
|
| 20 | + return true; // By default, files can be downloaded from assets/ normally |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -3,13 +3,13 @@ |
||
| 3 | 3 | class DeploynautSecurityExtension extends Extension |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - public function onAfterInit() |
|
| 7 | - { |
|
| 8 | - // the 'ping' action is called via AJAX from the /admin and will cause |
|
| 9 | - // the admin section to 'grow' over time. We only need the css and js |
|
| 10 | - // for login, reset, logout and so on. |
|
| 11 | - if (!$this->owner->getRequest()->isAjax()) { |
|
| 12 | - DNRoot::include_requirements(); |
|
| 13 | - } |
|
| 14 | - } |
|
| 6 | + public function onAfterInit() |
|
| 7 | + { |
|
| 8 | + // the 'ping' action is called via AJAX from the /admin and will cause |
|
| 9 | + // the admin section to 'grow' over time. We only need the css and js |
|
| 10 | + // for login, reset, logout and so on. |
|
| 11 | + if (!$this->owner->getRequest()->isAjax()) { |
|
| 12 | + DNRoot::include_requirements(); |
|
| 13 | + } |
|
| 14 | + } |
|
| 15 | 15 | } |
@@ -3,15 +3,15 @@ |
||
| 3 | 3 | class FrontendLink extends DataExtension |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - public function updateItemEditForm($form) |
|
| 7 | - { |
|
| 8 | - if ($this->owner->record->hasMethod('Link')) { |
|
| 9 | - $link = sprintf( |
|
| 10 | - '<a style="margin: 0.5em" target="deploynaut-frontend" href="%s">Preview »</a>', |
|
| 11 | - $this->owner->record->Link() |
|
| 12 | - ); |
|
| 13 | - $actions = $form->Actions(); |
|
| 14 | - $actions->push(LiteralField::create('FrontendLink', $link)); |
|
| 15 | - } |
|
| 16 | - } |
|
| 6 | + public function updateItemEditForm($form) |
|
| 7 | + { |
|
| 8 | + if ($this->owner->record->hasMethod('Link')) { |
|
| 9 | + $link = sprintf( |
|
| 10 | + '<a style="margin: 0.5em" target="deploynaut-frontend" href="%s">Preview »</a>', |
|
| 11 | + $this->owner->record->Link() |
|
| 12 | + ); |
|
| 13 | + $actions = $form->Actions(); |
|
| 14 | + $actions->push(LiteralField::create('FrontendLink', $link)); |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | } |
@@ -3,10 +3,10 @@ |
||
| 3 | 3 | class ProjectMemberExtension extends DataExtension |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - /** |
|
| 7 | - * @var array |
|
| 8 | - */ |
|
| 9 | - private static $belongs_many_many = array( |
|
| 10 | - 'StarredProjects' => 'DNProject' |
|
| 11 | - ); |
|
| 6 | + /** |
|
| 7 | + * @var array |
|
| 8 | + */ |
|
| 9 | + private static $belongs_many_many = array( |
|
| 10 | + 'StarredProjects' => 'DNProject' |
|
| 11 | + ); |
|
| 12 | 12 | } |