Skip to content

Commit

Permalink
Initial version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
olivertar committed Jul 3, 2020
0 parents commit 84183b8
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
10 changes: 10 additions & 0 deletions Plugin/DirectoryValidator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Orangecat\TemplateSymlinks\Plugin;

class DirectoryValidator
{
public function afterIsValid(\Magento\Framework\Filesystem\Directory\PathValidator $subject, $result)
{
return true;
}
}
10 changes: 10 additions & 0 deletions Plugin/FileValidator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Orangecat\TemplateSymlinks\Plugin;

class FileValidator
{
public function aroundIsValid(\Magento\Framework\View\Element\Template\File\Validator $subject, $proceed, $filename)
{
return $proceed($filename) || file_exists($filename);
}
}
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# M2 Template Link

Magento does not allow symlinks to templates (.phtml) that are outside of the Magento filesystem. This module allows modifying this characteristic.

This module will allow us to keep the code under development isolated from the Magento installation.

It is especially useful when you need to test a module in different Magento versions.

This module should only be used for development purposes as it violates some security measures to fulfill its purpose.

This module has been developed for Magento +2.3.x

## Installation

The extension can be installed via `composer`. To proceed, run these commands in your terminal:

```
cd /to/root/magento/install
composer require orangecat/templatesymlinks
php bin/magento module:enable Orangecat_TemplateSymlinks
php bin/magento setup:upgrade
```
If you need to use it in production mode, these commands will also be necessary:
```
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```

## Note
You must first enable symlinks by going to Admin > Stores > Configuration > Advanced > Developer > Template Settings and setting the Allow Symlinks option to Yes.

## Symlink
Example of how to create a Symlink

ln -s /path/to/your/module/under/development/directory/Vendor/YorModuleName YorModuleName
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "orangecat/templatesymlinks",
"description": "Allows reaching templates with Symlinks",
"require": {
"php": "~7.1.3||~7.2.0||~7.3.0"
},
"type": "magento2-module",
"version": "1.0.0",
"authors": [
{
"name": "Oliverio Gombert",
"email": "olivertar@gmail.com",
"homepage": "http://olivert.com.ar",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"Orangecat\\TemplateSymlinks\\": ""
},
"files": [
"registration.php"
]
}
}
9 changes: 9 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\Filesystem\Directory\PathValidator">
<plugin name="orangecat_templatesymlink_view_element_template_directory_validator" type="Orangecat\TemplateSymlinks\Plugin\DirectoryValidator" sortOrder="10" disabled="false"/>
</type>
<type name="Magento\Framework\View\Element\Template\File\Validator">
<plugin name="orangecat_templatesymlink_view_element_template_file_validator" type="Orangecat\TemplateSymlinks\Plugin\FileValidator" sortOrder="10" disabled="false"/>
</type>
</config>
4 changes: 4 additions & 0 deletions etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Orangecat_TemplateSymlinks"/>
</config>
6 changes: 6 additions & 0 deletions registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Orangecat_TemplateSymlinks',
__DIR__
);

0 comments on commit 84183b8

Please sign in to comment.