Part of meta-issue #2016679: Expand Entity Type interfaces to provide methods, protect the properties.
See the detailed explanations there and look at the issues that already have patches or were commited.
Add get*, set* and additional methods as it makes sense to replace the public properties (e.g. isSomething() and something())
--
Methods added are:
BlockContentType:
getDescription();
shouldCreateNewRevision();
Todo from the patch from comment #66:
- Remove the method BlockContent::getType() and use bundle().
- Rename the method BlockContentType::isNewRevision() to BlockContentType::shouldCreateNewRevision().
| Task | Novice task? | Contributor instructions | Complete? |
|---|---|---|---|
| Reroll the patch | Novice | Instructions | |
| Review patch to ensure BlockContent didn't get properties added/deleted | probably | Instructions |
| Comment | File | Size | Author |
|---|---|---|---|
| #76 | block-content-methods-2030597-75.patch | 7.76 KB | adci_contributor |
| #76 | interdiff-66-75.txt | 3.39 KB | adci_contributor |
Comments
Comment #1
plopescUps, chaging title
Comment #2
Thomas Brekelmans commentedI'll take this one on as well :)
Comment #3
Thomas Brekelmans commentedOnly the public $description property was left for CustomBlockType. All other properties have accessor methods for them defined by the base classes ConfigEntity and/or Entity, right?
So this patch adds a getDescription() and setDescription($description) method. :)
Comment #4
Thomas Brekelmans commentedI've updated the patch to also add methods for properties on the CustomBlock entity.
I only added a getter for the custom block type as that is something that shouldn't change on the fly by anyone right?
Comment #4.0
Thomas Brekelmans commentedUpdated issue summary.
Comment #4.1
Thomas Brekelmans commentedUpdated issue summary.
Comment #5
sutharsan commentedPlease add interdiffs to follow-up patches. See https://drupal.org/documentation/git/interdiff about the why and how of interdiffs.
Comment #6
Thomas Brekelmans commentedHere's an interdiff for the patch in #4 compared to the patch in #3. :)
Comment #7
benjy commentedHow come the property is info rather than description? Seems inconsistent.
Other than this looks good.
Comment #8
berdir@param are missing the variable name, like @param string $description.
This is a content entity, so should be more something like $this->get('type')->value.
We should probably convert calls to these methods to make sure that they actually work.
Comment #9
boztek commentedRerolling #4
Comment #10
boztek commentedUsing
$this->entityType()ingetCustomBlockType()method in response to #8.Comment #11
boztek commentedComment #12
boztek commentedComment #12.0
boztek commentedUpdated issue summary.
Comment #13
jibran10: custom-block-entity-expand-custom-block-with-methods-2030597-9.patch queued for re-testing.
Comment #16
larowlanComment #17
larowlanmaybe this?
Comment #18
jibran@larowlan do you think it is a good idea to add some more assertions to an existing test so that we can test these methods.
Comment #19
larowlan@jibran - yes, or a new phpunit test?
Comment #20
daffie commented@larowlan: I did a review of your patch and it looking good.
As far as I know the drupal way at this moment for get and set functions is:
For adding a new PHPUnit test.
Some of the sub-issues of #2016679: Expand Entity Type interfaces to provide methods, protect the properties have PHPUnit tests and some have not.
Comment #21
daffie commentedComment #22
internetdevels commentedComment #23
berdirSee #8.2, this is still missing the ->value after $this->get('info') and similar.
Comment #24
chakrapani commentedHere we go.. applying the changes suggested in #8.2 (#23).
Comment #26
chakrapani commentedLooks like a random fail..queuing for re-test.
24: drupal-custom_block-expand-methods-2030597-24.patch queued for re-testing.
Comment #27
chakrapani commentedHere we go. The patch passed the tests.
Setting back to needs review.
Comment #28
karolus commentedThere is an issue with the file paths in PSR4--I'm currently checking the patch to see what needs to be fixed to make this work...
Comment #29
karolus commentedComment #30
roderikTagging.
This is not failing but still needs reroll. It is a novice task since you're totally allowed to ask the mentor about the implications/reason of PSR-4 and not go into those too deeply yourself. It comes down to this:
replace lib/Drupal/custom_block/ by src/ in the paths.
Comment #31
robbertnl commented#Amsterdamsprint2014
I am starting to work on this.
Comment #32
robbertnl commentedComment #33
basvanderheijden commentedI've rerolled your patch without the services.yaml file. You accidentally included that one. Now cleanly applies.
Comment #34
basvanderheijden commentedComment #36
robbertnl commentedThank you basvanderheijden.
I also want to add something; custom_block was renamed to content_block. This means the patch consists of more changes as specified at #30
Comment #37
daffie commentedIt is renamed to block_content. Not content_block.
In the class BlockContentType the variables $id and $label do not have to be declared. They are inherited from the class Entity.
The $revision and $description are public and must be changed to protected. The whole idea of this issue is to use encapsulation.
Comment #38
daffie commentedThe patch is 2 months old so it needs a reroll.
Comment #39
daffie commentedThe function getCustomBlockType() must be changed to getBlockContentType().
Comment #40
larowlanThe method is already getBlockContentType, just the issue title was wrong.
Fixed description and revision, added new methods for revision - made them consistent with NodeType.
$id and $label aren't in any of the base-classes for the config-entity - that's only for content entities.
Fixed some CS issues in previous patch.
New patch with re-roll
Comment #42
larowlanFixed some fails from changes at #40 but also found a fail in BlockContent::getBlockContentType, there is no ->value in ER field.
Comment #43
daffie commentedI have reviewed your patch and I give it a RTBC. All entity variables are protected. The new functions are added to their interfaces. And they are documented. I am happy.
You also changed some comments from "custom block" to "block content". It is fine by me. Only if I do a search in the module directory for the word "custom" I get 139 results. Should we make a new issue for this? There is a #2062715: [META] Many UI/UX issues with custom blocks.
Comment #44
alexpottNever used.
Never used.
What is wrong with setRevisionLog and getRevisionLog that are already on the interface. These are unused and should be removed.
Comment #45
berdir@alexpott: I noticed your "Not used" argument in a few of these issues now, but I'm a bit confused by that. In all those patches that I wrote, "being used or not" was never a relevant criteria for me. We're just seeing core, who knows what contrib will do. "Being a public API or not" should be the criteria IMHO, and things like setting the description in my opinion are?
Comment #46
daffie commentedBravely done what alexpott suggested.
Comment #47
daffie commentedComment #49
daffie commented@alexpott: Can you respond to Berdirs comment #45.
Comment #50
daffie commentedComment #51
mile23Patch does not apply.
Comment #52
rpayanmComment #53
adci_contributor commentedTrying to reroll
// patch number typo, sorry for this
Comment #55
daffie commentedGood work the_contributer. With some work we shall get it fixed!
The BlockContent class does not need this function. It is not used.
This is the entity Block. Not BlockContent or BlockContentType.
This change is not necessary.
Comment #56
adci_contributor commentedThanks for the corrections.
As for BlockContentForm.php. If we leave
$block->setNewRevision($block_type->revision);unchanged, then should we unprotect$revisionback? (or use ->isNewRevision()) Else we get a permission error.Also after last updates the 'revision' field is unknown to
$block->set. So I return it to$block->setNewRevision();Comment #60
adci_contributor commentedEh. Seems I forgot to change the seven.theme in patch.
Comment #61
daffie commentedGood work adci_contributor. Almost there. I got two minor issues for you left.
This line generates a warning: 1 line adds whitespace errors.
I think that it is better to rename this function to getType(). The entity Node has also a getType() method to get the bundle. It is part of the BlockContent entity. So it is kind of obvious that if call getType() that you get getBlockContentType().
Comment #62
adci_contributor commentedThanks again!
Comment #63
adci_contributor commentedComment #64
daffie commentedOnly one nitpick left. After that it is for me RTBC.
Nitpick: There are now two blank lines after the function isNewRevision().
Comment #65
daffie commentedComment #66
adci_contributor commentedcleaned up
Comment #67
daffie commented@adci_contributor: Please add an interdiff.txt to your patch. It makes review live a lot easier. I have added one for your last patch.
It all looks good to me.
The patch fixes the problem as described in the issue summary.
There is one new method added to the class BlockContent: getType().
There are two new methods added to the class BlockContentType: getDescription() and isNewRevision().
All documentation is in order.
The patch gets an RTBC from me.
Comment #68
alexpottThis method name is misleading since the existing content entity
isNewRevision()means something different. The revision property is about whether or not to create new revisions of the BlockContent entities not about whether the we are dealing with a new revision of the BlockContentType entity. We should rename this method to reflect this - perhaps something likecreateNewBlockContentRevision(). Also the documentation needs to clarify that this determines whether we create new revision of BlockContent entities.This is not used and unnecessary - just use the
bundle()method.Comment #69
berdirWe have getType() as well for Node, for example.
NodeTypeInterface also uses isNewRevision() for this property...
Comment #70
alexpott@Berdir ok I can buy that - it think the getType() method is a shame.
bundle()matches the key and plenty of methods andgetType()is just match the arbitrary name of the bundles. Not to mention the confusion with entity type. But we have precedence so fair enough.Comment #71
berdirYeah, consistently bad ;)
Not completely sure myself.. there is an issue open that NodeInterface::getType() is bad, suggesting getTypeId(), but the thing is that the id property of node type is type :) That's not the case for block content though.
I'm not sure that consistency with node is argument enough, just wanted to point it out :)
Comment #72
alexpottOkay because the more I think about it the more I'm inclined to think "two wrongs don;t make a right" and stick by #68. Bad names in the node module does not mean we have to have bad names in the block_content module.
Comment #73
daffie commentedTalked to @alexpott on IRC and the decision is made to change the name of isNewRevision() to shouldCreateNewRevision().
Todo from the patch from comment #66:
Comment #74
adci_contributor commentedUpdated the patch from comment #66 with the instructions from #73.Sorry. Ignore it.
Comment #76
adci_contributor commentedUpdated the patch from comment #66 with the instructions from #73.
Comment #77
daffie commentedIt all looks good to me.
All the changes that @alexpott wanted are in the patch.
The patch fixes the problem as described in the issue summary.
There are two new methods added to the class BlockContentType: getDescription() and shouldCreateNewRevision().
All documentation is in order.
The patch gets an RTBC from me.
Comment #78
alexpottHi @adci_contributor can you confirm that this account is the work of a single person rather than a shared account. As per Drupal's terms of service (https://www.drupal.org/terms) - see section A. I sent you an email via your contact form last week and I have not had a response yet. The lack of reply leads me to think that this account is a shared account.
Comment #79
larowlan+1 RTBC. Although the title mentions BlockContent, looking at HEAD it is already done
Comment #80
adci_contributor commentedHello, @alexpott
Yes, I confirm that I'm the only one who uses this account.
I didn't check emails as I was on vacation. I see your email now. Would you like me to respond it?
Thank you for accepting my patch. I hope, my account name won't confuse you again.
Comment #81
alexpott@adci_contributor thanks for responding.
Beta evaluation is in the meta. Committed a549c01 and pushed to 8.0.x. Thanks!
Comment #83
webchick