3xw/attachment-third-party
Composer 安装命令:
composer require 3xw/attachment-third-party
包简介
CakePHP utils plugins
README 文档
README
Attachment third pary ( Youtube etc ... ). Is a sub project of plugin 3xw/attachment
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require 3xw/attachment-third-party
Add Queue tasks
Acrtive the plugin in your Application.php file:
// Queue $this->addPlugin('Queue');
Then migrate the db
bin/cake migrations migrate -p Queue
Install
Install Google lib:
composer require google/apiclient:^2.0
Protect
Ignore your Google private settings. Add following in .gitignore file:
/config/google/*
OAuth
- select/create a Google project here
- active Youtube Library in library menu
- create and download a OAuth Client (of type "Other"), place it as config/google/credentials.json
Usage
Prepare
When using attachment, setup an event listener either:
- globally in your config/attachment.php
return [ 'Attachment' => [ //... 'listeners' => [ 'beforeSave' => [ 'Attachment\Listener\ModifyTypeListener' => [ 'type' => 'transit', 'subtype' => 'youtube', // or other third party name ] ], ] //... ] ];
- specifically in any template:
$this->Attachment->buildIndex([ 'actions' => ['add','edit','delete','view'], 'types' =>['image/jpeg','image/png','embed/youtube','embed/vimeo','video/quicktime','transit/youtube'], 'listeners' => [ 'beforeSave' => [ 'Attachment\Listener\ModifyTypeListener' => [ 'type' => 'transit', 'subtype' => 'youtube', ] ], ] ])
Move Files
By creating a cron tasks, the plugin will look for attachments with a type "transit" and create Queue tasks for each attachment with relevant Mover Class.
bin/cake queue add CreateTransitStack & bin/cake queue runworker
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-05-14