auraphp / aura.payload Goto Github PK
View Code? Open in Web Editor NEWA Domain Payload implementation.
License: MIT License
A Domain Payload implementation.
License: MIT License
So the quality flag in readme is broken https://scrutinizer-ci.com/g/auraphp/Aura.Payload/
Did you envision the $messages
attribute to be an array of messages, similar to the $output
attribute, which is often treated as shown in the example below. I realize how $messages
and $output
are treated by user-derived classes is really up to us the users. I would however like to try to stay true to your vision to ensure that my code always plays well with the Aura and related-projects ecosystem. Thanks.
class Payload extends AuraPayload
{
/**
*
* Output values carried in the payload.
*
* @var array
*
*/
protected $output = [];
/**
*
* Converts the Payload to an array.
*
* @return array
*
*/
public function asArray()
{
$arr = [];
foreach (get_object_vars($this) as $key => $val) {
$arr[$key] = $val;
}
return $arr;
}
/**
*
* Merges added output values with the existing ones.
*
* @param array $output Merge these values with the existing ones.
**
* @return $this
*/
public function addOutput(array $output)
{
$this->output = array_merge($this->output, $output);
return $this;
}
}
It's weird to me that the PayloadInterface is in a separate repository. If someone wanted to use the interface, they could do so without using the implemented class. The usability of the current interface is also questionable, since it uses a weird namespace.
I think Payload and PayloadInterface should be merged into a single repository.
Was there ever any discussion on mutability?
I see that equips payload is immutable, and thought I remembered some discussion around the matter, but now that I'm looking, I don't see it.
Was immutability consciously rejected for a reason?
How do we create a payload that redirects to another location? I don't see anything in the current statuses that would be semantically correct.
Shouldn't the Aura\Payload\PayloadFactory
have more methods; especially when creating payloads of different statuses.
E.g.
$foundPayload = $this->payloadFactory->found()->setOutput(...);
$notFoundPayload = $this->payloadFactory->notFound()->setMessages(['Resource is missing.']);
I can write the PR if you do want this functionality.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.