當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。