-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Update API to suit its status as its own module #1
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# For more information about the properties used in | ||
# this file, please see the EditorConfig documentation: | ||
# http://editorconfig.org/ | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,js,json,css,scss,eslintrc,feature}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[composer.json] | ||
indent_size = 4 | ||
|
||
# Don't perform any clean-up on thirdparty files | ||
|
||
[thirdparty/**] | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/tests/php export-ignore | ||
/.tx export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.github export-ignore | ||
/*.dist export-ignore | ||
/phpcs.xml.dist export-ignore | ||
/.editorconfig export-ignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci: | ||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
composer.lock | ||
silverstripe-cache/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "silverstripe/template-engine", | ||
"description": "Template engine for rendering templates in Silverstripe CMS projects", | ||
"type": "silverstripe-vendormodule", | ||
"license": "BSD-3-Clause", | ||
"authors": [ | ||
{ | ||
"name": "Silverstripe", | ||
"homepage": "https://silverstripe.com" | ||
}, | ||
{ | ||
"name": "The Silverstripe Community", | ||
"homepage": "https://silverstripe.org" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.3", | ||
"silverstripe/framework": "^6" | ||
}, | ||
"require-dev": { | ||
"silverstripe/recipe-testing": "^4", | ||
"silverstripe/standards": "^1", | ||
"squizlabs/php_codesniffer": "^3", | ||
"phpstan/extension-installer": "^1.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"SilverStripe\\TemplateEngine\\": "src/", | ||
"SilverStripe\\TemplateEngine\\Tests\\": "tests/php/" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="SilverStripe"> | ||
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description> | ||
|
||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<!-- Show progress and output sniff names on violation, and add colours --> | ||
<arg value="p" /> | ||
<arg name="colors" /> | ||
<arg value="s" /> | ||
|
||
<!-- base rules are PSR-12 --> | ||
<rule ref="PSR12" > | ||
<!-- Current exclusions --> | ||
<!-- | ||
<exclude name="PSR1.Methods.CamelCapsMethodName" /> | ||
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" /> | ||
<exclude name="PSR2.Classes.PropertyDeclaration" /> | ||
<exclude name="PSR2.ControlStructures.SwitchDeclaration" /> <!-- causes php notice while linting --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will clean this up before marking ready-to-merge. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should clean it up then as this PR's in review? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! Sorry. I thought I'd forget that's why I added that comment lol. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaned up, and resolved linting failures from a local run. |
||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase" /> | ||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault" /> | ||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" /> | ||
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" /> | ||
<exclude name="Squiz.Scope.MethodScope" /> | ||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" /> | ||
<exclude name="Generic.Files.LineLength.TooLong" /> | ||
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" /> | ||
--> | ||
</rule> | ||
|
||
<!-- | ||
<rule ref="Squiz.Strings.ConcatenationSpacing"> | ||
<properties> | ||
<property name="spacing" value="1" /> | ||
<property name="ignoreNewlines" value="true"/> | ||
</properties> | ||
</rule> | ||
--> | ||
|
||
<!-- PHP-PEG generated file not intended for human consumption --> | ||
<exclude-pattern>*/SSTemplateParser.php$</exclude-pattern> | ||
</ruleset> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
parameters: | ||
paths: | ||
- src |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Default"> | ||
<directory>tests/php</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<?php | ||
|
||
namespace SilverStripe\View; | ||
namespace SilverStripe\TemplateEngine; | ||
|
||
/** | ||
* Defines an extra set of basic methods that can be used in templates | ||
* that are not defined on sub-classes of {@link ModelData}. | ||
*/ | ||
class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider | ||
class BasicIteratorSupport implements TemplateIteratorProvider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing |
||
{ | ||
/** | ||
* @var int | ||
|
GuySartorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm keeping the
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace SilverStripe\View; | ||
namespace SilverStripe\TemplateEngine\Exception; | ||
|
||
use Exception; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,29 +9,25 @@ parser. | |
It gets run through the php-peg parser compiler to have those comments turned into code that match parts of the | ||
template language, producing the executable version SSTemplateParser.php | ||
|
||
To recompile after changing this file, run this from the 'framework/View' directory via command line (in most cases | ||
this is: framework/src/View): | ||
To recompile after changing this file, run this from the 'src' directory via command line: | ||
|
||
php ../../thirdparty/php-peg/cli.php SSTemplateParser.peg > SSTemplateParser.php | ||
php ../thirdparty/php-peg/cli.php SSTemplateParser.peg > SSTemplateParser.php | ||
|
||
See the php-peg docs for more information on the parser format, and how to convert this file into SSTemplateParser.php | ||
|
||
This comment will not appear in the output | ||
*/ | ||
|
||
namespace SilverStripe\View; | ||
namespace SilverStripe\TemplateEngine; | ||
|
||
use SilverStripe\Core\Injector\Injector; | ||
use Parser; | ||
use InvalidArgumentException; | ||
use SilverStripe\TemplateEngine\Exception\SSTemplateParseException; | ||
|
||
// We want this to work when run by hand too | ||
if (defined('THIRDPARTY_PATH')) { | ||
require_once(THIRDPARTY_PATH . '/php-peg/Parser.php'); | ||
} else { | ||
$base = dirname(__FILE__); | ||
require_once($base.'/../thirdparty/php-peg/Parser.php'); | ||
} | ||
// Make sure to include the base parser code | ||
$base = dirname(__FILE__); | ||
require_once($base.'/../thirdparty/php-peg/Parser.php'); | ||
Comment on lines
-29
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That const was pointing to the |
||
|
||
/** | ||
* This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser | ||
|
@@ -936,7 +932,7 @@ class SSTemplateParser extends Parser implements TemplateParser | |
$arguments = $res['arguments']; | ||
|
||
// Note: 'type' here is important to disable subTemplates in SSTemplateEngine::getSubtemplateFor() | ||
$res['php'] = '$val .= \\SilverStripe\\View\\SSTemplateEngine::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getCurrentItem(), [' . | ||
$res['php'] = '$val .= \\SilverStripe\\TemplateEngine\\SSTemplateEngine::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getCurrentItem(), [' . | ||
implode(',', $arguments)."], \$scope, true);\n"; | ||
|
||
if ($this->includeDebuggingComments) { // Add include filename comments on dev sites | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from module standardiser, minus the bit about admin which isn't relevant here. Wanted it in here while I'm working to reduce cleanup required later.