forked from omniphx/forrest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed config namespacing issue. Updated travis file
- Loading branch information
Showing
14 changed files
with
349 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#### Query | ||
Returns results for a specified SOQL query. | ||
```php | ||
Forrest::query('SELECT Id FROM Account'); | ||
``` | ||
|
||
#### Query Explain | ||
Returns details of how Salesforce will process your query. Available for API verison 30.0 or later. | ||
```php | ||
Forrest::queryExplain('SELECT Id FROM Account'); | ||
``` | ||
|
||
#### Query All | ||
Returns results for a specified SOQL query, but will also inlcude deleted records. | ||
```php | ||
Forrest::queryAll('SELECT Id FROM Account'); | ||
``` | ||
|
||
#### Search | ||
Returns the specified SOSL query | ||
```php | ||
Forrest::search('Find {foo}'); | ||
``` | ||
|
||
#### Scope Order | ||
Global search keeps track of which objects the user interacts with and arranges them when the user performs a global search. This call will return this ordered list of objects. | ||
```php | ||
Forrest::scopeOrder(); | ||
``` | ||
|
||
#### Search Layouts | ||
Returns the search results layout for the objects in the query string. List should be formatted as a string, but delimited by a comma. | ||
```php | ||
Forrest::searchLayouts('Account,Contact,Lead'); | ||
``` | ||
|
||
#### Suggested Articles | ||
Returns a list of Salesforce Knowledge articles based on the a search query. Pass additional parameters into the second argument. Available for API verison 30.0 or later. | ||
|
||
> Salesforce Knowledge must be enabled for this to work. | ||
```php | ||
Forrest::suggestedArticles('foo', [ | ||
'parameters' => [ | ||
'channel' => 'App', | ||
'publishStatus' => 'Draft']]); | ||
``` | ||
|
||
#### Suggested Queries | ||
Returns a list of suggested searches based on a search text query. Matches search queries that other users have performed in Salesforce Knowledge. Like Suggest Articles, additional parameters can be passed into the second argument with the `parameters` key. Available for API version 30.0 or later. | ||
|
||
```php | ||
Forrest::suggestedQueries('app, [ | ||
'parameters' => ['foo' => 'bar']]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Omniphx/Forrest/Providers/Laravel4/Facades/Forrest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel4\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class Forrest extends Facade { | ||
|
||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() { return 'forrest'; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel; | ||
|
||
use Omniphx\Forrest\Interfaces\StorageInterface; | ||
use Omniphx\Forrest\Exceptions\MissingKeyException; | ||
use Illuminate\Config\Repository as Config; | ||
use Illuminate\Cache\CacheManager as Cache; | ||
|
||
class LaravelCache extends LaravelStorageProvider implements StorageInterface { | ||
|
||
public $minutes = 20; | ||
|
||
public $path; | ||
|
||
protected $cache; | ||
|
||
public function __construct(Config $config, Cache $cache) | ||
{ | ||
$this->path = $config->get('forrest::config.storage.path'); | ||
|
||
$this->cache = $cache; | ||
|
||
if($minutes = $config->get('forrest::config.storage.expire_in')) { | ||
$this->minutes = $minutes; | ||
} | ||
} | ||
|
||
/** | ||
* Store into session. | ||
* @param $key | ||
* @param $value | ||
* @return void | ||
*/ | ||
public function put($key, $value) | ||
{ | ||
return $this->cache->put($this->path.$key, $value, $this->minutes); | ||
} | ||
|
||
/** | ||
* Get from session | ||
* @param $key | ||
* @return mixed | ||
*/ | ||
public function get($key) | ||
{ | ||
if ($this->cache->has($this->path.$key)) { | ||
return $this->cache->get($this->path.$key); | ||
} | ||
|
||
throw new MissingKeyException(sprintf("No value for requested key: %s",$key)); | ||
} | ||
|
||
/** | ||
* Check if storage has a key | ||
* @param $key | ||
* @return boolean | ||
*/ | ||
public function has($key) | ||
{ | ||
return $this->cache->has($this->path.$key); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel; | ||
|
||
use Omniphx\Forrest\Interfaces\EventInterface; | ||
use Event; | ||
|
||
class LaravelEvent implements EventInterface { | ||
|
||
/** | ||
* Fire an event and call the listeners. | ||
* | ||
* @param string $event | ||
* @param mixed $payload | ||
* @param bool $halt | ||
* @return array|null | ||
*/ | ||
public function fire($event, $payload = array(), $halt = false) { | ||
return Event::fire($event, $payload, $halt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel; | ||
|
||
use Omniphx\Forrest\Interfaces\InputInterface; | ||
use Input; | ||
|
||
class LaravelInput implements InputInterface { | ||
|
||
/** | ||
* Get input from response | ||
* @param string $parameter | ||
* @return mixed | ||
*/ | ||
public function get($parameter){ | ||
return Input::get($parameter); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Omniphx/Forrest/Providers/Laravel4/LaravelRedirect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel; | ||
|
||
use Omniphx\Forrest\Interfaces\RedirectInterface; | ||
use Redirect; | ||
|
||
class LaravelRedirect implements RedirectInterface { | ||
|
||
/** | ||
* Redirect to new url | ||
* @param string $parameter | ||
* @return void | ||
*/ | ||
public function to($parameter){ | ||
return Redirect::to($parameter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel; | ||
|
||
use Omniphx\Forrest\Interfaces\StorageInterface; | ||
use Omniphx\Forrest\Exceptions\MissingKeyException; | ||
use Illuminate\Config\Repository as Config; | ||
use Illuminate\Session\SessionManager as Session; | ||
|
||
class LaravelSession extends LaravelStorageProvider implements StorageInterface { | ||
|
||
public $path; | ||
|
||
protected $session; | ||
|
||
public function __construct(Config $config, Session $session) | ||
{ | ||
$this->path = $config->get('forrest::config.storage.path'); | ||
|
||
$this->session = $session; | ||
} | ||
|
||
/** | ||
* Store into session. | ||
* @param $key | ||
* @param $value | ||
* @return void | ||
*/ | ||
public function put($key, $value) | ||
{ | ||
return $this->session->put($this->path.$key, $value); | ||
} | ||
|
||
/** | ||
* Get from session | ||
* @param $key | ||
* @return mixed | ||
*/ | ||
public function get($key) | ||
{ | ||
if ($this->session->has($this->path.$key)) { | ||
return $this->session->get($this->path.$key); | ||
} | ||
|
||
throw new MissingKeyException(sprintf("No value for requested key: %s",$key)); | ||
} | ||
|
||
/** | ||
* Check if storage has a key | ||
* @param $key | ||
* @return boolean | ||
*/ | ||
public function has($key) | ||
{ | ||
return $this->session->has($this->path.$key); | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
src/Omniphx/Forrest/Providers/Laravel4/LaravelStorageProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php namespace Omniphx\Forrest\Providers\Laravel; | ||
|
||
use Omniphx\Forrest\Interfaces\StorageInterface; | ||
use Omniphx\Forrest\Exceptions\MissingTokenException; | ||
use Omniphx\Forrest\Exceptions\MissingRefreshTokenException; | ||
use Crypt; | ||
|
||
abstract class LaravelStorageProvider implements StorageInterface { | ||
|
||
/** | ||
* Encrypt authentication token and store it in session. | ||
* @param array $token | ||
* @return void | ||
*/ | ||
public function putTokenData($token) | ||
{ | ||
$encryptedToken = Crypt::encrypt($token); | ||
return $this->put('token', $encryptedToken); | ||
} | ||
|
||
/** | ||
* Get token from the session and decrypt it. | ||
* @return mixed | ||
*/ | ||
public function getTokenData() | ||
{ | ||
if ($this->has('token')) { | ||
$token = $this->get('token'); | ||
return Crypt::decrypt($token); | ||
} | ||
|
||
throw new MissingTokenException(sprintf('No token available in \''.\Config::get('forrest::config.storage.type').'\' storage')); | ||
} | ||
|
||
/** | ||
* Encrypt refresh token and pass into session. | ||
* @param Array $token | ||
* @return void | ||
*/ | ||
public function putRefreshToken($token) | ||
{ | ||
$encryptedToken = Crypt::encrypt($token); | ||
return $this->put('refresh_token', $encryptedToken); | ||
} | ||
|
||
/** | ||
* Get refresh token from session and decrypt it. | ||
* @return mixed | ||
*/ | ||
public function getRefreshToken() | ||
{ | ||
if ($this->has('refresh_token')) { | ||
$token = $this->get('refresh_token'); | ||
return Crypt::decrypt($token); | ||
} | ||
|
||
throw new MissingRefreshTokenException(sprintf('No refresh token stored in current session. Verify you have added refresh_token to your scope items on your connected app settings in Salesforce.')); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Omniphx/Forrest/Providers/Laravel4/Routes/UserPassword.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Forrest Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| UserPassword authentication routes | ||
| | ||
*/ | ||
|
||
Route::get('/authenticate', function() | ||
{ | ||
Forrest::authenticate(); | ||
|
||
$url = Config::get('forrest::authRedirect'); | ||
|
||
return Redirect::to($url); | ||
}); |
Oops, something went wrong.