Skip to content

Commit

Permalink
Merge pull request #20 from swiffer/master
Browse files Browse the repository at this point in the history
Update Readme.md and Filesystem Panel
  • Loading branch information
WyriHaximus authored Mar 3, 2020
2 parents 8e651a2 + c6d73ab commit c142377
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FlyPie
======

Lightweight [Flysystem](http://flysystem.thephpleague.com/) wrapper/configuration plugin for CakePHP v3.x
Lightweight [Flysystem](http://flysystem.thephpleague.com/) wrapper/configuration plugin for CakePHP.

See below for CakePHP core version compatibility matrix.

## Installation ##

Expand All @@ -21,7 +23,7 @@ Plugin::load('WyriHaximus/FlyPie', ['bootstrap' => true]);

## Configuration ##

Example configuration (for in `config/app.php`):
Example configuration (for in `config/app_local.php`):

```php
/**
Expand All @@ -43,13 +45,21 @@ Example configuration (for in `config/app.php`):

At first it's namespaced within `WyriHaximus.FlyPie` to make sure it doesn't interfere with any other plugins. Secondly it's an associative array where every key is the alias for a specific plugin configuration. That is `s3_thumbnails` in our example. So when you need that filesystem somewhere in your project you can call `$this->filesystem('s3_thumbnails');` on the trait.

To enable the filesystem panel in DebugKit add the configuration as shown below:

```php
'DebugKit' => [
'panels' => ['WyriHaximus/FlyPie.Filesystem'],
],
```

### Configuration keys ###

* `adapter` - adapter name or full qualified class name to use for this filesystem
* `vars` - array containing the required settings for FlyPie to build an adapter for you. That is passed directly into `newInstanceArgs` upon adapter creation. (This is required in case you don't use a factory or provide the client.)
* `client` - a prebuild client
* `factory` - a callback, array (class instance, methodname), string (static class method or function name or event name) that can be utilized as a factory to build the adapter
* `url` - [Data Source Name](https://book.cakephp.org/3.0/en/appendices/glossary.html#term-dsn). A connection string format that is formed like a URI. See below for examples.
* `url` - [Data Source Name](https://book.cakephp.org/4/en/appendices/glossary.html#term-dsn). A connection string format that is formed like a URI. See below for examples.

Check out [`config/config.sample.php`](config/config.sample.php) for more details.

Expand All @@ -76,6 +86,13 @@ per case basis as extra composer packages. For all supported adapters see:
| -------------- | --------------------------------------------------------------------------- |
| AwsS3v3Adapter | `s3://key:secret@bucket/path?region={{region}}&version={{latest\|version}}` |

## CakePHP version compatibility matrix ##

| FlyPie | CakePHP core | PHP min |
| ------ | ------------ | ------- |
| 1.x | 3.x | PHP 5.4 |
| 2.x | 4.x | PHP 7.2 |

## License ##

Copyright 2017 [Cees-Jan Kiewiet](http://wyrihaximus.net/)
Expand Down
5 changes: 3 additions & 2 deletions src/Panel/FilesystemPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ public function data()
{
$data = [
'filesystems' => array_keys((array)Configure::read(self::CONFIGURE_KEY)),
'instances' => [],
'classes' => [],
];

foreach ($data['filesystems'] as $filesystem) {
$data['instances'][$filesystem] = FilesystemRegistry::retrieve($filesystem);
$instance = FilesystemRegistry::retrieve($filesystem);
$data['classes'][$filesystem] = get_class($instance->getAdapter());
}

return $data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

use \WyriHaximus\FlyPie\Panel\FilesystemPanel;
use WyriHaximus\FlyPie\Panel\FilesystemPanel;

?>

<?php if (!empty($filesystems)): ?>
<?php if (!empty($filesystems)) : ?>
<h4>Configured filesystems</h4>
<p class="warning">The following list used <strong><?= FilesystemPanel::CONFIGURE_KEY ?></strong> as filesystem list:</p>
<ul class="neat-array depth-0">
<?php foreach ($filesystems as $filesystem): ?>
<?php foreach ($filesystems as $filesystem) : ?>
<li class="expandable collapsed filesystemtree" data-alias="<?= $filesystem; ?>">
<strong><?= h($filesystem) ?></strong>
(<?= h(get_class($instances[$filesystem]->getAdapter())) ?>)
(<?= h($classes[$filesystem]) ?>)
<ul class="neat-array depth-1 loading" style="display: none;">
<li>Loading...</li>
</ul>
Expand All @@ -25,6 +25,6 @@
});
</script>
<hr />
<?php else: ?>
<?php else : ?>
<div class="warning"><?= __d('fly_pie', 'No configured filesystem found') ?></div>
<?php endif ?>

0 comments on commit c142377

Please sign in to comment.