Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
Added observer function for custom fields (works better)
  • Loading branch information
Leonardo Pedretti committed Oct 13, 2017
1 parent 7a74ed9 commit 520bdaf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/Endpoints/BaseEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ public function getUri() { return $this->uri; }
*/
protected function request(string $method, $path = '', array $options = [])
{
$config = $this->di->get('config');

//TODO: replace with is_iterable() at PHP 7.1
//TODO: replace with is_iterable() at PHP 7.1
if (is_array($path) || $path instanceof \Traversable) {
return $this->requestMany($method, $path);
} else {
Expand All @@ -106,7 +104,7 @@ protected function request(string $method, $path = '', array $options = [])
$response = $this->client->$method("$this->uri/$path", $options);
} catch (\RuntimeException $e) {
// Log the error and the last request info
$logger = new FileLogger($config['application']['loggingDir'] . date("d_m_y") . "-pwintegration.log");
$logger = new FileLogger('/tmp/' . date("d_m_y") . "-pwintegration.log");
$error = "Exception " . $e->getMessage() . "\n";

$transaction = end(CRM::$container);
Expand Down
18 changes: 16 additions & 2 deletions src/SubResources/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CustomField
//those two are used by the PW API
public $custom_field_definition_id;
public $value;

//those two are just for consulting
protected $name;
protected $valueName;
Expand Down Expand Up @@ -113,5 +113,19 @@ public function __construct(string $idOrName, $value = null, $resource = null)
$this->value = $value;
}
}


public function getValue() {
if (count($this->options) > 0) {
if ($this->type == "MultiSelect") {
$values = [];
foreach ($this->value as $val) {
$values[] = $this->options[$val];
}
return $values;
}
return $this->options[$this->value];
} else {
return $this->value;
}
}
}

0 comments on commit 520bdaf

Please sign in to comment.