Skip to content

Commit

Permalink
LEVEL 6の修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-gillingham committed Nov 2, 2023
1 parent 096e807 commit 7436c1d
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/Eccube/Entity/BaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ public function setPointConversionRate($pointConversionRate)
/**
* Get pointConversionRate
*
* @return string
* @return string|int|float
*/
public function getPointConversionRate()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Entity/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ public function setPoint($point)
/**
* Get point
*
* @return string
* @return string|int
*/
public function getPoint()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Entity/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getVersion()
/**
* Set source.
*
* @param string $source
* @param string|int $source
*
* @return Plugin
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Eccube/Service/Payment/PaymentResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class PaymentResult
{
/**
* @var array
* @var array<int, string>
*/
private $errors = [];

Expand Down Expand Up @@ -66,7 +66,7 @@ public function isSuccess()
/**
* 決済が失敗した場合のエラーの配列を返します.
*
* @return array
* @return array<int, string>
*/
public function getErrors()
{
Expand All @@ -76,7 +76,7 @@ public function getErrors()
/**
* 決済が失敗した場合のエラーの配列を設定します.
*
* @param array $errors
* @param array<int, string> $errors
*
* @return PaymentResult
*/
Expand Down
56 changes: 39 additions & 17 deletions src/Eccube/Service/PluginApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function getApiUrl()

/**
* @param mixed $apiUrl
* @return void
*/
public function setApiUrl($apiUrl)
{
Expand All @@ -91,8 +92,7 @@ public function setApiUrl($apiUrl)

/**
* Get master data: category
*
* @return array
* @return string|bool|array<string, string|int|array<int, string>>
*/
public function getCategory()
{
Expand All @@ -108,9 +108,8 @@ public function getCategory()
/**
* Get plugins list
*
* @param $data
*
* @return array
* @param array<string, string|int> $data
* @return array<string, string|int>
*
* @throws PluginApiException
*/
Expand All @@ -137,8 +136,7 @@ public function getPlugins($data)
/**
* Get purchased plugins list
*
* @return array
*
* @return array<int, array<string, string|int>>
* @throws PluginApiException
*/
public function getPurchased()
Expand All @@ -154,8 +152,7 @@ public function getPurchased()
/**
* Get recommended plugins list
*
* @return array($result, $info)
*
* @return array<int, array<string, string|int>>
* @throws PluginApiException
*/
public function getRecommended()
Expand All @@ -168,6 +165,10 @@ public function getRecommended()
return $this->buildPlugins($plugins);
}

/**
* @param array<int, array<string, string|int>> $plugins
* @return array<int, array<string, string|int>>
*/
private function buildPlugins(&$plugins)
{
/** @var Plugin[] $pluginInstalled */
Expand Down Expand Up @@ -215,7 +216,7 @@ private function isUpdate($pluginVersion, $remoteVersion)
*
* @param int|string $id Id or plugin code
*
* @return array
* @return array<string, string|int|array<int, string>>
*
* @throws PluginApiException
*/
Expand All @@ -229,26 +230,47 @@ public function getPlugin($id)
return $this->buildInfo($json);
}

/**
* @param Plugin $Plugin
* @return void
*/
public function pluginInstalled(Plugin $Plugin)
{
$this->updatePluginStatus('/status/installed', $Plugin);
}

/**
* @param Plugin $Plugin
* @return void
*/
public function pluginEnabled(Plugin $Plugin)
{
$this->updatePluginStatus('/status/enabled', $Plugin);
}

/**
* @param Plugin $Plugin
* @return void
*/
public function pluginDisabled(Plugin $Plugin)
{
$this->updatePluginStatus('/status/disabled', $Plugin);
}

/**
* @param Plugin $Plugin
* @return void
*/
public function pluginUninstalled(Plugin $Plugin)
{
$this->updatePluginStatus('/status/uninstalled', $Plugin);
}

/**
* @param string $url
* @param Plugin $Plugin
* @return void
*/
private function updatePluginStatus($url, Plugin $Plugin)
{
if ($Plugin->getSource()) {
Expand All @@ -263,9 +285,10 @@ private function updatePluginStatus($url, Plugin $Plugin)
* API request processing
*
* @param string $url
* @param array $data
* @param array<string, mixed> $data
* @param bool $post
*
* @return array
* @return string|bool
*
* @throws PluginApiException
*/
Expand Down Expand Up @@ -328,9 +351,8 @@ public function requestApi($url, $data = [], $post = false)
/**
* Get plugin information
*
* @param array $plugin
*
* @return array
* @param array<string, string|int|array<int, string>> $plugin
* @return array<string, string|int|array<int, string>>
*/
public function buildInfo(&$plugin)
{
Expand All @@ -341,8 +363,8 @@ public function buildInfo(&$plugin)

/**
* Check support version
*
* @param $plugin
* @param array<string, string|int|array<int, string|float>> $plugin
* @return void
*/
public function supportedVersion(&$plugin)
{
Expand Down
36 changes: 36 additions & 0 deletions src/Eccube/Service/PluginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,79 @@ class PluginContext
private const MODE_INSTALL = 'install';
private const MODE_UNINSTALL = 'uninstall';

/**
* @var string
*/
private $mode;

/**
* @var string|int
*/
private $code;

/**
* @var array<string, mixed>
*/
private $composerJson;

/**
* @var EccubeConfig
*/
private $eccubeConfig;

/**
* @param EccubeConfig $eccubeConfig
*/
public function __construct(EccubeConfig $eccubeConfig)
{
$this->eccubeConfig = $eccubeConfig;
}

/**
* @return bool
*/
public function isInstall()
{
return $this->mode === self::MODE_INSTALL;
}

/**
* @return bool
*/
public function isUninstall()
{
return $this->mode === self::MODE_UNINSTALL;
}

/**
* @return string
*/
public function setInstall()
{
return $this->mode = self::MODE_INSTALL;
}

/**
* @return string
*/
public function setUninstall()
{
return $this->mode = self::MODE_UNINSTALL;
}

/**
* @param string $code
* @return void
*/
public function setCode(string $code)
{
$this->code = $code;
}

/**
* @return array<string, mixed>
* @throws PluginException
*/
public function getComposerJson(): array
{
if ($this->composerJson) {
Expand All @@ -81,6 +113,10 @@ public function getComposerJson(): array
return $this->composerJson;
}

/**
* @return array<string, string>
* @throws PluginException
*/
public function getExtraEntityNamespaces(): array
{
$json = $this->getComposerJson();
Expand Down
Loading

0 comments on commit 7436c1d

Please sign in to comment.