Problem/Motivation

The method doc is incorrect on the form of the compound key in addArgumentArray().

PastEventInterface:

   * The key for each will consist of the $key_prefix_$array_key

But PastEvent uses ':'

Proposed resolution

Update method doc in interface.

Maybe even allow to pass a custom delimiter as parameter?

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Arla created an issue. See original summary.

Ginovski’s picture

Status: Active » Needs review
FileSize
3.16 KB

Added a delimiter as an argument and changed the method doc.

tduong’s picture

Status: Needs review » Needs work

Nice work :)
Some nitpicks:

  1. +++ b/modules/past_db/src/Entity/PastEvent.php
    @@ -237,10 +237,10 @@ class PastEvent extends ContentEntityBase implements PastEventInterface {
    +  public function addArgumentArray($key_prefix, $delimiter, array $data, array $options = array()) {
    
    +++ b/modules/past_simpletest/src/Entity/PastEventSimpletest.php
    @@ -102,10 +102,10 @@ class PastEventSimpletest implements PastEventInterface {
    +  public function addArgumentArray($key_prefix, $delimiter, array $data, array $options = array()) {
    
    +++ b/src/PastEventInterface.php
    @@ -183,7 +185,7 @@ interface PastEventInterface {
    +  public function addArgumentArray($key_prefix, $delimiter, array $data, array $options = array());
    
    +++ b/src/PastEventNull.php
    @@ -23,7 +23,7 @@ class PastEventNull implements PastEventInterface {
    +  public function addArgumentArray($key_prefix, $delimiter, array $data, array $options = array()) {
    

    I think we can also assign a default value to this delimiter, since it used ':' then this should be the default (?).
    And probably better to have it as the last param.

  2. +++ b/src/PastEventInterface.php
    @@ -167,10 +167,12 @@ interface PastEventInterface {
    +   *   The delimiter of the arguments.
    

    Then the param doc should be helpful for the ones that read it, so you need to specify the default value here as well.

  3. +++ b/src/PastEventInterface.php
    @@ -167,10 +167,12 @@ interface PastEventInterface {
    +   * The key for each will consist of the $key_prefix_$delimiter_$array_key
    

    Better $key_prefix . $delimiter . $array_key.
    Also missing ending sentence dot :)

And don't forget to assign the issue to yourself! ;)

Ginovski’s picture

Ginovski’s picture

Status: Needs work » Needs review
tduong’s picture

Status: Needs review » Needs work

Cool, coolcoolcoolcool! *abed style* :)
Just some code style things xd

  1. +++ b/modules/past_db/src/Entity/PastEvent.php
    @@ -237,7 +237,7 @@ class PastEvent extends ContentEntityBase implements PastEventInterface {
    +  public function addArgumentArray($key_prefix, array $data, array $options = array(), $delimiter = ':') {
    
    +++ b/modules/past_simpletest/src/Entity/PastEventSimpletest.php
    @@ -102,7 +102,7 @@ class PastEventSimpletest implements PastEventInterface {
    +  public function addArgumentArray($key_prefix, array $data, array $options = array(), $delimiter = ':') {
    
    +++ b/src/PastEventInterface.php
    @@ -167,25 +167,25 @@ interface PastEventInterface {
    +  public function addArgumentArray($key_prefix, array $data, array $options = array(), $delimiter = ':');
    
    +++ b/src/PastEventNull.php
    @@ -23,7 +23,7 @@ class PastEventNull implements PastEventInterface {
    +  public function addArgumentArray($key_prefix, array $data, array $options = array(), $delimiter = ':') {
    

    Since we are touching these lines, we can also do that small code style thingy about the array syntax :D

  2. +++ b/src/PastEventInterface.php
    @@ -167,25 +167,25 @@ interface PastEventInterface {
    +   * The key for each will consist of the $key_prefix . $delimiter . $array_key.
    

    argh, 81 chars xd

    Maybe better something like "The key for each will consists of '$key_prefix . $delimiter . $array_key'."

  3. +++ b/src/PastEventInterface.php
    @@ -167,25 +167,25 @@ interface PastEventInterface {
    +   *   ':' as provided.
        * @return array
    

    Needs a white line between @params and @return :)

Ginovski’s picture

Status: Needs work » Needs review
FileSize
0 bytes
3.5 KB

Fixed the code style and changed array() to [].

Ginovski’s picture

Last interdiff was empty, ignore comment #7.

tduong’s picture

+++ b/modules/past_db/src/Entity/PastEvent.php
@@ -237,10 +237,10 @@ class PastEvent extends ContentEntityBase implements PastEventInterface {
+    $arguments = [];

+++ b/modules/past_simpletest/src/Entity/PastEventSimpletest.php
@@ -102,10 +102,10 @@ class PastEventSimpletest implements PastEventInterface {
+    $arguments = [];

+++ b/src/PastEventNull.php
@@ -23,8 +23,8 @@ class PastEventNull implements PastEventInterface {
+    return [];

Actually I meant only the function line, but I guess this won't hurt that much as unrelated change (?)
I think it's fine.

I guess is ready now. Waiting for the maintainers review :)

Berdir’s picture

Title: PastEvent::addArgumentArray wrongly documented » Allow to pass the delimiter to PastEvent::addArgumentArray()
Version: 8.x-1.0-alpha1 » 8.x-1.x-dev

Updating the issue title.

@tduong is sneaking in some array() conversions in again, I see.. ;)

Berdir’s picture

Status: Needs review » Fixed

  • Berdir committed a2b708c on 8.x-1.x authored by Ginovski
    Issue #2674820 by Ginovski: Allow to pass the delimiter to PastEvent::...
tduong’s picture

Title: Allow to pass the delimiter to PastEvent::addArgumentArray() » Allow passing the delimiter to PastEvent::addArgumentArray()

@Berdir: it hurts so much, need to clean everything! .. xd

btw, after this comment about "allow grammar syntax", i pay more attention on it.. ^^'

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.