Skip to content

Commit

Permalink
Merge pull request #8 from hokoo/v3.1
Browse files Browse the repository at this point in the history
v3.1
  • Loading branch information
hokoo authored Aug 27, 2024
2 parents 01a97ac + 40dadbb commit 34087e7
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 48 deletions.
1 change: 0 additions & 1 deletion .env.template

This file was deleted.

6 changes: 6 additions & 0 deletions dev/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PHP_VERSION=8.3
XDEBUG_PORT=9019
XDEBUG_MODE=debug,develop
XDEBUG_IDE_KEY=PHPSTORM
XDEBUG_IDE_CONFIG=serverName=Docker
EXTENSIONS_DISABLE=""
4 changes: 4 additions & 0 deletions dev/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

[ -f ./.env ] || cp ./dev/.env.template ./.env
echo ".env ok"
5 changes: 5 additions & 0 deletions dev/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_port=9019
xdebug.idekey=PHPSTORM
xdebug.client_host=host.docker.internal
24 changes: 18 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ version: '3.8'

services:
php:
build:
context: .
args:
- PHP_VERSION=${PHP_VERSION}
container_name: php
image: wodby/php:${PHP_VERSION}
working_dir: /srv/web
container_name: templater-php
volumes:
- .:/srv/web
- ./dev/php.ini:/usr/local/etc/php/conf.d/z-php-sp-overrides.ini
environment:
- XDEBUG_MODE=off
XDEBUG_CONFIG: client_host=host.docker.internal
XDEBUG_MODE: $XDEBUG_MODE
PHP_XDEBUG: 1
PHP_XDEBUG_DEFAULT_ENABLE: 1
PHP_IDE_CONFIG: $XDEBUG_IDE_CONFIG
PHP_XDEBUG_CLIENT_PORT: $XDEBUG_PORT
PHP_XDEBUG_IDEKEY: $XDEBUG_IDE_KEY
PHP_EXTENSIONS_DISABLE: $EXTENSIONS_DISABLE
ports:
- "9000:9000"
networks:
- itron-network

networks:
itron-network:
driver: bridge
21 changes: 0 additions & 21 deletions dockerfile

This file was deleted.

18 changes: 18 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
init:
bash ./dev/init.sh

docker.up:
docker-compose -p itron-templater up -d

docker.down:
docker-compose -p itron-templater down

docker.build.php:
docker-compose -p itron-templater up -d --build php

connect.php:
docker-compose -p itron-templater exec php bash

tests.php.run:
docker-compose -p itron-templater exec php vendor/bin/phpunit

4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
>
<php>
<const name="DOING_TESTS" value="1" />

<ini name="xdebug.mode" value="debug"/>
<ini name="xdebug.client_port" value="9019"/>
<ini name="xdebug.idekey" value="PHPSTORM"/>
</php>
<testsuites>
<testsuite name="WP_Lock concurrency mutexes for WordPress test suite">
Expand Down
23 changes: 13 additions & 10 deletions src/Templater.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,18 @@ private function get_repeaters( $subject ) {
'clear' => [],
];

foreach ( $m['content'] as $found ):
foreach ( $m['content'] as $index => $found ):
$inner = $this->get_repeaters( $found );
if ( is_array( $inner ) ) :
$result['tag'] = array_merge( $result['tag'], $inner['result']['tag'] );
$result['content'] = array_merge( $result['content'], $inner['result']['content'] );
$result['clear'] = array_merge( $result['clear'],
[ str_replace( $inner['data'][0], '', $found ) ],
$inner['result']['clear'] );
$result['clear'] = array_merge(
$result['clear'],
[ $m['tag'][$index] => str_replace( $inner['data'][0], '', $found ) ],
$inner['result']['clear'],
);
else :
$result['clear'] [] = $found;
$result['clear'][ $m['tag'][$index] ] = $found;
endif;
endforeach;

Expand All @@ -167,14 +169,15 @@ private function get_repeaters_data( $data, $context ) {
}
endforeach;
}
$substr .= ( false !== $key = array_search( $row['tag'], $context['result']['tag'] ) ) ?
$this->format( $context['result']['clear'][ $key ], $content ) :
( is_array( $content ) ? implode( '', $content ) : $content );

$substr .= $this->format(
$context['result']['clear'][ $context['result']['tag'][ array_search( $row['tag'], $context['result']['tag'] ) ] ],
$content
);
elseif ( ! empty( $content ) ) :
$substr .= ( is_array( $content ) ? implode( '', $content ) : $content );
elseif ( ! empty( $row['tag'] ) ) :
$substr .= ( false !== $key = array_search( $row['tag'], $context['result']['tag'] ) ) ?
$context['result']['clear'][ $key ] : '';
$substr .= $context['result']['clear'][ $context['result']['tag'][ array_search( $row['tag'], $context['result']['tag'] ) ] ];
endif;
endforeach;
$out = $substr;
Expand Down
Loading

0 comments on commit 34087e7

Please sign in to comment.