當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityInterface::visibleProperties方法代碼示例

本文整理匯總了PHP中Cake\Datasource\EntityInterface::visibleProperties方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityInterface::visibleProperties方法的具體用法?PHP EntityInterface::visibleProperties怎麽用?PHP EntityInterface::visibleProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Datasource\EntityInterface的用法示例。


在下文中一共展示了EntityInterface::visibleProperties方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _getErrors

 /**
  * Extracts nested validation errors
  *
  * @param EntityInterface $entity Entity to extract
  *
  * @return array
  */
 protected function _getErrors(EntityInterface $entity)
 {
     $errors = $entity->errors();
     foreach ($entity->visibleProperties() as $property) {
         $v = $entity[$property];
         if ($v instanceof EntityInterface) {
             $errors[$property] = $this->_getErrors($v);
         } elseif (is_array($v)) {
             foreach ($v as $key => $varValue) {
                 if ($varValue instanceof EntityInterface) {
                     $errors[$property][$key] = $this->_getErrors($varValue);
                 }
             }
         }
     }
     return Hash::filter($errors);
 }
開發者ID:ansidev,項目名稱:cakephp_blog,代碼行數:24,代碼來源:VariablesPanel.php

示例2: propertyExists

 /**
  * Checks if the provided entity has defined certain $property, regardless of
  * its value.
  *
  * @param \Cake\Datasource\EntityInterface $entity The entity to check
  * @param string $property The property name
  * @return bool True if exists
  */
 public function propertyExists(EntityInterface $entity, $property)
 {
     $visibleProperties = $entity->visibleProperties();
     return in_array($property, $visibleProperties);
 }
開發者ID:quickapps-plugins,項目名稱:eav,代碼行數:13,代碼來源:EavToolbox.php

示例3: _calculateHash

 /**
  * Generates a unique hash for the given entity.
  *
  * Used by revision system to detect if an entity has changed or not.
  *
  * @param \Cake\Datasource\EntityInterface $entity The entity for which calculate its hash
  * @return string MD5 hash for this particular entity
  */
 protected function _calculateHash($entity)
 {
     $hash = [];
     foreach ($entity->visibleProperties() as $property) {
         if (strpos($property, 'created') === false && strpos($property, 'created_by') === false && strpos($property, 'modified') === false && strpos($property, 'modified_by') === false) {
             if ($property == '_fields') {
                 foreach ($entity->get('_fields') as $field) {
                     if ($field instanceof \Field\Model\Entity\Field) {
                         $hash[] = is_object($field->value) || is_array($field->value) ? md5(serialize($field->value)) : md5($field->value);
                     }
                 }
             } else {
                 $hash[] = $entity->get($property);
             }
         }
     }
     return md5(serialize($hash));
 }
開發者ID:quickapps-plugins,項目名稱:content,代碼行數:26,代碼來源:ContentsTable.php

示例4: _getChangelog

 /**
  * Creates changelog report in string format.
  *
  * Example:
  *
  * Subject: changed from 'Foo' to 'Bar'.
  * Content: changed from 'Hello world' to 'Hi there'.
  *
  * @param \Cake\Datasource\EntityInterface $entity Entity instance
  * @return string
  */
 protected function _getChangelog(EntityInterface $entity)
 {
     $result = '';
     // plain changelog if entity is new
     if ($entity->isNew()) {
         return $result;
     }
     // get entity's modified fields
     $fields = $entity->extractOriginalChanged($entity->visibleProperties());
     if (empty($fields)) {
         return $result;
     }
     // remove ignored fields
     foreach ($this->_ignoredFields as $field) {
         if (!array_key_exists($field, $fields)) {
             continue;
         }
         unset($fields[$field]);
     }
     if (empty($fields)) {
         return $result;
     }
     foreach ($fields as $k => $v) {
         $result .= sprintf(static::CHANGELOG, Inflector::humanize($k), $v, $entity->{$k});
     }
     return $result;
 }
開發者ID:QoboLtd,項目名稱:cakephp-csv-migrations,代碼行數:38,代碼來源:ModelAfterSaveListener.php

示例5: _prepareCachedColumns

 /**
  * Prepares entity's cache-columns (those defined using `cache` option).
  *
  * @param \Cake\Datasource\EntityInterface $entity The entity to prepare
  * @return \Cake\Datasource\EntityInterfa Modified entity
  */
 protected function _prepareCachedColumns(EntityInterface $entity)
 {
     if ($this->config('cacheMap')) {
         foreach ((array) $this->config('cacheMap') as $column => $fields) {
             if (in_array($column, $entity->visibleProperties())) {
                 $string = $entity->get($column);
                 if ($string == serialize(false) || @unserialize($string) !== false) {
                     $entity->set($column, unserialize($string));
                 } else {
                     $entity->set($column, new CachedColumn());
                 }
             }
         }
     }
     return $entity;
 }
開發者ID:quickapps-plugins,項目名稱:eav,代碼行數:22,代碼來源:EavBehavior.php


注:本文中的Cake\Datasource\EntityInterface::visibleProperties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。