3xw / attachment-third-party
CakePHP utils plugins
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.5.9
- 3xw/attachment: 3.*
- cakephp/cakephp: 3.*
- dereuromark/cakephp-queue: 3.*
Requires (Dev)
This package is auto-updated.
Last update: 2024-12-16 22:56:26 UTC
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