| Server IP : 81.19.159.101 / Your IP : 216.73.217.111 Web Server : Apache System : Linux www58.world4you.com 4.18.0-553.126.2.lve.el8.x86_64 #1 SMP Thu May 28 14:12:30 UTC 2026 x86_64 User : ftp8817043 ( 2681) PHP Version : 8.4.21 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/.sites/103/site8817043/web/wp-content/plugins/akeebabackupwp/app/Solo/Model/Json/ |
Upload File : |
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2025 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\Model\Json;
use Awf\Container\Container;
use Awf\Container\ContainerAwareInterface;
use Awf\Container\ContainerAwareTrait;
/**
* Handles task execution
*/
class Task implements ContainerAwareInterface
{
use ContainerAwareTrait;
/** @var TaskInterface[] The task handlers known to us */
protected $handlers = array();
/**
* Public constructor. Populates the list of task handlers.
*/
public function __construct(Container $container)
{
$this->setContainer($container);
// Populate the list of task handlers
$this->initialiseHandlers();
}
/**
* Do I have a specific task handling method?
*
* @param string $method The method to check for
*
* @return bool
*/
public function hasMethod($method)
{
$method = strtolower($method);
return isset($this->handlers[$method]);
}
/**
* Execute a JSON API method
*
* @param string $method The method's name
* @param array $parameters The parameters to the method (optional)
*
* @return mixed
*
* @throws \RuntimeException When the method requested is not known to us
*/
public function execute($method, $parameters = array())
{
if (!$this->hasMethod($method))
{
throw new \RuntimeException("Invalid method $method", 405);
}
$method = strtolower($method);
return $this->handlers[$method]->execute($parameters);
}
/**
* Initialises the encapsulation handlers
*
* @return void
*/
protected function initialiseHandlers()
{
// Reset the array
$this->handlers = array();
// Look all files in the Task handlers' directory
$dh = new \DirectoryIterator(__DIR__ . '/Task');
/** @var \DirectoryIterator $entry */
foreach ($dh as $entry)
{
$fileName = $entry->getFilename();
// Ignore non-PHP files
if (substr($fileName, -4) != '.php')
{
continue;
}
// Ignore the Base class
if ($fileName == 'Base.php')
{
continue;
}
// Get the class name
$className = '\\Solo\\Model\\Json\\Task\\' . substr($fileName, 0, -4);
// Check if the class really exists
if (!class_exists($className, true))
{
continue;
}
/** @var TaskInterface $o */
$o = new $className;
if ($o instanceof ContainerAwareInterface)
{
$o->setContainer($this->getContainer());
}
$name = $o->getMethodName();
$name = strtolower($name);
$this->handlers[$name] = $o;
}
}
}