Browse Source

adding

master
Björn 3 years ago
parent
commit
1765d32434
5 changed files with 79 additions and 19 deletions
  1. +0
    -14
      app/Handlers/Actions/ActionHandler.php
  2. +14
    -0
      app/Handlers/Response/ResponseHandler.php
  3. +4
    -2
      composer.json
  4. +42
    -2
      composer.lock
  5. +19
    -1
      resources/CustomHandlers/Action/FileDownload.php

+ 0
- 14
app/Handlers/Actions/ActionHandler.php View File

@ -13,20 +13,6 @@ class ActionHandler implements ActionHandlerInterface
// data to process in a action // data to process in a action
protected $data; protected $data;
/**
*
* @param [type] $data
* @return [type]
*/
protected function processActions($source, $response, $data)
{
foreach($this->source->actions() as $action) {
HandlerFactory::getActionHandlerClass($action->response_handler_class);
$action = new ActionClass($this->source, $data);
$action->run();
}
}
/** /**
* *
* @param mixed $data * @param mixed $data


+ 14
- 0
app/Handlers/Response/ResponseHandler.php View File

@ -24,4 +24,18 @@ class ResponseHandler implements ResponseHandlerInterface
{ {
$this->source = $source; $this->source = $source;
} }
/**
*
* @param [type] $data
* @return [type]
*/
protected function processActions($data)
{
foreach($this->source->actions() as $action) {
HandlerFactory::getActionHandlerClass($action->action_handler_class);
$action = new ActionClass($this->source, $this->response, $data);
$action->run();
}
}
} }

+ 4
- 2
composer.json View File

@ -22,7 +22,8 @@
"illuminate/http": "^7.0", "illuminate/http": "^7.0",
"illuminate/log": "^7.0", "illuminate/log": "^7.0",
"laravel-zero/framework": "^7.0", "laravel-zero/framework": "^7.0",
"nunomaduro/laravel-console-menu": "^3.0"
"nunomaduro/laravel-console-menu": "^3.0",
"ralouphie/mimey": "^2.1"
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "^1.4", "fzaninotto/faker": "^1.4",
@ -31,7 +32,8 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/"
"App\\": "app/",
"CustomHandlers\\": "resources/CustomHandlers/"
} }
}, },
"autoload-dev": { "autoload-dev": {


+ 42
- 2
composer.lock View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ac74c34c116ba452cd3b28f38c918e86",
"content-hash": "01f46875cfca1c919f8e66d42dcf772f",
"packages": [ "packages": [
{ {
"name": "beberlei/assert", "name": "beberlei/assert",
@ -2594,6 +2594,46 @@
}, },
"time": "2019-03-08T08:55:37+00:00" "time": "2019-03-08T08:55:37+00:00"
}, },
{
"name": "ralouphie/mimey",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/mimey.git",
"reference": "8f74e6da73f9df7bd965e4e123f3d8fb9acb89ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/mimey/zipball/8f74e6da73f9df7bd965e4e123f3d8fb9acb89ba",
"reference": "8f74e6da73f9df7bd965e4e123f3d8fb9acb89ba",
"shasum": ""
},
"require": {
"php": "^5.4|^7.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^1.1",
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Mimey\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "PHP package for converting file extensions to MIME types and vice versa.",
"time": "2019-03-08T08:49:03+00:00"
},
{ {
"name": "ramsey/uuid", "name": "ramsey/uuid",
"version": "3.9.3", "version": "3.9.3",
@ -6480,5 +6520,5 @@
"platform-overrides": { "platform-overrides": {
"php": "7.4.18" "php": "7.4.18"
}, },
"plugin-api-version": "2.0.0"
"plugin-api-version": "1.1.0"
} }

+ 19
- 1
resources/CustomHandlers/Action/FileDownload.php View File

@ -2,6 +2,11 @@
namespace CustomHandlers\Actions; namespace CustomHandlers\Actions;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Mimey\MimeTypes;
/** /**
* *
* *
@ -12,6 +17,19 @@ class FileDownload extends ActionHandler
{ {
public function run() public function run()
{ {
if (isset($this->data->enclosure) && isset($this->data->enclosure->attributes()->url)) {
// get mimes
$mimes = new MimeTypes();
$extension = $mimes->getExtension($this->data->enclosure->attributes()->type);
// if extension valid
if ($extension) {
$filename = Str::slug($this->data->title).'.'.$extension;
Storage::download($this->data->enclosure->attributes()->url)->put($filename);
} else {
// @TODO what you do
}
}
} }
} }

Loading…
Cancel
Save