Comments (6)
Sounds reasonable for 2.1 but I'd go a bit further by passing result through allowing to post-process it:
return $this->afterRun($result);
Can't be done in 2.0 because of method signature change.
from yii-core.
Sorry) I'm talking about this piece of code here https://github.com/yiisoft/yii2/blob/master/framework/base/Action.php#L94-L95
public function runWithParams($params)
{
...
if ($this->beforeRun()) {
$result = call_user_func_array([$this, 'run'], $args);
$this->afterRun();
return $result;
}
...
}
Wouldn't it be right to pass $result
to afterRun()
before returning it? Like this:
...
if ($this->beforeRun()) {
$result = call_user_func_array([$this, 'run'], $args);
$this->afterRun($result);
return $result;
}
...
To be able to analyze the result of the action in afterRun()
and change afterRun()
's execution accordingly. Right now I came up with a solution where I pass stuff through action class parameters. But it just seems not right. Or maybe I'm wrong, that was the base question) Is it worth making a PR or even talking about?
An example: action class which sends some specific EventSource stuff to the browser before and after each action.
class Operation extends \yii\base\Action
{
...
protected function beforeRun()
{
\Yii::$app->getLog()->targets['operation']->rotateFiles();
$this->log('Operation begin [' . date('Y-m-d H:i:s') . ']');
EventSource::begin();
return true;
}
protected function afterRun()
{
... this is where it would be nice to have action run result to change $data ...
EventSource::end($data);
$this->log('Operation end [' . date('Y-m-d H:i:s') . ']');
}
...
}
from yii-core.
Sorry I read your message three times but I do not get what you are asking :) Could you rephrase or explain in more detail please?
from yii-core.
Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:
- When does the issue occur?
- What do you see?
- What was the expected result?
- Can you supply us with a stacktrace? (optional)
- Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)
Thanks!
This is an automated comment, triggered by adding the label status:need more info
.
from yii-core.
+1
I think it's reasonable to pass the result to afterRun
With out the result of run() to be passed to afterRun, afterRun can do very few things.
from yii-core.
The issue doesn't apply to new code anymore.
from yii-core.
Related Issues (20)
- `data` dirs in tests HOT 5
- Debug code in Model? HOT 3
- \yii\base\Application constructor parameter HOT 2
- 我认为yii3最应该解决的就是composer包过大的问题 HOT 2
- Should not require yii-web HOT 11
- Enhancement: BaseJson::decode supports decode options HOT 1
- Discuss: Do we still need controllers? HOT 2
- Enhancement: StringHelper::isEmpty() HOT 7
- can't visit yii forum site HOT 1
- Review helpers naming and usage HOT 33
- Url::ensureScheme should fail hard for non absolute paths HOT 2
- What is the current dependency between repo? HOT 20
- Yii3 assets path not correctly reference if installed in subfolder HOT 2
- SOLID compliance HOT 3
- Custom reference syntax to class or class member in comments make impossible to navigate in IDE HOT 19
- Change namespace to Yiisoft\Core? HOT 8
- When will yii3 be released? HOT 1
- Request to separate FileHelper from yii-core HOT 19
- Pack requirements checker into separate package HOT 1
- Repo merges into a repo and then splits HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii-core.