-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft yiisoft/view assets, and view no merge. #50
Conversation
terabytesoftw
commented
Aug 23, 2019
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Tests pass? | ✔️ |
Fixed issues | #49 |
[x] AssetBundleTest. Done. If you can fix the travis configuration. Thks, |
I was thinking about alternatives but haven't found better ones yet :( If you have any ideas, feel free to post them for discussion. There is interesting forum discussion about Html helper https://forum.yiiframework.com/t/using-functions-for-html-generation/126814/24 with the idea of having Also, instead of config, config-methods could be used to make configuration in IDEs more handy.
It is not broken as far as I can see. |
I honestly believe that we should maintain the array configuration in the widgets and static helpers, I think that injecting everything through the container di would be equal to Yii2, in my opinion the views are only the representation of the result, and using static helpers would be fine, for on the other hand we would leave things like Yii2 like helpers and widgets that do not need a great design, I was reviewing the OptionsResolver Component of Symfony, it could be a good alternative to better control the matrix configurations. And with respect to travis it was if the configuration of .travis.yml was already standardized. |
We should create a repository of exceptions, we need to have more specific exceptions, those of php are very generic. What is the replacement for:
I can update the configuration of .travis.yml to that of Please Add repo scrutinizer, coverage tests AssetBundle (100%), AssetConverter (94%), Thks, |
Create ones you need right in this repository.
Please do. |
Done. |
@samdark What do you think about injecting the aliases and assetconverter into the bundle __construct() to use it in the same bundle. Example:
Review the documentation please. |
I was always looking at bundles as configuration containers, not as anything that actively does things. |
It is correct but to access the converter you will have to call it from the controller, and do the conversions, I think it is a good idea in the bundle, since it is converted to publish, on the other hand I would also agree if that task is left that the developer do it on your own using sass, gulp, and any tool for it. |
Conversion may happen in many ways. Yii 2 has two out of the box ways for it:
Additionally community developed tools that generated configs for grunt/gulp and other native JavaScript builders from bundles. I think it would be a bad idea to force specific way of conversion in the bundle itself because of that. |
For widgets we must continue with the configuration of arrays since we must allow them to be easy to configure and can be changed dynamically. Example: /**
* @var array $widgetOptions
*/
private $widgetOptions = [
'setId()',
'setItems()',
];
/**
* setConfig widget options.
*
* @param array $config
*
* @throws \InvalidConfigException
*
* @return void
*/
public function setConfig(array $config): void
{
foreach ($config as $key => $item) {
if (in_array($key, $this->widgetOptions)) {
$this->$key($config['$key']);
} else {
throw new \InvalidConfigException("Widget options: ($key) no exist.");
}
}
}
protected function setId(string $value): void
{
$this->id = $value;
}
And we change the init() method to beforeRun() |
@terabytesoftw is it overall ready for thorough review? Any things that should be done before that? |
AssetBundle, AssetManager and AssetConverter work well I have tried them I am happy with that, now I would also like to fix the widgets and leave the complete operating package, of course you also have to fix i18n to establish everything well. |
How about doing that in subsequent pull request? This one's diff is already close to impossible to review (but I can handle that). |
Done. |
*/ | ||
public function init(): void | ||
public function publish(AssetManager $am): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still valid AssetBundle publishes itself with the help of asset manager. Maybe asset manager should do it completely?