Skip to content

Commit 381cda5

Browse files
authored
Merge pull request #102 from ticktackk/develop
1.3.5
2 parents 2de8ae5 + 3601fd2 commit 381cda5

19 files changed

+179
-197
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
==========================
33

4+
## 1.3.5 (`1030570`)
5+
6+
- **Change:** Improvement to how `XF\PermissionCache` class is extended (#99) (Thanks @Xon)
7+
- **Change:** Disable the "View template modifications" feature of this add-on if standard library 1.5.0+ is detected (#101)
8+
- **Fix:** Many hard-coded text instead of using phrases in "View template modifications" page (#100)
9+
- General code improvements and compatibility fixes
10+
411
## 1.3.4 (`1030470`)
512

613
- **Fix:** Testing template modification for specific style does not work (#97)

Cli/Command/EntityFromTable.php

Lines changed: 16 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44

55
use Closure;
66
use Symfony\Component\Console\Command\Command;
7-
use Symfony\Component\Console\Helper\ProcessHelper;
87
use Symfony\Component\Console\Helper\QuestionHelper;
8+
use Symfony\Component\Console\Input\ArrayInput;
99
use Symfony\Component\Console\Input\InputArgument;
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Input\InputOption;
1212
use Symfony\Component\Console\Output\OutputInterface;
1313
use Symfony\Component\Console\Question\Question;
14-
use Symfony\Component\Process\Exception\ProcessFailedException;
15-
use Symfony\Component\Process\PhpExecutableFinder;
16-
use Symfony\Component\Process\Process;
17-
use Symfony\Component\Process\ProcessBuilder;
1814
use XF\Cli\Command\AddOnActionTrait;
1915
use XF\Cli\Command\Development\RequiresDevModeTrait;
2016
use XF\Util\File;
@@ -45,7 +41,7 @@ protected function configure() : void
4541
'table to inspect'
4642
)
4743
->addArgument(
48-
'RelationName',
44+
'name',
4945
InputArgument::REQUIRED,
5046
'The entity\'s name'
5147
)
@@ -58,10 +54,12 @@ protected function configure() : void
5854
}
5955

6056
/**
61-
* @param InputInterface $input
57+
* @param InputInterface $input
6258
* @param OutputInterface $output
6359
*
6460
* @return int
61+
*
62+
* @throws \Exception
6563
*/
6664
protected function execute(InputInterface $input, OutputInterface $output) : int
6765
{
@@ -94,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int
9492
$output->writeln('');
9593
}
9694

97-
$name = $input->getArgument('RelationName');
95+
$name = $input->getArgument('name');
9896
if (!$name)
9997
{
10098
$question = new Question('<question>Enter the relationship name for the entity:</question> ');
@@ -252,20 +250,20 @@ public static function getStructure(Structure \$structure)
252250
TEMPLATE;
253251
$entityName = "{$namespace}:{$name}";
254252
$entityName = str_replace('/', '\\', $entityName);
253+
File::writeFile($filename, $template, false);
255254

256255
$output->writeln("Writing entity for {$entityName}");
257-
echo $template . "\n\n";
258-
File::writeFile($filename, $template, false);
256+
$output->writeln($template);
259257

260-
$this->runSubAction($output, [
261-
'xf-dev:entity-class-properties',
262-
$entityName
263-
]);
258+
$command = $this->getApplication()->find('xf-dev:entity-class-properties');
259+
$childInput = new ArrayInput(['addon-or-entity' => $entityName]);
260+
$command->run($childInput, $output);
261+
$output->writeln('');
264262

265-
$this->runSubAction($output, [
266-
'tdt-addon:generate-schema-entity',
267-
$entityName
268-
]);
263+
$command = $this->getApplication()->find('tck-dt:generate-schema-entity');
264+
$childInput = new ArrayInput(['id' => $entityName]);
265+
$command->run($childInput, $output);
266+
$output->writeln('');
269267

270268
return 0;
271269
}
@@ -397,56 +395,6 @@ protected function parseSqlType(string $sqlType) : array
397395
return [$type, $len, $allowedValues];
398396
}
399397

400-
/**
401-
* @param OutputInterface $output
402-
* @param array $args
403-
*/
404-
public function runSubAction(OutputInterface $output, array $args = []) : void
405-
{
406-
$execFinder = new PhpExecutableFinder();
407-
408-
$builderOptions = [
409-
$execFinder->find(false),
410-
\XF::getRootDirectory() . DIRECTORY_SEPARATOR . 'cmd.php',
411-
'-n'
412-
];
413-
$builderOptions = \array_merge($builderOptions, $args);
414-
415-
if ($verbosityOption = $this->getVerbosityOption($output->getVerbosity()))
416-
{
417-
$builderOptions[] = $verbosityOption;
418-
}
419-
420-
$process = new Process($builderOptions);
421-
$process->setTimeout(null);
422-
423-
/** @var ProcessHelper $processHelper */
424-
$processHelper = $this->getHelper('process');
425-
426-
try
427-
{
428-
$processHelper->mustRun($output, $process, null, function ($type, $data) use ($output)
429-
{
430-
if ($type === Process::OUT)
431-
{
432-
$output->write($data);
433-
}
434-
// Note that progress bar output is in Process::ERR/stderr, but they get streamed to this callback
435-
// interleaved, so displaying both is difficult. Thus, we need to only display stuff sent stdout.
436-
});
437-
}
438-
catch (ProcessFailedException $e)
439-
{
440-
$process = $e->getProcess();
441-
if ($process->getExitCode() === 222)
442-
{
443-
// This indicates that the sub-process threw an exception. It will have been printed and logged
444-
// so don't trigger the normal exception handling. However, we can't continue so exit.
445-
exit(1);
446-
}
447-
}
448-
}
449-
450398
/**
451399
* @param $key
452400
*

Cli/Command/Exception/InvalidAddOnQuestionFieldAnswerException.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

Cli/Command/GenerateSchemaEntity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int
5151
{
5252
$entity = \XF::em()->create($id);
5353
}
54+
/** @noinspection PhpUnusedLocalVariableInspection */
5455
catch (\Exception $e)
5556
{
5657
$class = \XF::stringToClass($id, '%s\Entity\%s');

Entity/EmailLog.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@
66
use XF\Mvc\Entity\Structure as EntityStructure;
77

88
/**
9-
* Class EmailLog
10-
*
11-
* @package TickTackk\DeveloperTools\Entity
12-
*
139
* COLUMNS
1410
* @property int|null email_id
1511
* @property string subject
1612
* @property int log_date
1713
* @property string return_path
18-
* @property array<string, string> sender
19-
* @property array<string, string> from
20-
* @property string[] reply_to
21-
* @property string[] to
22-
* @property string[] cc
23-
* @property string[] bcc
24-
* @property string html_message
25-
* @property string text_message
14+
* @property array|null|null sender
15+
* @property array|null from
16+
* @property array|null|null reply_to
17+
* @property array|null to
18+
* @property array|null|null cc
19+
* @property array|null|null bcc
20+
* @property string|null html_message
21+
* @property string|null text_message
2622
*/
2723
class EmailLog extends Entity
2824
{

Listener.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
namespace TickTackk\DeveloperTools;
44

5-
use TickTackk\DeveloperTools\XF\PermissionCache as ExtendedPermissionCache;
65
use TickTackk\DeveloperTools\XF\Template\Templater as ExtendedTemplater;
76
use XF\App as BaseApp;
8-
use XF\Container;
97
use XF\Http\Response;
108
use XF\Mvc\Dispatcher;
119
use XF\Mvc\Reply\AbstractReply;
1210
use XF\Mvc\Renderer\AbstractRenderer;
11+
use XF\PermissionCache;
1312
use XF\Util\File as FileUtil;
1413

1514
/**
@@ -28,7 +27,15 @@ class Listener
2827
* @param AbstractRenderer $renderer Renderer object.
2928
* @param Response $response HTTP Response object.
3029
*/
31-
public static function dispatcherPostRender(Dispatcher $dispatcher, ?string &$content, AbstractReply $reply, AbstractRenderer $renderer, Response $response) : void
30+
public static function dispatcherPostRender
31+
(
32+
/** @noinspection PhpUnusedParameterInspection */
33+
Dispatcher $dispatcher,
34+
?string &$content,
35+
AbstractReply $reply,
36+
AbstractRenderer $renderer,
37+
Response $response
38+
) : void
3239
{
3340
if (!\is_string($content))
3441
{
@@ -71,11 +78,11 @@ public static function dispatcherPostRender(Dispatcher $dispatcher, ?string &$co
7178
*/
7279
public static function appSetup(BaseApp $app) : void
7380
{
74-
$container = $app->container();
75-
76-
$container['permission.cache'] = function (Container $container)
81+
$app->offsetSet('permission.cache', function ($c) use ($app)
7782
{
78-
return new ExtendedPermissionCache($container['db']);
79-
};
83+
$class = $app->extendClass(PermissionCache::class);
84+
85+
return new $class($c['db']);
86+
});
8087
}
8188
}

Service/Listener/Creator.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,12 @@ class {$listenerClass}
163163
PHP;
164164
}
165165

166-
/**
167-
* @param string $listenerMethod
168-
* @param string $indent
169-
*
170-
* @return string
171-
*/
172-
public function getListenerMethodBlock(string $listenerMethod, string $indent = null)
166+
public function getListenerMethodBlock
167+
(
168+
/** @noinspection PhpUnusedParameterInspection */
169+
string $listenerMethod,
170+
string $indent = null
171+
) : string
173172
{
174173
$codeEvent = $this->getCodeEvent();
175174

0 commit comments

Comments
 (0)