Comments (8)
AFAIU, the entity is persisted and has been modified in memory so
$entity->getStatus() & FlexibleEntityInterface::STATUS_EXIST; // return true
$entity->getStatus() & FlexibleEntityInterface::STATUS_MODIFIED; // return true as well
So status is a linear combination of 1×1 + 1×2 = 3 (both modified and persisted).
Is there something I am missing ?
from modelmanager.
There is no such status as 3 and if I call get method I want to get current status without bitwise operations. Check your phpdoc for FlexibleEntityInterface::status(). Also StatefulEntityTrait::status() method should check for available statuses before assign new value.
from modelmanager.
That's true, the doc block doesn't state it can also be a combination of 4 different possible states:
0 = none
1 = persisted
2 = modified
3 = persisted + modified
If a new state is needed (let's say TAINTED) it would be 4 and this will give 8 possible states for the FlexibleEntity. I am going to make the doc block more meaningful about that.
There used to be isModified()
and isPersisted()
methods in Pomm 1 but they are not present in Pomm2 since using bitwise operations with named constants makes the code self explained and more flexible.
True, the status($status)
method does not validate the status. Since the status mechanism is extensible I think it would be a problem to limit the status system. Any ideas ?
from modelmanager.
https://github.com/pomm-project/ModelManager/blob/master/sources/lib/Model/FlexibleEntity/StatefulEntityTrait.php#L34
Is it ok that we can assign any value to state?
from modelmanager.
I have updated my previous post on that topic. From my point of view, yes it is ok since developers can declare new netmask constants(4, 8, 16 etc.) so I feel like setting unknown value to status (let's say 255) will still be at least PERSISTED and MODIFIED with unknown other states so it doesn't break the actual status mechanism.
Any other opinions welcome.
from modelmanager.
You mean it would be nice to cast the parameter as an int
to compensate for PHP lack of type check ?
from modelmanager.
Yes, at least. It would be great to have code like this too
if (!in_array($status, FlexibleEntityInterface::getStatuses())) {
throw new FoundationException(...);
}
from modelmanager.
👍 to cast the status as integer.
Testing the available status is not that simple because status is a bitmask of possible states. getStatuses() would have to return all possible combinations of available statuses (given they are registered). Furthermore, this method getStatuses()
would collide with an entity field named statuses
(likely to happen).
from modelmanager.
Related Issues (20)
- Make the use of prepared statement configurable
- WriteQueries :: UpdateByWhere HOT 12
- Get model class from entity HOT 6
- Disable Prefixing with session name and/or schema HOT 3
- Switching schema on the fly HOT 1
- Object hydration problem when the binding is null
- StatefulEntityTrait::status() method is confusing HOT 16
- FlexibleEntityInterface::fields() and FlexibleEntityInterface::extract() are somehow a bit redundant HOT 1
- Error docs HOT 2
- Bulk processing HOT 5
- PgEntity convert null value into empty string HOT 7
- Choose not to return the projection of the query HOT 2
- Model and interfaces
- When `FlexibleEntity::extract` is overloaded, the `Model::insertOne` method fails
- Model & entity generator to read what to generate from a file HOT 2
- Possibly missing information in Quick Pomm2 setup HOT 3
- Null value casted in string HOT 3
- Collection Filters HOT 1
- Possibly missing information in Quick Pomm2 setup HOT 2
- Does Pomm suffer of the problem of useless order by on some ORM prefetches ? 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 modelmanager.