Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
Closes #9
Closes #7
Closes #3
  • Loading branch information
jasonvarga committed Jan 25, 2018
1 parent 2c10c31 commit 1948823
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions addons/Spock/SpockListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Statamic\Addons\Spock;

use League\Flysystem\Adapter\AbstractAdapter;
use Statamic\API\File;
use Statamic\API\Parse;
use Statamic\API\User;
use Statamic\Extend\Listener;
use Statamic\API\User as UserAPI;
use Symfony\Component\Process\Process;
use Statamic\Contracts\Data\Users\User;

class SpockListener extends Listener
{
Expand Down Expand Up @@ -78,19 +78,9 @@ private function environmentWhitelisted()
*/
private function commands()
{
if ($this->data instanceof \Statamic\Data\Users\User) {
$disk = File::disk('users');
} else {
$disk = File::disk('content');
}

/** @var AbstractAdapter $adapter */
$adapter = $disk->filesystem()->getAdapter();
$full_path = $adapter->getPathPrefix() . $this->data->path();

$data = $this->data->toArray();
$data['full_path'] = $full_path;
$data['committer'] = User::getCurrent()->toArray();
$data['full_path'] = $this->getPathPrefix() . $this->data->path();
$data['committer'] = UserAPI::getCurrent()->toArray();

$commands = [];

Expand All @@ -100,4 +90,16 @@ private function commands()

return join('; ', $commands);
}

/**
* Get the prefix to the data's path.
*
* @return string
*/
private function getPathPrefix()
{
$disk = $this->data instanceof User ? 'users' : 'content';

return File::disk($disk)->filesystem()->getAdapter()->getPathPrefix();
}
}

0 comments on commit 1948823

Please sign in to comment.