Skip to content

Commit

Permalink
Fixed config namespacing issue. Updated travis file
Browse files Browse the repository at this point in the history
  • Loading branch information
omniphx committed Jul 24, 2015
1 parent 9d49ec1 commit dffa126
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ php:

before_script:
- composer self-update
- composer install --prefer-source --no-interaction --dev
- composer install --prefer-source --no-interaction

script: vendor/bin/phpspec run
55 changes: 55 additions & 0 deletions extend_doc.md
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']]);
```
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
Forrest::authenticate();

$url = Config::get('forrest::authRedirect');
$url = Config::get('forrest.authRedirect');

return Redirect::to($url);
});
2 changes: 1 addition & 1 deletion src/Omniphx/Forrest/Providers/Laravel/Routes/WebServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
Forrest::callback();

$url = Config::get('forrest::authRedirect');
$url = Config::get('forrest.authRedirect');

return Redirect::to($url);
});
14 changes: 14 additions & 0 deletions src/Omniphx/Forrest/Providers/Laravel4/Facades/Forrest.php
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'; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function boot()

$authentication = Config::get('forrest::authentication');

include __DIR__ . "/../Laravel/Routes/$authentication.php";
include __DIR__ . "/../Laravel4/Routes/$authentication.php";
}

/**
Expand All @@ -39,14 +39,14 @@ public function register()
$settings = Config::get('forrest::config');

$client = new \GuzzleHttp\Client();
$redirect = new \Omniphx\Forrest\Providers\Laravel\LaravelRedirect();
$redirect = new \Omniphx\Forrest\Providers\Laravel4\LaravelRedirect();
if($settings['storage']['type'] == 'cache') {
$storage = new \Omniphx\Forrest\Providers\Laravel\LaravelCache(app('config'), app('cache'));
$storage = new \Omniphx\Forrest\Providers\Laravel4\LaravelCache(app('config'), app('cache'));
} else {
$storage = new \Omniphx\Forrest\Providers\Laravel\LaravelSession(app('config'), app('session'));
$storage = new \Omniphx\Forrest\Providers\Laravel4\LaravelSession(app('config'), app('session'));
}
$input = new \Omniphx\Forrest\Providers\Laravel\LaravelInput();
$event = new \Omniphx\Forrest\Providers\Laravel\LaravelEvent();
$input = new \Omniphx\Forrest\Providers\Laravel4\LaravelInput();
$event = new \Omniphx\Forrest\Providers\Laravel4\LaravelEvent();

$authentication = '\\Omniphx\\Forrest\\Authentications\\';
$authentication .= $settings['authentication'];
Expand Down
62 changes: 62 additions & 0 deletions src/Omniphx/Forrest/Providers/Laravel4/LaravelCache.php
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);
}

}
19 changes: 19 additions & 0 deletions src/Omniphx/Forrest/Providers/Laravel4/LaravelEvent.php
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);
}
}
16 changes: 16 additions & 0 deletions src/Omniphx/Forrest/Providers/Laravel4/LaravelInput.php
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 src/Omniphx/Forrest/Providers/Laravel4/LaravelRedirect.php
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);
}
}
56 changes: 56 additions & 0 deletions src/Omniphx/Forrest/Providers/Laravel4/LaravelSession.php
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 src/Omniphx/Forrest/Providers/Laravel4/LaravelStorageProvider.php
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 src/Omniphx/Forrest/Providers/Laravel4/Routes/UserPassword.php
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);
});
Loading

0 comments on commit dffa126

Please sign in to comment.