Skip to content

Commit

Permalink
Merge pull request #243 from Asgraf/master
Browse files Browse the repository at this point in the history
cakephp 3.6 deprecation fixes
  • Loading branch information
josegonzalez authored May 5, 2018
2 parents 2b4fa78 + 74251de commit dd5e9f6
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 31 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
}
],
"require": {
"cakephp/cakephp": "~3.4",
"friendsofcake/crud": "*",
"friendsofcake/bootstrap-ui": "~1.2"
"cakephp/cakephp": "^3.5",
"friendsofcake/crud": "^5.4",
"friendsofcake/bootstrap-ui": "^1.4"
},
"require-dev": {
"friendsofcake/cakephp-test-utilities": "^1.0",
"markstory/asset_compress": "^3.2",
"phpunit/phpunit": "^5.7|^6.0"
"phpunit/phpunit": "^5.7.14|^6.0"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 14 additions & 14 deletions src/Listener/ViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function beforePaginate(Event $event)
$this->associations = $this->_associations(array_keys($related));
}

if (!$event->getSubject()->query->contain()) {
if (!$event->getSubject()->query->getContain()) {
$event->getSubject()->query->contain($this->_getRelatedModels(['manyToOne', 'oneToOne']));
}
}
Expand All @@ -78,7 +78,7 @@ public function beforePaginate(Event $event)
*/
public function beforeRender(Event $event)
{
if ($this->_controller()->name === 'Error') {
if ($this->_controller()->getName() === 'Error') {
return;
}

Expand Down Expand Up @@ -147,7 +147,7 @@ protected function _getPageTitle()
$scope = $action->getConfig('scope');

$request = $this->_request();
$actionName = Inflector::humanize(Inflector::underscore($request->action));
$actionName = Inflector::humanize(Inflector::underscore($request->getParam('action')));
$controllerName = $this->_controllerName();

if ($scope === 'table') {
Expand Down Expand Up @@ -211,14 +211,14 @@ protected function _getRelatedModels($associationTypes = [])
foreach ($associationTypes as $assocType) {
$associations = array_merge(
$associations,
$this->_table()->associations()->type($assocType)
$this->_table()->associations()->getByType($assocType)
);
}
}

$models = [];
foreach ($associations as $assoc) {
$models[] = $assoc->name();
$models[] = $assoc->getName();
}
}

Expand Down Expand Up @@ -265,9 +265,9 @@ protected function _getPageVariables()
'modelSchema' => $table->getSchema(),
'displayField' => $table->getDisplayField(),
'singularHumanName' => Inflector::humanize(Inflector::underscore(Inflector::singularize($controller->modelClass))),
'pluralHumanName' => Inflector::humanize(Inflector::underscore($controller->name)),
'singularVar' => Inflector::singularize($controller->name),
'pluralVar' => Inflector::variable($controller->name),
'pluralHumanName' => Inflector::humanize(Inflector::underscore($controller->getName())),
'singularVar' => Inflector::singularize($controller->getName()),
'pluralVar' => Inflector::variable($controller->getName()),
'primaryKey' => $table->getPrimaryKey(),
];

Expand Down Expand Up @@ -351,7 +351,7 @@ protected function _controllerName()
$inflections[] = 'singularize';
}

$baseName = $this->_controller()->name;
$baseName = $this->_controller()->getName();
foreach ($inflections as $inflection) {
$baseName = Inflector::$inflection($baseName);
}
Expand Down Expand Up @@ -539,13 +539,13 @@ protected function _associations(array $whitelist = [])
$associationConfiguration[$type] = [];
}

$assocKey = $association->name();
$assocKey = $association->getName();
$associationConfiguration[$type][$assocKey]['model'] = $assocKey;
$associationConfiguration[$type][$assocKey]['type'] = $type;
$associationConfiguration[$type][$assocKey]['primaryKey'] = $association->target()->getPrimaryKey();
$associationConfiguration[$type][$assocKey]['displayField'] = $association->target()->getDisplayField();
$associationConfiguration[$type][$assocKey]['foreignKey'] = $association->foreignKey();
$associationConfiguration[$type][$assocKey]['propertyName'] = $association->property();
$associationConfiguration[$type][$assocKey]['primaryKey'] = $association->getTarget()->getPrimaryKey();
$associationConfiguration[$type][$assocKey]['displayField'] = $association->getTarget()->getDisplayField();
$associationConfiguration[$type][$assocKey]['foreignKey'] = $association->getForeignKey();
$associationConfiguration[$type][$assocKey]['propertyName'] = $association->getProperty();
$associationConfiguration[$type][$assocKey]['plugin'] = pluginSplit($association->className())[0];
$associationConfiguration[$type][$assocKey]['controller'] = $assocKey;
$associationConfiguration[$type][$assocKey]['entity'] = Inflector::singularize(Inflector::underscore($assocKey));
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/ViewSearchListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function _deriveFields()

$input['value'] = $request->getQuery($field);

if (empty($input['options']) && $schema->columnType($field) === 'boolean') {
if (empty($input['options']) && $schema->getColumnType($field) === 'boolean') {
$input['options'] = ['No', 'Yes'];
$input['type'] = 'select';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Template/Element/actions.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ $links = [];
foreach ($actions as $name => $config) {
$config += ['method' => 'GET'];

if ((empty($config['url']['controller']) || $this->request->controller === $config['url']['controller']) &&
(!empty($config['url']['action']) && $this->request->action === $config['url']['action'])
if ((empty($config['url']['controller']) || $this->request->getParam('controller') === $config['url']['controller']) &&
(!empty($config['url']['action']) && $this->request->getParam('action') === $config['url']['action'])
) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Element/index/bulk_actions/form_end.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $submitButton = $this->Form->button(__d('crud', 'Apply'), [
'name' => '_bulk',
]);

echo $this->Form->input('action', [
echo $this->Form->control('action', [
'empty' => __d('crud', 'Bulk Actions'),
'label' => [
'class' => 'col-sm-2 control-label',
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Element/search.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (empty($searchInputs)) {
?>

<fieldset>
<?= $this->Form->inputs($searchInputs, ['fieldset' => false]); ?>
<?= $this->Form->controls($searchInputs, ['fieldset' => false]); ?>
<?= $this->Form->button(__d('crud', 'Filter results'), ['type' => 'submit', 'class' => 'btn btn-primary']); ?>
</fieldset>

Expand Down
2 changes: 1 addition & 1 deletion src/Template/Layout/default.ctp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="<?= \Locale::getPrimaryLanguage(\Cake\I18n\I18n::locale()) ?>">
<html lang="<?= \Locale::getPrimaryLanguage(\Cake\I18n\I18n::getLocale()) ?>">
<head>
<?= $this->Html->charset(); ?>
<title><?= $this->get('title');?></title>
Expand Down
2 changes: 1 addition & 1 deletion src/View/Cell/TablesListCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function display($tables = null, $blacklist = null)
{
if (empty($tables)) {
$connection = ConnectionManager::get('default');
$schema = $connection->schemaCollection();
$schema = $connection->getSchemaCollection();
$tables = $schema->listTables();
ksort($tables);

Expand Down
7 changes: 2 additions & 5 deletions src/View/Helper/CrudViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,8 @@ public function introspect($field, $value, array $options = [])
public function columnType($field)
{
$schema = $this->schema();
if (method_exists($schema, 'baseColumnType')) {
return $schema->baseColumnType($field);
}

return $schema->columnType($field);
return $schema->getColumnType($field);
}

/**
Expand Down Expand Up @@ -390,7 +387,7 @@ public function currentModel()
/**
* Get model schema.
*
* @return \Cake\Database\Schema\Table
* @return \Cake\Database\Schema\TableSchemaInterface
*/
public function schema()
{
Expand Down
2 changes: 1 addition & 1 deletion src/View/Widget/DateTimeWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function render(array $data, ContextInterface $context)
$disabled = isset($data['disabled']) && $data['disabled'] ? 'disabled' : '';
$role = isset($data['role']) ? $data['role'] : 'datetime-picker';
$format = null;
$locale = isset($data['locale']) ? $data['locale'] : I18n::locale();
$locale = isset($data['locale']) ? $data['locale'] : I18n::getLocale();

$timezoneAware = Configure::read('CrudView.timezoneAwareDateTimeWidget');

Expand Down

0 comments on commit dd5e9f6

Please sign in to comment.