当前位置: 首页>>代码示例>>PHP>>正文


PHP Association::type方法代码示例

本文整理汇总了PHP中Cake\ORM\Association::type方法的典型用法代码示例。如果您正苦于以下问题:PHP Association::type方法的具体用法?PHP Association::type怎么用?PHP Association::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\ORM\Association的用法示例。


在下文中一共展示了Association::type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: associatedEntityTypeToHintType

 /**
  * Converts an entity class type to its DocBlock hint type counterpart.
  *
  * @param string $type The entity class type (a fully qualified class name).
  * @param \Cake\ORM\Association $association The association related to the entity class.
  * @return string The DocBlock type
  */
 public function associatedEntityTypeToHintType($type, Association $association)
 {
     if ($association->type() === Association::MANY_TO_MANY || $association->type() === Association::ONE_TO_MANY) {
         return $type . '[]';
     }
     return $type;
 }
开发者ID:AmuseXperience,项目名称:api,代码行数:14,代码来源:DocBlockHelper.php

示例2: _marshalAssociation

 /**
  * Create a new sub-marshaller and marshal the associated data.
  *
  * @param \Cake\ORM\Association $assoc The association to marshall
  * @param array $value The data to hydrate
  * @param array $options List of options.
  * @return mixed
  */
 protected function _marshalAssociation($assoc, $value, $options)
 {
     if (!is_array($value)) {
         return null;
     }
     $targetTable = $assoc->target();
     $marshaller = $targetTable->marshaller();
     $types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
     if (in_array($assoc->type(), $types)) {
         return $marshaller->one($value, (array) $options);
     }
     if ($assoc->type() === Association::ONE_TO_MANY || $assoc->type() === Association::MANY_TO_MANY) {
         $hasIds = array_key_exists('_ids', $value);
         $onlyIds = array_key_exists('onlyIds', $options) && $options['onlyIds'];
         if ($hasIds && is_array($value['_ids'])) {
             return $this->_loadAssociatedByIds($assoc, $value['_ids']);
         }
         if ($hasIds || $onlyIds) {
             return [];
         }
     }
     if ($assoc->type() === Association::MANY_TO_MANY) {
         return $marshaller->_belongsToMany($assoc, $value, (array) $options);
     }
     return $marshaller->many($value, (array) $options);
 }
开发者ID:rlugojr,项目名称:cakephp,代码行数:34,代码来源:Marshaller.php

示例3: _marshalAssociation

 /**
  * Create a new sub-marshaller and marshal the associated data.
  *
  * @param \Cake\ORM\Association $assoc The association to marshall
  * @param array $value The data to hydrate
  * @param array $options List of options.
  * @return mixed
  */
 protected function _marshalAssociation($assoc, $value, $options)
 {
     $targetTable = $assoc->target();
     $marshaller = $targetTable->marshaller();
     $types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
     if (in_array($assoc->type(), $types)) {
         return $marshaller->one($value, (array) $options);
     }
     if ($assoc->type() === Association::MANY_TO_MANY) {
         return $marshaller->_belongsToMany($assoc, $value, (array) $options);
     }
     return $marshaller->many($value, (array) $options);
 }
开发者ID:RogerSchmeier,项目名称:Webtruck,代码行数:21,代码来源:Marshaller.php


注:本文中的Cake\ORM\Association::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。