Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Small updates & test with PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
back-2-95 committed Dec 2, 2021
1 parent fa26a45 commit fc16740
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:

build:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix:
php-versions: ['7.3','7.4','8.0']
php-versions: ['7.3','7.4','8.0','8.1']
composer-versions: ['v2']

steps:
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "druidfi/mona-plugin",
"type": "composer-plugin",
"description": "Mona Composer Plugin for Drupal 7 sites",
"minimum-stability": "dev",
"license": "MIT",
"authors": [
{
Expand All @@ -28,7 +27,7 @@
},
"require": {
"php": "^7.3 || ^8.0",
"composer-plugin-api": "^2.0",
"composer-plugin-api": "^2.0 || ^2.1",
"composer/installers": "^1.11 || ^2.0",
"cweagans/composer-patches": "^1.7",
"drush/drush": "^8.4"
Expand All @@ -39,7 +38,9 @@
},
"conflict": {
"drupal/core": "8.*",
"drupal/drupal": "<7.81",
"drupal/drupal": "<7.83",
"drush/drush": "<8.4"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
6 changes: 6 additions & 0 deletions src/Mona/Symlink.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function getOriginalTarget(): string
public function setOriginalTarget(string $target): self
{
$this->originalTarget = $target;

return $this;
}

Expand All @@ -69,6 +70,7 @@ public function getOriginalLink(): string
public function setOriginalLink(string $link): self
{
$this->originalLink = $link;

return $this;
}

Expand All @@ -88,6 +90,7 @@ public function getTarget(): string
public function setTarget(string $target): self
{
$this->target = $target;

return $this;
}

Expand All @@ -107,6 +110,7 @@ public function getLink(): string
public function setLink(string $link): self
{
$this->link = $link;

return $this;
}

Expand All @@ -126,6 +130,7 @@ public function isAbsolutePath(): bool
public function setAbsolutePath(bool $absolutePath): self
{
$this->absolutePath = $absolutePath;

return $this;
}

Expand All @@ -145,6 +150,7 @@ public function isForceCreate(): bool
public function setForceCreate(bool $forceCreate): self
{
$this->forceCreate = $forceCreate;

return $this;
}
}
7 changes: 6 additions & 1 deletion src/Mona/SymlinksFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function __construct(Event $event, Filesystem $filesystem)
public function process(string $webroot): array
{
$symlinksData = $this->getSymlinksData();

$symlinks = [];

foreach ($symlinksData as $target => $linkData) {
$linkData = str_replace('${webroot}', $webroot, $linkData);

Expand All @@ -55,6 +55,7 @@ public function process(string $webroot): array
if ($this->getConfig(static::THROW_EXCEPTION, $linkData, true)) {
throw $exception;
}

$this->event->getIO()->writeError(
sprintf(
' Error while process <comment>%s</comment>: <comment>%s</comment>',
Expand Down Expand Up @@ -123,6 +124,7 @@ protected function processSymlink(string $target, $linkData): ?Symlink
if ($this->getConfig(static::SKIP_MISSED_TARGET, $link)) {
return null;
}

throw new InvalidArgumentException(
sprintf('The target path %s does not exists', $targetPath)
);
Expand All @@ -142,6 +144,7 @@ protected function processSymlink(string $target, $linkData): ?Symlink
$link
)
);

return null;
}

Expand Down Expand Up @@ -187,11 +190,13 @@ protected function getSymlinksData(): array
protected function getLink($linkData): string
{
$link = '';

if (is_array($linkData)) {
$link = $linkData['link'] ?? '';
} elseif (is_string($linkData)) {
$link = $linkData;
}

return $link;
}
}
6 changes: 2 additions & 4 deletions src/Mona/SymlinksProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ public function processSymlink(Symlink $symlink): bool
if ($symlink->isAbsolutePath()) {
return @symlink($symlink->getTarget(), $symlink->getLink());
}

return $this->filesystem->relativeSymlink($symlink->getTarget(), $symlink->getLink());
}

protected function isToUnlink(string $path): bool
{
return
file_exists($path) ||
is_dir($path) ||
is_link($path);
return file_exists($path) || is_dir($path) || is_link($path);
}
}
4 changes: 2 additions & 2 deletions tests/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"require": {
"ckeditor/ckeditor": "4.10.1",
"druidfi/mona-plugin": "*",
"drupal/drupal": "^7.81",
"drupal/pathauto": "1.3"
"drupal/drupal": "^7.83",
"drupal/pathauto": "^1"
},
"repositories": [
{
Expand Down

0 comments on commit fc16740

Please sign in to comment.