Skip to content

Commit

Permalink
Merge pull request #1353 from phalcon/3.4.x
Browse files Browse the repository at this point in the history
3.4.7
  • Loading branch information
Jeckerson authored Nov 3, 2019
2 parents 0afdc50 + 4b521f6 commit 730e542
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 28 deletions.
2 changes: 1 addition & 1 deletion scripts/Phalcon/Devtools/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ class Version extends PhVersion
*/
protected static function _getVersion()
{
return [3, 4, 6, 0, 0];
return [3, 4, 7, 0, 0];
}
}
10 changes: 9 additions & 1 deletion scripts/Phalcon/Web/Tools/Controllers/ScaffoldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace WebTools\Controllers;

use PDOException;
use Phalcon\Text;
use Phalcon\Builder\Scaffold;
use Phalcon\Mvc\Controller\Base;
Expand Down Expand Up @@ -107,10 +108,17 @@ public function generateAction()
$this->tag->setDefault('templatesPath', $templatesPath);
$this->tag->setDefault('schema', $this->dbUtils->resolveDbSchema());

try {
$tables = $this->dbUtils->listTables();
} catch (PDOException $PDOException) {
$tables = [];
$this->flash->error($PDOException->getMessage());
}

$this->view->setVars(
[
'page_subtitle' => 'Generate code from template',
'tables' => $this->dbUtils->listTables(),
'tables' => $tables,
'template_path' => $templatesPath,
'templateEngines' => [
'volt' => 'Volt',
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/controllers/edit.volt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ content() }}
{{ flashSession.output() }}
<div class="box box-success">
<form role="form" name="edit-controller" method="post" action="{{ url.get("/webtools.php?_url=/controllers/update") }}">
<form role="form" name="edit-controller" method="post" action="{{ url.get(webtools_uri ~ "?_url=/controllers/update") }}">
<div class="box-header with-border">
<p class="pull-left">{{ controller_name }} - [{{ controller_path }}]</p>
{{ submit_button("Save", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/controllers/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-controller" method="post" action="{{ url.get("/webtools.php?_url=/controllers/generate") }}">
<form role="form" class="form-horizontal" name="generate-controller" method="post" action="{{ url.get(webtools_uri ~ "?_url=/controllers/generate") }}">
<div class="box-header with-border">
<p class="pull-left">{{ controller_name }} - [{{ controller_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Web/Tools/Views/controllers/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="box-header">
<h3 class="box-title">Controllers List</h3>
{{ link_to("/webtools.php?_url=/controllers/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
{{ link_to(webtools_uri ~ "?_url=/controllers/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
Expand Down Expand Up @@ -41,7 +41,7 @@
<td>{{ controller.owner }}</td>
<td>{{ controller.modified_time }}</td>
<td>
{{ link_to("/webtools.php?_url=/controllers/edit/" ~ rawurlencode(controller.filename),
{{ link_to(webtools_uri ~ "?_url=/controllers/edit/" ~ rawurlencode(controller.filename),
'<i class="fa fa-pencil"></i>', 'class': 'btn btn-default btn-xs') }}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/migrations/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get("/webtools.php?_url=/migrations/generate") }}">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get(webtools_uri ~ "?_url=/migrations/generate") }}">
<div class="box-header with-border">
<p class="pull-left">New model will be placed at: [{{ migration_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/migrations/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="box-header">
<h3 class="box-title">Migrations List</h3>
{{ link_to("/webtools.php?_url=/migrations/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
{{ link_to(webtools_uri ~ "?_url=/migrations/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover table-bordered">
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/migrations/run.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get("/webtools.php?_url=/migrations/run") }}">
<form role="form" class="form-horizontal" name="generate-migration" method="post" action="{{ url.get(webtools_uri ~ "?_url=/migrations/run") }}">
<div class="box-header with-border">
<p class="pull-left">Migrations from: [{{ migration_path }}]</p>
{{ submit_button("Run", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/models/edit.volt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ content() }}
{{ flashSession.output() }}
<div class="box box-success">
<form role="form" name="edit-model" method="post" action="{{ url.get("/webtools.php?_url=/models/update") }}">
<form role="form" name="edit-model" method="post" action="{{ url.get(webtools_uri ~ "?_url=/models/update") }}">
<div class="box-header with-border">
<p class="pull-left">{{ model_name }} - [{{ model_path }}]</p>
{{ submit_button("Save", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/models/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-model" method="post" action="{{ url.get("/webtools.php?_url=/models/generate") }}">
<form role="form" class="form-horizontal" name="generate-model" method="post" action="{{ url.get(webtools_uri ~ "?_url=/models/generate") }}">
<div class="box-header with-border">
<p class="pull-left">New model will be placed at: [{{ model_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Web/Tools/Views/models/index.volt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="box">
<div class="box-header">
<h3 class="box-title">Models List</h3>
{{ link_to("/webtools.php?_url=/models/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
{{ link_to(webtools_uri ~ "?_url=/models/generate", "Generate", 'class': 'btn btn-primary pull-right') }}
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
Expand Down Expand Up @@ -41,7 +41,7 @@
<td>{{ model.owner }}</td>
<td>{{ model.modified_time }}</td>
<td>
{{ link_to("/webtools.php?_url=/models/edit/" ~ rawurlencode(model.filename),
{{ link_to(webtools_uri ~ "?_url=/models/edit/" ~ rawurlencode(model.filename),
'<i class="fa fa-pencil"></i>', 'class': 'btn btn-default btn-xs') }}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Web/Tools/Views/scaffold/generate.volt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ flashSession.output() }}

<div class="box box-success">
<form role="form" class="form-horizontal" name="generate-scaffold" method="post" action="{{ url.get("/webtools.php?_url=/scaffold/generate") }}">
<form role="form" class="form-horizontal" name="generate-scaffold" method="post" action="{{ url.get(webtools_uri ~ "?_url=/scaffold/generate") }}">
<div class="box-header with-border">
<p class="pull-left">We will use templates from: [{{ template_path }}]</p>
{{ submit_button("Generate", "class": "btn btn-success pull-right") }}
Expand Down
2 changes: 1 addition & 1 deletion templates/project/micro/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ dbname = test
modelsDir = ../app/models/
migrationsDir = ../app/migrations/
viewsDir = ../app/views/
baseUri = /@@name@@/
baseUri = /
2 changes: 1 addition & 1 deletion templates/project/micro/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
'modelsDir' => APP_PATH . '/models/',
'migrationsDir' => APP_PATH . '/migrations/',
'viewsDir' => APP_PATH . '/views/',
'baseUri' => '/@@name@@/',
'baseUri' => '/',
]
]);
11 changes: 11 additions & 0 deletions templates/project/micro/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@
return $connection;
});

/**
* Register router
*/
$di->setShared('router', function () {
$router = new \Phalcon\Mvc\Router();
$router->setUriSource(
\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI
);

return $router;
});
2 changes: 1 addition & 1 deletion templates/project/modules/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ modelsDir = ../apps/frontend/models/
migrationsDir = ../apps/migrations/
cacheDir = ../../cache/
viewsDir = ../apps/frontend/views/
baseUri = /@@name@@/
baseUri = /
6 changes: 1 addition & 5 deletions templates/project/modules/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
'modelsDir' => APP_PATH . '/common/models/',
'migrationsDir' => APP_PATH . '/migrations/',
'cacheDir' => BASE_PATH . '/cache/',

// This allows the baseUri to be understand project paths that are not in the root directory
// of the webpspace. This will break if the public/index.php entry point is moved or
// possibly if the web server rewrite rules are changed. This can also be set to a static path.
'baseUri' => preg_replace('/public([\/\\\\])index.php$/', '', $_SERVER["PHP_SELF"]),
'baseUri' => '/',
],

/**
Expand Down
3 changes: 3 additions & 0 deletions templates/project/modules/services_web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
$router = new Router();

$router->setDefaultModule('frontend');
$router->setUriSource(
Router::URI_SOURCE_SERVER_REQUEST_URI
);

return $router;
});
Expand Down
2 changes: 1 addition & 1 deletion templates/project/simple/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ viewsDir = ../app/views/
pluginsDir = ../app/plugins/
libraryDir = ../app/library/
cacheDir = ../cache/
baseUri = /@@name@@/
baseUri = /

[models]
metadata.adapter = "Memory"
6 changes: 1 addition & 5 deletions templates/project/simple/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
'pluginsDir' => APP_PATH . '/plugins/',
'libraryDir' => APP_PATH . '/library/',
'cacheDir' => BASE_PATH . '/cache/',

// This allows the baseUri to be understand project paths that are not in the root directory
// of the webpspace. This will break if the public/index.php entry point is moved or
// possibly if the web server rewrite rules are changed. This can also be set to a static path.
'baseUri' => preg_replace('/public([\/\\\\])index.php$/', '', $_SERVER["PHP_SELF"]),
'baseUri' => '/',
]
]);
13 changes: 13 additions & 0 deletions templates/project/simple/services.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Phalcon\Mvc\Router;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Php as PhpEngine;
use Phalcon\Mvc\Url as UrlResolver;
Expand Down Expand Up @@ -110,3 +111,15 @@

return $session;
});

/**
* Register router
*/
$di->setShared('router', function () {
$router = new Router();
$router->setUriSource(
Router::URI_SOURCE_SERVER_REQUEST_URI
);

return $router;
});

0 comments on commit 730e542

Please sign in to comment.