CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
      • Association
      • Attribute
      • Behavior
      • Exception
      • Locator
      • Query
      • Rule
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Trait AssociationsNormalizerTrait

Contains methods for parsing the associated tables array that is typically passed to a save operation

Namespace: Cake\ORM

Property Summary

  • $associationOptions protected
    array<string, int>

    List of option names accepted inside an association's options array.

    Unknown string keys are treated as nested association aliases so that contain-style associated arrays also work with lowercase aliases.

Method Summary

  • extractAssociations() protected

    Extracts association names from options array, separating them from actual options.

    This allows a contain-style nested array format in the shared associated option:

    • ['Users', 'Comments'] contains nested associations
    • ['Users' => [...], 'Comments'] contains nested associations
    • ['onlyIds' => true, 'validate' => false] contains options
    • ['Users', 'onlyIds' => true] contains associations and options
  • normalizeAssociations() protected

    Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines.

    This method now supports the same nested array format as contain(), allowing:

    • Dot notation: ['First.Second']
    • Nested arrays: ['First' => ['Second', 'Third']]
    • Mixed with options: ['First' => ['Second', 'onlyIds' => true]]

    Known option names are parsed as options. Unknown string keys are parsed as association aliases. If an association alias collides with an option name, use dot notation or the explicit associated option.

Method Detail

extractAssociations() ¶ protected

extractAssociations(array $options): array

Extracts association names from options array, separating them from actual options.

This allows a contain-style nested array format in the shared associated option:

  • ['Users', 'Comments'] contains nested associations
  • ['Users' => [...], 'Comments'] contains nested associations
  • ['onlyIds' => true, 'validate' => false] contains options
  • ['Users', 'onlyIds' => true] contains associations and options
Parameters
array $options

The options array that may contain nested associations.

Returns
array

An array with two elements: [associations, options]

normalizeAssociations() ¶ protected

normalizeAssociations(array|string $associations): array

Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines.

This method now supports the same nested array format as contain(), allowing:

  • Dot notation: ['First.Second']
  • Nested arrays: ['First' => ['Second', 'Third']]
  • Mixed with options: ['First' => ['Second', 'onlyIds' => true]]

Known option names are parsed as options. Unknown string keys are parsed as association aliases. If an association alias collides with an option name, use dot notation or the explicit associated option.

Parameters
array|string $associations

The array of included associations.

Returns
array

An array having dot notation transformed into nested arrays

Property Detail

$associationOptions ¶ protected

List of option names accepted inside an association's options array.

Unknown string keys are treated as nested association aliases so that contain-style associated arrays also work with lowercase aliases.

Type
array<string, int>
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs