Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #130 from davidyell/develop
Browse files Browse the repository at this point in the history
Update master
  • Loading branch information
davidyell committed Aug 25, 2015
2 parents 8604cac + c706cac commit e2c4a93
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install:
- composer install --prefer-dist --no-interaction --dev

before_script:
- sh -c "if [ '$PHPCS' = '1' ]; then composer require squizlabs/php_codesniffer:~2; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then composer require cakephp/cakephp-codesniffer:~2; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls:dev-master; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"

Expand All @@ -36,7 +36,7 @@ before_script:

script:
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --ignore=bootstrap.php --standard=PSR2 ./src ./tests; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --ignore=bootstrap.php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"

Expand Down
15 changes: 0 additions & 15 deletions config/bootstrap.php

This file was deleted.

7 changes: 0 additions & 7 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ see which ones you must define and which ones can be ignored to use the defaults

```php
<?php
// Configure your upload field to use the file datatype
protected function _initializeSchema(\Cake\Database\Schema\Table $table)
{
$table->columnType('photo', 'proffer.file');
return $table;
}

// Add the behaviour and configure any options you want
$this->addBehavior('Proffer.Proffer', [
'photo' => [ // The name of your upload field
Expand Down
2 changes: 2 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ echo $this->Form->input($entity, ['type' => 'file']);
echo $this->Form->input('file_upload', ['type' => 'file']);
// etc
```
### No database changes and no file system changes
If the form is submitting without issue, yet no file upload is tacking place, ensure that your form is multipart. In your template, make sure your form is type file. `$this->Form->create($example, ['type' => 'file'])`.

## Still having trouble?
If you're still having trouble, head to `#cakephp` on Freenode.net and ask for help. A web chat client is available
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ It's always advised to lock your dependencies to a specific version number. You
Then you'll need to load the plugin in your `config/bootstrap.php` file.

```php
Plugin::load('Proffer', ['bootstrap' => true]);
Plugin::load('Proffer');
```

## Database
Expand Down
6 changes: 6 additions & 0 deletions src/Database/Type/FileType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

class FileType extends Type
{
/**
* Prevent the marhsaller changing the upload array into a string
*
* @param mixed $value Passed upload array
* @return mixed
*/
public function marshal($value)
{
return $value;
Expand Down
10 changes: 4 additions & 6 deletions src/Lib/ProfferPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,14 @@ public function fullPath($prefix = null)
$table = $this->getTable();
$table = (!empty($table)) ? $table . DS : null;

$seed = $this->getSeed();
$seed = $this->getSeed();
$seed = (!empty($seed)) ? $seed . DS : null;

if ($prefix) {
return $this->getRoot() . DS . $table . $this->getField()
. DS . $this->getSeed() . DS . $prefix . '_' . $this->getFilename();
return $this->getRoot() . DS . $table . $this->getField() . DS . $this->getSeed() . DS . $prefix . '_' . $this->getFilename();
}

return $this->getRoot() . DS . $table . $this->getField()
. DS . $seed . $this->getFilename();
return $this->getRoot() . DS . $table . $this->getField() . DS . $seed . $this->getFilename();
}

/**
Expand All @@ -236,7 +234,7 @@ public function getFolder()
$table = $this->getTable();
$table = (!empty($table)) ? $table . DS : null;

$seed = $this->getSeed();
$seed = $this->getSeed();
$seed = (!empty($seed)) ? $seed . DS : null;

return $this->getRoot() . DS . $table . $this->getField() . DS . $seed;
Expand Down
24 changes: 21 additions & 3 deletions src/Model/Behavior/ProfferBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Proffer\Model\Behavior;

use ArrayObject;
use Cake\Database\Type;
use Cake\Event\Event;
use Cake\ORM\Behavior;
use Cake\ORM\Entity;
Expand All @@ -22,12 +23,29 @@
*/
class ProfferBehavior extends Behavior
{
/**
* Build the behaviour
*
* @param array $config Passed configuration
* @return void
*/
public function initialize(array $config)
{
Type::map('proffer.file', '\Proffer\Database\Type\FileType');
$schema = $this->_table->schema();
foreach (array_keys($this->config()) as $field) {
$schema->columnType($field, 'proffer.file');
}
$this->_table->schema($schema);
}

/**
* beforeMarshal event
*
* @param Event $event
* @param ArrayObject $data
* @param ArrayObject $options
* @param Event $event Event instance
* @param ArrayObject $data Data to process
* @param ArrayObject $options Array of options for event
* @return void
*/
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Shell/ProfferShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getOptionParser()
'parser' => [
'description' => [__('Use this command to regenerate the thumbnails for a specific table.')],
'arguments' => [
'table' => ['help' => __('The table to regenerate thumbs for') , 'required' => true]
'table' => ['help' => __('The table to regenerate thumbs for'), 'required' => true]
],
'options' => [
'path-class' => [
Expand Down Expand Up @@ -224,13 +224,13 @@ public function cleanup($table)

foreach ($filesToRemove as $file) {
if ($this->param('dry-run') && $this->param('verbose')) {
$this->out(__("Would delete `$seedFolder" .DS ."$file`"));
$this->out(__("Would delete `$seedFolder" . DS . "$file`"));
} elseif ($this->param('dry-run')) {
$this->out(__("Would delete `$file`"));
} else {
unlink($seedFolder . DS . $file);
if ($this->param('verbose')) {
$this->out(__("Deleted `$seedFolder" .DS ."$file`"));
$this->out(__("Deleted `$seedFolder" . DS . "$file`"));
} else {
$this->out(__("Deleted `$file`"));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Lib/ProfferPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class ProfferPathTest extends PHPUnit_Framework_TestCase
*
* @param $dir
*/
private function __rrmdir($dir)
protected function _rrmdir($dir)
{
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir . "/" . $object) == "dir") {
$this->__rrmdir($dir . "/" . $object);
$this->_rrmdir($dir . "/" . $object);
} else {
unlink($dir . "/" . $object);
}
Expand All @@ -44,7 +44,7 @@ private function __rrmdir($dir)
*/
public function tearDown()
{
$this->__rrmdir(TMP . 'ProfferTests' . DS);
$this->_rrmdir(TMP . 'ProfferTests' . DS);
}

public function pathDataProvider()
Expand Down
Loading

0 comments on commit e2c4a93

Please # to comment.