To fix:

  Line   ui_patterns/src/Entity/UiPatternsSampleEntityGenerator.php                
  57     Access to an undefined property                                           
         Drupal\Core\Entity\FieldableEntityInterface::$in_preview.                 
         đź’ˇ Learn more:                                                            
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property  

Also, we may need to do something about this UiPatternsSampleEntityGenerator and its interface. Is it really a generator? Why "sample"? Can we implement an existing interface?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

Christian.wiedemann made their first commit to this issue’s fork.

christian.wiedemann’s picture

Status: Active » Needs review

The variable is only available for Nodes. Right now I don't see any usecase to set the node to preview mode. I think we can remove it safely.
If we found a case we should readd it and add a typecheck for nodes. (I think Layout Builder will hit the same phpstan exception)

pdureau’s picture

Proposals:

We duplicated SampleEntityGeneratorInterface from layout_builder module, so:

  • let's add a comment to explain why we did the copy (to avoid a dependency to this module)
  • let's add the variables typing

UiPatternsSampleEntityGenerator:

  • Can you rename SampleEntityGenerator?
  • And change the comment to not make people believe it is only related to Layout Builder.
  • let's add the variables typing
pdureau’s picture

Status: Needs review » Needs work
christian.wiedemann’s picture

Status: Needs work » Needs review
pdureau’s picture

Status: Needs review » Needs work

thanks Christian for the update. It is 99% perfect.

Is it relevant to add the type of the parameters here?
public function get($entity_type_id, $bundle_id): EntityInterface;

and here?
public function delete($entity_type_id, $bundle_id) :SampleEntityGeneratorInterface;

Did you run?

phpcbf --standard=Drupal --extensions=php,module path/to/module
phpcs --standard=Drupal --extensions=php,module path/to/module

What does "successor" means here?
Generates a sample entity for use by the UI Patterns successors.

Can you rebase your MR?

christian.wiedemann’s picture

Hi, I updated the types and the docs.

christian.wiedemann’s picture

Status: Needs work » Needs review

pdureau’s picture

Status: Needs review » Fixed
pdureau’s picture

Assigned: christian.wiedemann » Unassigned

Status: Fixed » Closed (fixed)

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