Skip to content

[Content]: Coding guideline examples incorrect #753

@jamie-s-white

Description

@jamie-s-white

Product

None

Description

The coding guidelines have examples which don't work, and, never have:

https://craftcms.com/docs/5.x/extend/coding-guidelines.html

For example:

Use those instead of their magic properties:

// Bad:
\Craft::$app->entries->saveEntry($entry);

// Better:
\Craft::$app->getEntries()->saveEntry($entry);

Neither of these lines of code work in Craft 3, 4 or 5, where they are shown.

The correct code should be:

Craft::$app->getElements()->saveElement($entry);

I believe this was corrupted when rewritten from Craft 2:

craft()->entries->saveEntry($entry);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions