AbstractLoggerRequest.php
8 months ago
ActivateRequest.php
8 months ago
DeactivateRequest.php
8 months ago
InstallRequest.php
8 months ago
OptInRequest.php
8 months ago
OptOutRequest.php
8 months ago
UninstallRequest.php
8 months ago
AbstractLoggerRequest.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Analyst\Http\Requests; |
| 4 | |
| 5 | use Analyst\ApiResponse; |
| 6 | use Analyst\Collector; |
| 7 | use Analyst\Contracts\RequestContract; |
| 8 | use Analyst\Contracts\RequestorContract; |
| 9 | |
| 10 | abstract class AbstractLoggerRequest implements RequestContract |
| 11 | { |
| 12 | /** |
| 13 | * @var Collector |
| 14 | */ |
| 15 | protected $collector; |
| 16 | |
| 17 | /** |
| 18 | * @var integer |
| 19 | */ |
| 20 | protected $id; |
| 21 | |
| 22 | /** |
| 23 | * @var string |
| 24 | */ |
| 25 | protected $path; |
| 26 | |
| 27 | public function __construct(Collector $collector, $pluginId, $path) |
| 28 | { |
| 29 | $this->collector = $collector; |
| 30 | $this->id = $pluginId; |
| 31 | $this->path = $path; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Cast request data to array |
| 36 | * |
| 37 | * @return array |
| 38 | */ |
| 39 | public function toArray() |
| 40 | { |
| 41 | return [ |
| 42 | 'plugin_id' => $this->id, |
| 43 | 'php_version' => $this->collector->getPHPVersion(), |
| 44 | 'wp_version' => $this->collector->getWordPressVersion(), |
| 45 | 'plugin_version' => $this->collector->getPluginVersion($this->path), |
| 46 | 'url' => $this->collector->getSiteUrl(), |
| 47 | 'sdk_version' => $this->collector->getSDKVersion(), |
| 48 | 'ip' => $this->collector->getServerIp(), |
| 49 | 'mysql_version' => $this->collector->getMysqlVersion(), |
| 50 | 'locale' => $this->collector->getSiteLanguage(), |
| 51 | 'current_theme' => $this->collector->getCurrentThemeName(), |
| 52 | 'active_plugins_list' => implode(', ', $this->collector->getActivePluginsList()), |
| 53 | 'email' => $this->collector->getGeneralEmailAddress(), |
| 54 | 'name' => $this->collector->getCurrentUserName() |
| 55 | ]; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Execute the request |
| 60 | * @param RequestorContract $requestor |
| 61 | * @return ApiResponse |
| 62 | */ |
| 63 | public abstract function execute(RequestorContract $requestor); |
| 64 | } |
| 65 |