Skip to content

Commit

Permalink
Merge branch 'roots:main' into fse
Browse files Browse the repository at this point in the history
  • Loading branch information
dsturm committed Jan 26, 2024
2 parents 9d93c3b + 25408e2 commit 7786fe5
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ else
cat /roots/app/composer.json | jq ".repositories += [{ type: \"path\", url: \"${WORKSPACE_FOLDER}\" }]" > /roots/app/composer.tmp \
&& rm /roots/app/composer.json \
&& mv /roots/app/composer.tmp /roots/app/composer.json \
&& composer require -d /roots/app $(cat "${WORKSPACE_FOLDER}/composer.json" | jq '.name' | tr -d '"') --no-interaction
&& composer require -d /roots/app $(cat "${WORKSPACE_FOLDER}/composer.json" | jq '.name' | tr -d '"') --no-interaction -W
fi

composer remove -d /roots/app wpackagist-theme/twentytwentyfour
composer require -d /roots/app roots/soil
composer require -d /roots/app roots/acorn-prettify -W

# Set filesystem permissions
sudo chown -R vscode:www-data /roots/app
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Acorn is a framework for integrating Laravel within WordPress.
| illuminate/console | 🟢 | |
| illuminate/container | 🟢 | |
| illuminate/contracts | 🟢 | |
| illuminate/contracts | 🟢 | |
| illuminate/database | 🟢 | |
| illuminate/encryption | 🟢 | |
| illuminate/events | 🟢 | |
Expand Down
2 changes: 1 addition & 1 deletion src/Roots/Acorn/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected function bindPathsInContainer()
/**
* Get the path to the bootstrap directory.
*
* @param string $path Optionally, a path to append to the bootstrap path
* @param string $path Optionally, a path to append to the bootstrap path
* @return string
*/
public function bootstrapPath($path = '')
Expand Down
10 changes: 5 additions & 5 deletions src/Roots/Acorn/Assets/Asset/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Asset implements AssetContract
/**
* Get asset from manifest
*
* @param string $path Local path
* @param string $uri Remote URI
* @param string $path Local path
* @param string $uri Remote URI
*/
public function __construct(string $path, string $uri)
{
Expand Down Expand Up @@ -86,7 +86,7 @@ public function contents(): string
/**
* Get the relative path to the asset.
*
* @param string $basePath Base path to use for relative path.
* @param string $basePath Base path to use for relative path.
*/
public function relativePath(string $basePath): string
{
Expand All @@ -112,7 +112,7 @@ public function base64()
/**
* Get data URL of asset.
*
* @param string $mediatype MIME content type
* @param string $mediatype MIME content type
*/
public function dataUrl(?string $mediatype = null): string
{
Expand All @@ -130,7 +130,7 @@ public function dataUrl(?string $mediatype = null): string
/**
* Get data URL of asset.
*
* @param string $mediatype MIME content type
* @param string $mediatype MIME content type
*/
public function dataUri(?string $mediatype = null): string
{
Expand Down
14 changes: 7 additions & 7 deletions src/Roots/Acorn/Assets/Asset/TextAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TextAsset extends Asset
/**
* Get character encoding.
*
* @param string $fallback Fallback if charset cannot be determined
* @param string $fallback Fallback if charset cannot be determined
*/
public function charset($fallback = 'UTF-8'): string
{
Expand All @@ -36,9 +36,9 @@ public function charset($fallback = 'UTF-8'): string
/**
* Get data URL of asset.
*
* @param string $mediatype MIME content type
* @param string $charset Character encoding
* @param string $urlencode List of characters to be percent-encoded
* @param string $mediatype MIME content type
* @param string $charset Character encoding
* @param string $urlencode List of characters to be percent-encoded
*/
public function dataUrl(?string $mediatype = null, ?string $charset = null, string $urlencode = '%\'"'): string
{
Expand Down Expand Up @@ -68,9 +68,9 @@ public function dataUrl(?string $mediatype = null, ?string $charset = null, stri
/**
* Get data URL of asset.
*
* @param string $mediatype MIME content type
* @param string $charset Character encoding
* @param string $urlencode List of characters to be percent-encoded
* @param string $mediatype MIME content type
* @param string $charset Character encoding
* @param string $urlencode List of characters to be percent-encoded
*/
public function dataUri(?string $mediatype = null, ?string $charset = null, string $urlencode = '%\'"'): string
{
Expand Down
6 changes: 3 additions & 3 deletions src/Roots/Acorn/Assets/AssetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class AssetFactory
/**
* Create Asset instance.
*
* @param string $path Local path
* @param string $uri Remote URI
* @param string $type Asset type
* @param string $path Local path
* @param string $uri Remote URI
* @param string $type Asset type
*/
public static function create(string $path, string $uri, ?string $type = null): AssetContract
{
Expand Down
19 changes: 19 additions & 0 deletions src/Roots/Acorn/Assets/Concerns/Enqueuable.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,25 @@ public function localize($name, $object)
return $this;
}

/**
* Add script translations to be used by the bundle
*
* @param string $domain
* @param string $path
* @return $this
*/
public function translate($domain = null, $path = null)
{
$domain ??= wp_get_theme()->get('TextDomain');
$path ??= lang_path();

$this->js()->keys()->each(function ($handle) use ($domain, $path) {
wp_set_script_translations("{$this->id}/{$handle}", $domain, $path);
});

return $this;
}

/**
* Merge two or more arrays.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Roots/Acorn/Assets/Contracts/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function contents();
/**
* Get the relative path to the asset.
*
* @param string $base_path Base path to use for relative path.
* @param string $base_path Base path to use for relative path.
*/
public function relativePath(string $base_path): string;

Expand Down
2 changes: 1 addition & 1 deletion src/Roots/Acorn/Assets/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function pipeline(array $config): array
/**
* Opens a JSON manifest file from the local file system
*
* @param string $jsonManifest Path to .json file
* @param string $jsonManifest Path to .json file
*/
protected function getJsonManifest(string $jsonManifest): array
{
Expand Down
5 changes: 2 additions & 3 deletions src/Roots/Acorn/Bootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ protected function handleRequest(
if (
$response instanceof \Symfony\Component\HttpFoundation\Response
&& ! $response->isServerError()
&& $response->getStatusCode() >= 400
) {
return;
}
Expand Down Expand Up @@ -360,8 +359,8 @@ protected function normalizeApplicationPath($path, $default = null)
}

return Str::startsWith($env, $this->absoluteApplicationPathPrefixes)
? $env
: $this->basePath($env);
? $env
: $this->basePath($env);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/Roots/Acorn/Sage/ViewFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(FileViewFinder $finder, Filesystem $files, $path = '
{
$this->finder = $finder;
$this->files = $files;
$this->path = realpath($path ? $path : get_theme_file_path());
$this->path = realpath($path ?: get_theme_file_path());
}

/**
Expand All @@ -55,9 +55,10 @@ public function locate($file)
}

return $this->getRelativeViewPaths()
->flatMap(fn ($viewPath) => collect($this->finder->getPossibleViewFilesFromPath($file))
->merge([$file])
->map(fn ($file) => "{$viewPath}/{$file}")
->flatMap(
fn ($viewPath) => collect($this->finder->getPossibleViewFilesFromPath($file))
->merge([$file])
->map(fn ($file) => "{$viewPath}/{$file}")
)
->unique()
->map(fn ($file) => trim($file, '\\/'))
Expand Down
6 changes: 3 additions & 3 deletions src/Roots/Acorn/View/FileViewFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FileViewFinder extends FileViewFinderBase
/**
* Get possible relative locations of view files
*
* @param string $path Absolute or relative path to possible view file
* @param string $path Absolute or relative path to possible view file
* @return string[]
*/
public function getPossibleViewFilesFromPath($path)
Expand All @@ -22,7 +22,7 @@ public function getPossibleViewFilesFromPath($path)
/**
* Get possible view name based on path
*
* @param string $path Absolute or relative path to possible view file
* @param string $path Absolute or relative path to possible view file
* @return string
*/
public function getPossibleViewNameFromPath($file)
Expand Down Expand Up @@ -60,7 +60,7 @@ public function getPossibleViewNameFromPath($file)
/**
* Remove recognized extensions from path
*
* @param string $file relative path to view file
* @param string $file relative path to view file
* @return string view name
*/
protected function stripExtensions($path)
Expand Down
4 changes: 2 additions & 2 deletions tests/Test/Concerns/SupportsGlobalStubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ trait SupportsGlobalStubs
/**
* Create stubs and spies for global functions.
*
* @param string $fn The name of the global function
* @param null|callable $callable The real function to monitor
* @param string $fn The name of the global function
* @param null|callable $callable The real function to monitor
*/
protected function stub(string $fn, ?callable $callable = null): MockeryCallableMock
{
Expand Down

3 comments on commit 7786fe5

@ARehmanMahi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this huge feature ALONE.

@dsturm
Copy link
Contributor Author

@dsturm dsturm commented on 7786fe5 Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much - but I'm actually not working on it alone. @strarsis has started the work on this and has made great progress. My fork has only optimised it even more.

For my projects everything works quite well so far - but I think to make it available to the general public, further testing / customisation might be necessary.

@ARehmanMahi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought these 2 are different, seemed the one by startsis didn't had more activity. Appreciate both contributors. Am just curious to see the progress, though I don't understand a bit whats going on haha, noob alert.

Please sign in to comment.