/** * Sets the property name that should be filled with data from the target table * in the source table record. * If no arguments are passed, currently configured type is returned. * * @param string|null $name The name of the property. Pass null to read the current value. * @return string */ public function property($name = null) { if ($name !== null) { return parent::property($name); } if ($name === null && !$this->_propertyName) { list(, $name) = pluginSplit($this->_name); $this->_propertyName = Inflector::underscore(Inflector::singularize($name)); } return $this->_propertyName; }
/** * Helper method for saving an association's data. * * @param Association $association The association object to save with. * @param Entity $entity The entity to save * @param array $nested Options for deeper associations * @param array $options Original options * @return bool Success */ protected function _save($association, $entity, $nested, $options) { if (!$entity->dirty($association->property())) { return true; } if (!empty($nested)) { $options = (array) $nested + $options; } return (bool) $association->save($entity, $options); }
/** * Registers a table alias, typically loaded as a join in a query, as belonging to * an association. This helps hydrators know what to do with the columns coming * from such joined table. * * @param string $alias The table alias as it appears in the query. * @param \Cake\ORM\Association $assoc The association object the alias represents; * will be normalized * @param bool $asMatching Whether or not this join results should be treated as a * 'matching' association. * @param string $targetProperty The property name where the results of the join should be nested at. * If not passed, the default property for the association will be used. * @return void */ public function addToJoinsMap($alias, Association $assoc, $asMatching = false, $targetProperty = null) { $this->_joinsMap[$alias] = new EagerLoadable($alias, ['aliasPath' => $alias, 'instance' => $assoc, 'canBeJoined' => true, 'forMatching' => $asMatching, 'targetProperty' => $targetProperty ?: $assoc->property()]); }