Skip to content

Refactor settings from container#2104

Merged
akrabat merged 10 commits into
slimphp:4.xfrom
codeguy:feature-refactor-container-settings
Mar 7, 2017
Merged

Refactor settings from container#2104
akrabat merged 10 commits into
slimphp:4.xfrom
codeguy:feature-refactor-container-settings

Conversation

@codeguy

@codeguy codeguy commented Dec 11, 2016

Copy link
Copy Markdown
Member

Work in progress. Do not merge yet.

@codeguy codeguy added the Slim 4 label Dec 11, 2016
@codeguy codeguy added this to the 4.0 milestone Dec 11, 2016
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.6%) to 96.993% when pulling e6ac9e0 on codeguy:feature-refactor-container-settings into 394732e on slimphp:4.x.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.5%) to 97.11% when pulling b6c2927 on codeguy:feature-refactor-container-settings into 394732e on slimphp:4.x.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 97.649% when pulling dac7c1f on codeguy:feature-refactor-container-settings into 394732e on slimphp:4.x.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.1%) to 97.521% when pulling 7a5c616 on codeguy:feature-refactor-container-settings into 394732e on slimphp:4.x.

@codeguy

codeguy commented Dec 12, 2016

Copy link
Copy Markdown
Member Author

@akrabat What's your opinion on injecting settings in the constructor? Right now we accept a container instance in the constructor... but that will be unnecessary in 4.x. The container will be optional, so I think we should not ask for it in the constructor, but instead with a setter method setContainer($c).

We could update the constructor to accept settings though like:

$app = new \Slim\App([
    'foo' => 'bar
]);

@codeguy

codeguy commented Dec 12, 2016

Copy link
Copy Markdown
Member Author

Currently, there are two ways you may use the 3.x constructor:

$app = new App([
    'settings' => [
        // settings
    ],
    // other container items
]);

The array argument will be used to populate a default Slim container. Else, you can pass your own container-interop container into the constructor:

$app = new App($myContainer);

Both scenarios would need to change to the following signature, where the argument is optional and if present, will be merged with the default settings:

$app = new App([
    // settings
]);

@codeguy

codeguy commented Dec 17, 2016

Copy link
Copy Markdown
Member Author

@akrabat I had to merge my latest work from #2102 into this branch. So you can either merge #2102 and then merge this PR, or you can simply merge this PR.

Latest changes in this PR make the App::__construct() method accept only an array of app settings which are then merged into the default settings array. It adds a public interface to interact with app settings array. And it separates settings from the app container entirely. To do this, I added getter/setter methods for app handlers (e.g. not found, not allowed, error, php error).

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.009%) to 96.631% when pulling f957107 on codeguy:feature-refactor-container-settings into 394732e on slimphp:4.x.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.7%) to 96.611% when pulling 1db36bc on codeguy:feature-refactor-container-settings into 5abbab0 on slimphp:4.x.

@codeguy

codeguy commented Feb 19, 2017

Copy link
Copy Markdown
Member Author

Ping @akrabat. Can you review and merge this soon? I just merged in other latest changes from the primary 4.x branch.

@codeguy codeguy changed the title [WIP] Refactor settings from container [Needs Review] Refactor settings from container Feb 19, 2017

@geggleto geggleto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread Slim/App.php
}
$this->container = $container;
$this->addSettings($settings);
$this->container = new Container();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? I thought we were going to remove the container ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One step at a time :)

@akrabat
akrabat merged commit 1db36bc into slimphp:4.x Mar 7, 2017
@akrabat akrabat changed the title [Needs Review] Refactor settings from container Refactor settings from container Sep 16, 2018
@l0gicgate l0gicgate mentioned this pull request Aug 1, 2019
chriscct7 pushed a commit to awesomemotive/aioseo-slim-v3-php-8.1 that referenced this pull request Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants