Skip to content

Commit

Permalink
Merge pull request #477 from sallaberry/#476-Crud_Improvements
Browse files Browse the repository at this point in the history
#476 crud improvements
  • Loading branch information
astorm authored Aug 17, 2019
2 parents 868299b + 2d851fb commit 5622bcf
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 59 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ before_script:
# test that magento is installed
- curl "$PULSESTORM_MAGE2_FAKE_URL/index.php"

# phpcs install and generating a module for same

# generate the code for phpcs
- ../travis/for-lint.sh

# leave m2 folder
- cd ..

Expand All @@ -110,6 +105,11 @@ before_script:
- sudo mv pestle.phar /usr/bin
- sudo chmod +x /usr/bin/pestle.phar
- pestle.phar hello_world

# cd to magento 2 folder, generate the code for phpcs and leave
- cd magento2
- ../travis/for-lint.sh
- cd ..
script:
# unit tests
- vendor/bin/phpunit tests
Expand All @@ -119,4 +119,4 @@ script:
# run phpcs
- cd ../phpcs
- find ../magento2/app/code/Pulsestorm
- vendor/bin/phpcs vendor/bin/phpcs --standard=vendor/magento/magento-coding-standard/Magento2/ ../magento2/app/code/Pulsestorm/Travis
- vendor/bin/phpcs vendor/bin/phpcs -s --standard=vendor/magento/magento-coding-standard/Magento2/ ../magento2/app/code/Pulsestorm/Travis
34 changes: 31 additions & 3 deletions modules/pulsestorm/cli/code_generation/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function processNewColumnAttributes($array)

$normalize_whitespace = "/\s+/";
$attrs = preg_replace($normalize_whitespace, " ", $attrs);
$attrs = substr($attrs, 0, -3) . ' ]';

return $attrs;
}
Expand Down Expand Up @@ -240,9 +241,16 @@ function templateInterface($interface, $functions=[])
$class = trim($interface, '\\');
$parts = explode('\\',$class);
$name = array_pop($parts);
$phpDoc = '/**'. "\n" .
' * Interface ' . $name . "\n" .
' *' . "\n" .
' * @api' . "\n" .
' */';

$template = '<' . '?' . 'php' . "\n" .
'namespace ' . implode('\\',$parts) . ";\n" .
"interface $name \n{\n";
"\n" .$phpDoc . "\n" .
"interface $name\n{\n";
foreach($functions as $function)
{
$template .=
Expand Down Expand Up @@ -275,21 +283,41 @@ function createClassTemplate($class, $extends=false, $implements=false, $include
$class = trim($class, '\\');
$parts = explode('\\',$class);
$name = array_pop($parts);
$phpDoc = '/**'. "\n" .
' * Class ' . $name . "\n" .
' */';

$template = '<' . '?' . 'php' . "\n" .
'namespace ' . implode('\\',$parts) . ";\n";
$template .= "\n";

if($includeUse)
{
$template .= '<$use$>' . "\n";
$template .= '<$use$>' . "\n\n";
}
$template .= $phpDoc . "\n";
$template .= "class $name";
if($extends)
{
$template .= " extends $extends";
}
if($implements)
{
$template .= " implements $implements";
if (strpos($implements, ',') !== false) {
$implements = explode(',', $implements);
$i = count($implements);
$template .= " implements" . "\n";
foreach ($implements as $implement) {
$template .= ' ' . $implement;
if ($i - 1 > 0) {
$template .= ',' . "\n";
$i--;
}
}
}
else {
$template .= " implements $implements";
}
}
$template .= "\n" .
'{' . '<$body$>' . '}' . "\n";
Expand Down
Loading

0 comments on commit 5622bcf

Please sign in to comment.