File: NzbHandler_Factory.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (26 lines) | stat: -rwxr-xr-x 1,173 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
class NzbHandler_Factory
{
	public static function build(SpotSettings $settings, $action, array $nzbHandling)
	{
		# Nieuwe handlers voegen we expliciet toe omdat we anders
		# niet weten wat we includen in combinate met __autoload()
		switch ($action)
		{
			case 'disable'			: $handler = new NzbHandler_Disable($settings, $nzbHandling); break;
			case 'save'	  			: $handler = new NzbHandler_Save($settings, $nzbHandling); break;
			case 'runcommand'		: $handler = new NzbHandler_Runcommand($settings, $nzbHandling); break;
			case 'push-sabnzbd' 	: $handler = new NzbHandler_Pushsabnzbd($settings, $nzbHandling); break;
			case 'client-sabnzbd' 	: $handler = new NzbHandler_Clientsabnzbd($settings, $nzbHandling); break;
			case 'nzbget'			: $handler = new NzbHandler_Nzbget($settings, $nzbHandling); break;
			default					: $handler = new NzbHandler_Display($settings, $nzbHandling); break;
		} # switch

                if (!$handler instanceof NzbHandler_Disable && $handler->isAvailable()!==true) {
                    $handler = new NzbHandler_Disable($settings, $nzbHandling);
                }

		return $handler;
	} # build()

} # class NzbHandler_Factory