This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Api/Jobs/AbstractJob.php
2014-05-18 21:59:56 +02:00

82 lines
1.4 KiB
PHP

<?php
abstract class AbstractJob implements IJob
{
const CONTEXT_NORMAL = 1;
const CONTEXT_BATCH_EDIT = 2;
const CONTEXT_BATCH_ADD = 3;
protected $arguments = [];
protected $context = self::CONTEXT_NORMAL;
public function prepare()
{
}
public abstract function execute();
public abstract function getRequiredArguments();
public function getName()
{
$name = get_called_class();
$name = str_replace('Job', '', $name);
$name = TextCaseConverter::convert(
$name,
TextCaseConverter::UPPER_CAMEL_CASE,
TextCaseConverter::SPINAL_CASE);
return $name;
}
public function getRequiredPrivileges()
{
return false;
}
public function isAuthenticationRequired()
{
return false;
}
public function isConfirmedEmailRequired()
{
return false;
}
public function getContext()
{
return $this->context;
}
public function setContext($context)
{
$this->context = $context;
}
public function getArgument($key)
{
if (!$this->hasArgument($key))
throw new ApiMissingArgumentException($key);
return $this->arguments[$key];
}
public function getArguments()
{
return $this->arguments;
}
public function hasArgument($key)
{
return isset($this->arguments[$key]);
}
public function setArgument($key, $value)
{
$this->arguments[$key] = $value;
}
public function setArguments(array $arguments)
{
$this->arguments = $arguments;
}
}