Adds support for bundle-specific models for Drupal 8 entities.
Development of this project is moved to Drupal.org: https://www.drupal.org/project/entity_model.
Adds support for bundle-specific models for Drupal 8 entities.
License: MIT License
Adds support for bundle-specific models for Drupal 8 entities.
Development of this project is moved to Drupal.org: https://www.drupal.org/project/entity_model.
I think we should remove this line:
is_a($argument->getType(), FormStateInterface::class, true)
from ModelValueResolver
. I'm not against what it does, I just think wmmodel isn't the right place for that. I think a core patch for this issue in the relevant projects would be better.
phpstan.neon
config file referencing the wmcodestyle
rule files (example)phpstan analyse
to the coding-standards
composer scriptautoload-dev
entry to ensure autoloading during analysisToday I discovered specifying bundles for the entity param converter is already possible in core, since #3155568: Filter by bundle in EntityConverter route param converter. This was added in Drupal 9.2, but since we now require Drupal 9.3 we can remove our own EntityBundleConverter
.
The ModelValueResolver
resolves the same argument multiple times in some cases.
For instance with this controller:
class Controller {
public function show(Page $a, Page $b) {}
}
and this route:
my_route:
path: 'foobar/{a}/{b}'
defaults:
_controller: 'Controller::show'
options:
parameters:
a: {type: 'entity:node'}
b: {type: 'entity:node'}
And then visiting /foobar/123/456
I expect that when the show
method of my controller is called, the$b
argument is resolved to a Node with id 456
.
The $a
and $b
argument are the same.
I think we should remove the AccountProxy
override. This changes core logic, which might break stuff on certain installations. Looking at the code, I'm also not sure whether it's still necessary. The only difference with the core logic I can spot is that in case the user is anonymous, a AnonymousUserSession
object is returned instead of a UserInterface
object. Is that really necessary?
Make models Drupal plugins.
Instead of using our custom ModelFinder
service, we should use the built-in plugin discovery of Drupal. The entity type and bundle would become parameters of the annotation. This way we can also get rid of the getModelInfo
, entityType
, bundleName
, bundleDeduceRegex
and snake
methods on the WmModel
trait.
In #17 (comment) we prepared this module for Drupal 9.3 and it became patch-less ๐
However we haven't updated the README to reflect you no longer need to use a patch.
entity_model
We'll have to increase the minimum core version, but we'll be able to get rid of the patch. See https://www.drupal.org/project/drupal/issues/2570593.
AccountProxy::getAccount()
does not return our own User
implementation
while EntityTypeManager::getStorage('user')->load()
does.
@see AccountProxy::loadUserEntity()
difference between EntityTypeManager::getStorage()
and EntityManager::getStorage()
?
Returns a \Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException
from \Drupal\Core\Entity\EntityTypeRepository::getEntityTypeFromClass
.
We'll need to override the static Load
static method as done in src/Entity/Traits/WmModel.php
The ModelValueResolver resolves for optional parameters.
Assume we have a route to move the relation between tags.
foo.mark_tag_as_root:
path: /move/{tag}
options:
parameters:
tag: {type: 'entity:taxonomy_term'}
foo.mark_tag_as_child:
path: /move/{tag}/{parentTag}
options:
parameters:
tag: {type: 'entity:taxonomy_term'}
parentTag: {type: 'entity:taxonomy_term'}
And this controller method:
public function move(Tag $tag, ?Tag $parentTag = null): void
{
if (!$parentTag) {
// Mark $tag as root
} else {
// Mark $tag as child of $parentTag
}
}
When I visit /move/123
, I expect:
$tag
to be a Term with id 123$parentTag
to be null
.$parentTag
is the same as $tag
instead of null
When working with node bundle "Vacature" and "Vacatures" the singularizing in the wmmodel cause key clashing and missed mapping. I would suggest taking out any singularizing.
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.