/** * Returns this user as a GenericUser * * @param \stdClass|array $profile * * @throws \DreamFactory\Oasys\Exceptions\ProviderException * @throws \InvalidArgumentException * @return UserLike */ public function getUserData($profile = null) { $_result = parent::getUserData(); if (empty($_result)) { throw new \InvalidArgumentException('No profile available to convert.'); } if (null === ($_profile = Option::get($_result, 'result'))) { throw new ProviderException('No profile available to convert.'); } // Log::debug( 'Profile retrieved: ' . print_r( $_profile, true ) ); $_profileId = Option::get($_profile, 'id'); $_login = Option::get($_profile, 'login'); $_formatted = Option::get($_profile, 'name', $_login); $_parts = explode(' ', $_formatted); $_name = array('formatted' => $_formatted); if (!empty($_parts)) { if (sizeof($_parts) >= 1) { $_name['givenName'] = $_parts[0]; } if (sizeof($_parts) > 1) { $_name['familyName'] = $_parts[1]; } } return new GenericUser(array('provider_id' => $this->getProviderId(), 'user_id' => $_profileId, 'published' => Option::get($_profile, 'created_at'), 'display_name' => $_formatted, 'name' => $_name, 'email_address' => Option::get($_profile, 'email'), 'preferred_username' => $_login, 'urls' => array(Option::get($_profile, 'url')), 'thumbnail_url' => Option::get($_profile, 'avatar_url'), 'updated' => Option::get($_profile, 'updated_at'), 'relationships' => Option::get($_profile, 'followers'), 'user_data' => $_profile)); }
/** * @param array|\stdClass $payload * * @throws \InvalidArgumentException * @return array|\stdClass|void */ public static function validatePayload($payload) { if (null === Option::get($payload, 'refresh_token')) { throw new \InvalidArgumentException('The "refresh_token" parameter must be specified to use this grant type.'); } return $payload; }
/** * @param string $storageId * @param string $storagePath * @param array $contents * * @return \DreamFactory\Oasys\Stores\FileSystem */ public function __construct($storageId, $storagePath = null, $contents = array()) { $this->_storageId = $storageId; $this->_storagePath = $storagePath ?: Option::get($contents, 'storage_path', rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR), true); $this->_fileName = Option::get($contents, 'file_name', static::KEY_PREFIX . sha1(static::KEY_PREFIX . $storageId), true); parent::__construct($contents); $this->_load(); }
/** * @param \PDO $pdo The PDO instance on which the error occurred * @param \Exception $exception The exception thrown * @param int|mixed|null $code The HTTP response code to use. Defaults to 500 - Internal Server Error * @param mixed $previous The previous exception * @param array $context Additional information for downstream consumers */ public function __construct($pdo, $exception, $code = HttpResponse::InternalServerError, $previous = null, $context = null) { $this->_driverName = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); $this->_sqlState = Option::get($_info, 0); $this->_driverCode = Option::get($_info, 1); $this->_driverMessage = Option::get($_info, 2); parent::__construct($exception, $code, $previous, $context); }
/** * @param array|\stdClass $payload * * @throws \InvalidArgumentException * @return array|\stdClass|void */ public static function validatePayload($payload) { if (null === Option::get($payload, 'code')) { throw new \InvalidArgumentException('The "code" parameter must be specified to use this grant type.'); } if (null === Option::get($payload, 'redirect_uri')) { throw new \InvalidArgumentException('The "redirect_uri" parameter must be specified to use this grant type.'); } return $payload; }
/** * @param array|\stdClass $payload * * @throws \InvalidArgumentException * @return array|\stdClass|void */ public static function validatePayload($payload) { if (null === Option::get($payload, 'username')) { throw new \InvalidArgumentException('The "username" parameter must be specified to use this grant type.'); } if (null === Option::get($payload, 'password')) { throw new \InvalidArgumentException('The "password" parameter must be specified to use this grant type.'); } return $payload; }
/** * @param array $contents * * @throws \DreamFactory\Oasys\Exceptions\OasysException */ public function __construct($contents = array()) { if (!isset($_SESSION) || PHP_SESSION_DISABLED == session_status()) { throw new OasysException('No session active. Session storage not available.'); } $_data = array(); if (null !== ($_parcel = Option::get($_SESSION, static::KEY_PREFIX . '.data'))) { $_data = Storage::defrost($_parcel); } if (is_array($_data)) { $_data = array_merge($_data, $contents); } parent::__construct($_data); }
/** * Returns this user as a GenericUser * * * @throws \DreamFactory\Oasys\Exceptions\OasysException * @throws \InvalidArgumentException * @return UserLike */ public function getUserData() { $_response = $this->fetch('/me'); if (HttpResponse::Ok != ($_code = Option::get($_response, 'code'))) { throw new OasysException('Unexpected response code', $_code, null, $_response); } $_profile = Option::get($_response, 'result'); if (empty($_profile)) { throw new \InvalidArgumentException('No profile available to convert.'); } $_profileId = Option::get($_profile, 'id'); $_name = array('formatted' => Option::get($_profile, 'name'), 'familyName' => Option::get($_profile, 'last_name'), 'givenName' => Option::get($_profile, 'first_name')); return new GenericUser(array('user_id' => $_profileId, 'published' => Option::get($_profile, 'updated_time'), 'updated' => Option::get($_profile, 'updated_time'), 'display_name' => $_name['formatted'], 'name' => $_name, 'preferred_username' => Option::get($_profile, 'username'), 'gender' => Option::get($_profile, 'gender'), 'email_address' => Option::get($_profile, 'email'), 'urls' => array(Option::get($_profile, 'link')), 'relationships' => Option::get($_profile, 'friends'), 'thumbnail_url' => $this->_config->getEndpointUrl() . '/' . $_profileId . '/picture?width=150&height=150', 'user_data' => $_profile)); }
/** * @param array $schema * @param bool $returnHtml If true, HTML is returned, otherwise an array of fields * * @return string */ protected static function _buildFormFields($schema, $returnHtml = true) { $_form = null; $_fields = array(); foreach ($schema as $_field => $_settings) { // No private fields are ever rendered if (false !== Option::get($_settings, 'private', false)) { continue; } $_value = Option::get($_settings, 'value', Option::get($_settings, 'default')); $_label = Option::get($_settings, 'label', Inflector::display($_field)); $_labelAttributes = Option::get($_settings, 'label_attributes', array('for' => $_field)); $_attributes = array_merge(array('name' => $_field, 'id' => $_field), Option::get($_settings, 'attributes', array())); if (false !== ($_required = Option::get($_settings, 'required', false))) { $_attributes['class'] = HtmlMarkup::addValue(Option::get($_attributes, 'class'), 'required'); } $_form .= HtmlMarkup::label($_labelAttributes, $_label); $_fields[$_field]['label'] = array('value' => $_label, 'attributes' => $_labelAttributes); switch ($_settings['type']) { case 'text': $_form .= HtmlMarkup::tag('textarea', $_attributes, $_value) . PHP_EOL; $_fields[$_field] = array_merge($_fields[$_field], array('type' => 'textarea', 'contents' => $_value), $_attributes); break; case 'select': $_attributes['size'] = Option::get($_settings, 'size', 1); $_attributes['value'] = $_value; $_fields[$_field] = array_merge($_fields[$_field], array('type' => 'select', 'data' => Option::get($_settings, 'options', array())), $_attributes); $_form .= HtmlMarkup::select($_fields[$_field]['data'], $_attributes) . PHP_EOL; break; default: $_attributes['maxlength'] = Option::get($_settings, 'length'); $_attributes['value'] = $_value; $_attributes['type'] = 'text'; $_fields[$_field] = array_merge($_fields[$_field], array('type' => 'input', 'value' => $_value), $_attributes); $_form .= HtmlMarkup::tag('input', $_attributes, null, true, true) . PHP_EOL; break; } } return $returnHtml ? $_form : $_fields; }
<?php use DreamFactory\Yii\Utility\Pii; use Kisma\Core\Utility\Option; /** * supplies info for the roll your own list */ if (false !== ($_options = Pii::getParam('dashboard.rackspace', false))) { $_featureEnabled = Option::get($_options, 'enabled', false); if ($_featureEnabled) { $_body = <<<HTML <p>Rackspace has no specific image. Instead, install one of our pre-built packages! For Redhat or CentOS flavors, \t\t\t\tsee our <a href="http://wiki.dreamfactory.com/wiki/Packages/Rpm" target="_blank">installation guide</a>. We also have one for Debian/Ubuntu systems <a \t\thref="http://wiki.dreamfactory.com/wiki/Packages/Deb" target="_blank">here</a>.</p> HTML; } else { $_body = <<<HTML <p><strong>This feature is coming soon! Stay tuned!</strong></p> HTML; } return array('id' => 'rackspace', 'title' => 'Rackspace', 'body' => $_body); } return array();
/** * Merges any configuration schema with model data * * @param string $providerId The API name of the provider * @param array $configData * * @return array|null */ protected function _loadConfigSchema($providerId, $configData = array()) { $_schema = null; switch ($providerId) { case 'provider': /** @var Provider $model */ $_schema = Oasys::getProvider($providerId)->getConfig()->getSchema(); break; } // Merge if (!empty($_schema)) { $_config = !empty($configData) ? $configData : array(); // Load the resource into the schema for a goof foreach ($_schema as $_key => $_value) { if (null !== ($_configValue = Option::get($_config, $_key))) { if (is_array($_configValue)) { $_configValue = implode(', ', $_configValue); } $_value['value'] = $_configValue; } $_schema[static::SCHEMA_PREFIX . $_key] = $_value; unset($_schema[$_key]); } } return $_schema; }
/** * Returns the validated URL that has been called to get here * * @param bool $includeQuery If true, query string is included * @param bool $includePath If true, the uri path is included * * @return string */ public static function currentUrl($includeQuery = true, $includePath = true) { // Are we SSL? Check for load balancer protocol as well... $_port = intval(Option::get($_SERVER, 'HTTP_X_FORWARDED_PORT', Option::get($_SERVER, 'SERVER_PORT', 80))); $_protocol = Option::get($_SERVER, 'HTTP_X_FORWARDED_PROTO', 'http' . (Option::getBool($_SERVER, 'HTTPS') ? 's' : null)) . '://'; $_host = Option::get($_SERVER, 'HTTP_X_FORWARDED_HOST', Option::get($_SERVER, 'HTTP_HOST', gethostname())); $_parts = parse_url($_protocol . $_host . Option::get($_SERVER, 'REQUEST_URI')); if ((empty($_port) || !is_numeric($_port)) && null !== ($_parsePort = Option::get($_parts, 'port'))) { $_port = @intval($_parsePort); } if (null !== ($_query = Option::get($_parts, 'query'))) { $_query = static::urlSeparator($_query) . http_build_query(explode('&', $_query)); } if (false !== strpos($_host, ':') || $_protocol == 'https://' && $_port == 443 || $_protocol == 'http://' && $_port == 80) { $_port = null; } else { $_port = ':' . $_port; } if (false !== strpos($_host, ':')) { $_port = null; } $_currentUrl = $_protocol . $_host . $_port . (true === $includePath ? Option::get($_parts, 'path') : null) . (true === $includeQuery ? $_query : null); if (\Kisma::get('debug.curl.current_url')) { Log::debug('Parsed current URL to be: ' . $_currentUrl, $_parts); } return $_currentUrl; }
/** * Fetch a protected resource * * @param string $resource * @param array $payload * @param string $method * @param array $headers * * @throws \DreamFactory\Oasys\Exceptions\OasysConfigurationException * @throws \Kisma\Core\Exceptions\NotImplementedException * @return array */ public function fetch($resource, $payload = array(), $method = self::Get, array $headers = array()) { $_url = $resource; if (false === stripos($_url, 'http://', 0) && false === stripos($_url, 'https://', 0)) { $_endpoint = $this->_config->getEndpoint(EndpointTypes::SERVICE); $payload = array_merge(Option::get($_endpoint, 'parameters', array()), $payload); // Spiffify $_url = rtrim($_endpoint['endpoint'], '/') . '/' . ltrim($resource, '/'); } if (false !== $this->_client->fetch($_url, $payload, $method, $headers)) { $_response = $this->_client->getLastResponse(); $_info = $this->_client->getLastResponseInfo(); return array('result' => $_response, 'info' => $_info, 'code' => $_info['http_code'], 'content_type' => $_info['content_type']); } }
/** * Given an inbound state string, convert to original defrosted state * * @param string $state If not supplied, $_REQUEST['state'] is used. * * @return array */ protected static function _decodeState($state = null) { if (null === ($_state = $state ?: Option::request('state'))) { return array(); } return Storage::defrost($_state); }
/** * Formats the log entry. You can override this method to provide you own formatting. * It will strip out any console escape sequences as well * * @param array $entry Read the code, data in the array * @param bool $newline * * @return string * @deprecated in v0.2.20. To be removed in v0.3.0. Replaced by Monolog formatter */ public static function formatLogEntry(array $entry, $newline = true) { $_level = Option::get($entry, 'level'); $_levelName = static::_getLogLevel($_level); $_timestamp = Option::get($entry, 'timestamp'); $_message = preg_replace('/\\033\\[[\\d;]+m/', null, Option::get($entry, 'message')); $_context = Option::get($entry, 'context'); $_extra = Option::get($entry, 'extra'); $_blob = new \stdClass(); if (static::$_includeProcessInfo) { $_blob->pid = getmypid(); $_blob->uid = getmyuid(); $_blob->hostname = gethostname(); } if (!empty($_context)) { $_blob->context = $_context; } if (!empty($_extra)) { $_context->extra = $_extra; } $_blob = json_encode($_blob); if (false === $_blob || '{}' == $_blob) { $_blob = null; } $_replacements = array(0 => $_levelName, 1 => date('M d', $_timestamp), 2 => date('H:i:s', $_timestamp), 3 => $_message, 4 => $_blob); return str_ireplace(array('%%level%%', '%%date%%', '%%time%%', '%%message%%', '%%extra%%'), $_replacements, static::$_logFormat) . ($newline ? PHP_EOL : null); }
/** * Constructs and sets all options at once. * * @param array $options * * Options are: * * @option string $dbname The name of the database * @option string $type The connection type, "socket" or "stream" * @option string $host * @option int $port * @option string $user * @option string $password * @option string $ip * @option bool $logging * @option Configuration $config * @option EventManager $manager * @option array $namespaces Array of additional document namespaces * * @return \Doctrine\ODM\CouchDB\DocumentManager */ public static function documentManager($options = array()) { $_key = Option::get($options, 'host', 'localhost') . ':' . Option::get($options, 'port', 5984); if (!isset(self::$_dms[$_key])) { self::$_dms[$_key] = \Doctrine\ODM\CouchDB\DocumentManager::create(Option::get($options, 'client', static::couchDbClient($options)), Option::get($options, 'config'), Option::get($options, 'manager')); } return self::$_dms[$_key]; }
/** * @return array */ public function getPhoneNumber() { return @current(Option::clean($this->_phoneNumbers)); }
<?php use DreamFactory\Yii\Utility\Pii; use Kisma\Core\Utility\Option; /** * supplies info for the roll your own list */ if (false !== ($_options = Pii::getParam('dashboard.vmware', false))) { $_featureEnabled = Option::get($_options, 'enabled', false); $_wikiUrl = Option::get($_options, 'wiki_url'); $_launchUrl = Option::get($_options, 'launch_url'); if ($_featureEnabled) { $_body = <<<HTML <p>Our VMWare appliance is available at <a target="_blank" href="{$_launchUrl}">{$_launchUrl}</a>.</p> <p>More information is available here:<br/> <a target="_blank" href="{$_wikiUrl}">{$_wikiUrl}</a></p> HTML; } else { $_body = <<<HTML <p><strong>This feature is coming soon! Stay tuned!</strong></p> HTML; } return array('id' => 'vmware', 'title' => 'VMWare Appliance', 'body' => $_body); } return array();
/** * Returns the level indicator for the log * * @param int $level The level value * * @return string */ public static function getIndicator($level) { return \Kisma\Core\Utility\Option::get(self::$_indicators, $level, self::__default); }
/** * @param string $key * @param mixed $value * @param bool $overwrite * * @return $this */ public function set($key, $value, $overwrite = true) { Option::set($this->_map, $this->_hashKey($key), $value, $overwrite); return $this; }
/** * Called before a request to get any additional auth header(s) or payload parameters * (query string for non-POST-type requests) needed for the call. * * Append them to the $headers array as strings in "header: value" format: * * <code> * $_contentType = 'Content-Type: application/json'; * $_origin = 'Origin: teefury.com'; * * $headers[] = $_contentType; * $headers[] = $_origin; * </code> * * and/or append them to the $payload array in $key => $value format: * * <code> * $payload['param1'] = 'value1'; * $payload['param2'] = 'value2'; * $payload['param3'] = 'value3'; * </code> * * @param array $headers The current headers that are going to be sent * @param array $payload * * @throws \DreamFactory\Oasys\Exceptions\OasysConfigurationException * @throws NotImplementedException * @return void */ protected function _getAuthParameters(&$headers = array(), &$payload = array()) { $_token = $this->getConfig('access_token'); // Use the resource url if provided... if ($_token) { $_authHeaderName = $this->getConfig('auth_header_name'); switch ($this->getConfig('access_token_type')) { case TokenTypes::URI: Option::set($payload, $this->getConfig('access_token_param_name'), $_token); $_authHeaderName = null; break; case TokenTypes::BEARER: $_authHeaderName = $_authHeaderName ?: 'Bearer'; break; case TokenTypes::OAUTH: $_authHeaderName = $_authHeaderName ?: 'OAuth'; break; case TokenTypes::MAC: throw new NotImplementedException(); default: throw new OasysConfigurationException('Unknown access token type "' . $this->getConfig('access_token_type') . '".'); } if (null !== $_authHeaderName) { $headers[] = 'Authorization: ' . $_authHeaderName . ' ' . $_token; } } }
/** * Creates a generic, consistent event for scripting and notifications * * The returned array is as follows: * * array( * // Basics * 'id' => 'A unique ID assigned to this event', * 'name' => 'event.name', * 'trigger' => '{api_name}/{resource}', * 'stop_propagation' => [true|false], * 'dispatcher' => array( * 'id' => 'A unique ID assigned to the dispatcher of this event', * 'type' => 'The class name of the dispatcher', * ), * // Information about the triggering request * 'request' => array( * 'timestamp' => 'timestamp of the initial request', * 'path' => '/full/path/that/triggered/event', * 'api_name' =>'The api_name of the called service', * 'resource' => 'The name of the resource requested', * 'body' => 'The body posted as part of the request (possibly normalized by the service)', * ), * // Information about the outgoing response. * 'response' => 'The response body returned to the calling service and eventually to the requesting client.', * // Access to the platform api * 'platform' => array( * 'api' => [wormhole to inline-REST API], * 'config' => [standard DSP configuration update], * 'session' => [the current session], * ), * 'extra' => [Extra information passed by caller], * ) * * Note that this structure is not passed to the script verbatim. Portions are extracted and exposed by the * Script resource as it sees fit. * * Please note that the format of the request and response bodies may differ slightly from the format passed in or * sent back to the client. Some service handlers normalize the data for convenience, i.e. see * BaseDbSvc::_determineRequestMembers(). * * Therefore the data exposed by the event system has been "normalized" to provide a reliable and consistent manner * in which to process said data. There should be no need for wasting time trying to determine if your data is * "maybe here, or maybe there, or maybe over there even" when received by your event handlers. * * * @param string $eventName The event name * @param PlatformEvent $event The event * @param EventDispatcher $dispatcher The dispatcher of the event * @param array $extra Any additional data to put into the event structure * @param bool $includeDspConfig If true, the current DSP config is added to container * @param bool $returnJson If true, the event will be returned as a JSON string, otherwise an * array. * * @return array|string */ public static function normalizeEvent($eventName, PlatformEvent $event, $dispatcher, array $extra = [], $includeDspConfig = true, $returnJson = false) { static $config = null; if (!$config) { $config = $includeDspConfig ? \Cache::get(Config::LAST_RESPONSE_CACHE_KEY, false) : false; } // Clean up the event extras, remove data portion $eventExtras = $event->getData(); $path = $dispatcher->getPathInfo(true); // Clean up the trigger $trigger = false !== strpos($path, 'rest', 0) || false !== strpos($path, '/rest', 0) ? str_replace(['/rest', 'rest'], null, $path) : $path; $request = static::buildRequestArray($event); $response = $event->getResponseData(); // Build the array $event = ['id' => $event->getEventId(), 'name' => $eventName, 'timestamp' => date('c', Option::server('REQUEST_TIME_FLOAT', Option::server('REQUEST_TIME', microtime(true)))), 'trigger' => $trigger, 'request_path' => $path, 'stop_propagation' => ArrayUtils::get($eventExtras, 'stop_propagation', false, true), 'dispatcher_id' => spl_object_hash($dispatcher), 'dispatcher_type' => Inflector::neutralize(get_class($dispatcher)), 'extra' => $extra, 'platform' => ['config' => $config, 'session' => static::getCleanedSession()], 'request' => $request, 'response' => $response]; return $returnJson ? json_encode($event, JSON_UNESCAPED_SLASHES) : $event; }
/** * @param PackageInterface $package * * @throws \InvalidArgumentException * @return string */ protected function _validatePackage(PackageInterface $package) { $_packageName = $package->getPrettyName(); $_parts = explode('/', $_packageName, 2); $this->_extra = Option::clean($package->getExtra()); $this->_config = Option::get($this->_extra, 'config', array()); $this->_plugIn = static::DSP_PLUGIN_PACKAGE_TYPE == $package->getType(); // Only install DreamFactory packages if not a plug-in if (static::PACKAGE_PREFIX != ($_vendor = @current($_parts)) && !$this->_plugIn) { throw new \InvalidArgumentException('This package is not a DreamFactory package and cannot be installed by this installer.' . PHP_EOL . ' * Name: ' . $_packageName . PHP_EOL . ' * Parts: ' . implode(' / ', $_parts) . PHP_EOL); } // Effectively /docRoot/shared/[vendor]/[namespace]/[package] Log::debug('Package "' . $_packageName . '" installation type: ' . ($this->_plugIn ? 'Plug-in' : 'Package')); $this->_packageName = $_packageName; $this->_installPath = $this->_buildInstallPath($_vendor, @end($_parts)); // Link path for plug-ins $_extra = Option::clean($package->getExtra()); $this->_linkName = Option::get($_extra, 'link_name', $_parts[1]); // Relative to composer.json... i.e. web/[link_name] $this->_linkPath = trim(static::PLUG_IN_LINK_PATH . '/' . $this->_linkName, '/'); Log::info('Platform Installer Debug > ' . $_packageName . ' > Version ' . $package->getVersion()); Log::debug(' * Install path: ' . $this->_installPath); if ($this->_plugIn) { Log::debug(' * Link name: ' . $this->_linkName); Log::debug(' * Link path: ' . $this->_linkPath); } return true; }
/** * Google Plus does not allow the state parameter when making access tokens requests, so it is removed from the * payload. * * @param string $grantType * @param array $payload * * @return array|false * @throws \InvalidArgumentException */ public function requestAccessToken($grantType = GrantTypes::AUTHORIZATION_CODE, array $payload = array()) { Option::remove($payload, 'state'); return parent::requestAccessToken($grantType, $payload); }
/** * @param string $property * @param mixed $defaultValue * @param bool $burnAfterReading * * @return BaseProviderConfig|ProviderConfigLike|array */ public function getConfig($property = null, $defaultValue = null, $burnAfterReading = false) { if (null !== $property) { return Option::get($this->_config, $property, $defaultValue, $burnAfterReading); } return $this->_config; }
/** * @param array|\stdClass $data * * @return bool|void */ protected function _processReceivedToken($data) { $_data = $data; if (!is_array($data) && !$data instanceof \stdClass && !$data instanceof \Traversable) { $_data = Option::clean($data); if (!empty($_data)) { $_data = current($_data); } } foreach ($_data as $_key => $_value) { switch ($_key) { case 'instance_url': $this->_instanceName = trim(str_ireplace(array('https://', 'http://', '/'), null, $_value)); $_endpoint = $this->getConfig()->getEndpoint(EndpointTypes::SERVICE); $_endpoint['endpoint'] = str_ireplace('{{instance_name}}', $this->_instanceName, static::SERVICE_ENDPOINT_PATTERN); $this->getConfig()->mapEndpoint(EndpointTypes::SERVICE, $_endpoint); break; case 'id': $this->_identityUrl = $_value; break; } } return parent::_processReceivedToken($data); }
/** * @param int|array[] $type An EndpointTypes constant or an array of mappings * @param string|array $endpoint Call with null to remove a mapping * @param array $parameters KVPs of additional parameters * * @throws \InvalidArgumentException * @return BaseProviderConfig */ public function mapEndpoint($type, $endpoint = null, $parameters = null) { // Allow for an array of endpoints to be passed in... if (is_array($type) && null === $endpoint) { foreach ($type as $_endpointType => $_endpoint) { $this->mapEndpoint($_endpointType, $_endpoint); } return $this; } $type = $this->_getEndpointType($type); if (!EndpointTypes::contains($type)) { throw new \InvalidArgumentException('The endpoint type "' . $type . '" is not valid.'); } if (null === $endpoint) { Option::remove($this->_endpointMap, $type); return $this; } if (is_string($endpoint)) { $endpoint = array('endpoint' => $endpoint, 'parameters' => $parameters ?: array()); } $this->_endpointMap[$type] = $endpoint; return $this; }
<?php use DreamFactory\Yii\Utility\Pii; use Kisma\Core\Utility\Option; /** * supplies info for the roll your own list */ if (false !== ($_options = Pii::getParam('dashboard.bitnami', false))) { $_featureEnabled = Option::get($_options, 'enabled', false); $_url = Option::get($_options, 'url'); $_wikiUrl = Option::get($_options, 'wiki_url'); if ($_featureEnabled) { $_body = <<<HTML <p>Click the link to launch a DSP using a BitNami stack:<br/> <a target="_blank" href="{$_url}">{$_url}</a></p> <p>More information may be found in the README: <br/> <a target="_blank" href="{$_wikiUrl}">{$_wikiUrl}</a></p> HTML; } else { $_body = <<<HTML <p><strong>This feature is coming soon! Stay tuned!</strong></p> HTML; } return array('id' => 'bitnami', 'title' => 'BitNami', 'body' => $_body); } return array();
/** * Testing endpoint for events */ public function actionEventReceiver() { $_request = Pii::requestObject(); $_data = $_request->getContent(); if (is_string($_data)) { $_data = json_decode($_data, true); if (JSON_ERROR_NONE != json_last_error()) { Log::error(' * DSP event could not be converted from JSON.'); return; } } if (isset($_data['details'])) { $_eventName = Option::getDeep($_data, 'details', 'event_name'); Log::debug('DSP event "' . $_eventName . '" received'); return; } Log::error('Weird event received: ' . var_export($_data, true)); }
/** * @param array $contents * * @return \DreamFactory\Oasys\Configs\OAuthProviderConfig */ public function __construct($contents = array()) { Option::set($contents, 'type', static::OAUTH); parent::__construct($contents); }