3xw/attachment-third-party

There is no license information available for the latest version (3.0.2) of this package.

CakePHP utils plugins

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:cakephp-plugin

3.0.2 2019-05-16 10:16 UTC

This package is auto-updated.

Last update: 2024-04-16 21:41:11 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

Google

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